Fix compact command validation flow (#28)

* feat: Implement /compact command with processing feedback

- Add 'compact' status type to session status store
- Update SessionStatusIndicator to show purple pulsing animation for compaction
- Add summarizeSession() API method to OpenCode client
- Modify command handler for /compact to:
  - Get current model from state
  - Show compaction toast
  - Set session to compacting status
  - Call summarize endpoint with provider/model
- Update SSE handler to clear compact status on session.compacted event

The user sees a purple animated indicator and 'Compacting' text during the operation, matching the TUI experience.

* Fix compact command to use break instead of return for model validation

---------

Co-authored-by: Chris Scott <chris@cstech.dev>
This commit is contained in:
Chris ScottandChris Scott authored and GitHub committed 2025-12-19 00:10:12 -05:00
1 parent 516a894627
commit a9ebee72c4
5 files changed
+47 -7

No files matched your search

@@ -19,7 +19,7 @@ export const SessionStatusIndicator = memo(function SessionStatusIndicator({
const [retryCountdown, setRetryCountdown] = useState(0)
useEffect(() => {
if (status.type !== 'busy' && status.type !== 'retry') {
if (status.type !== 'busy' && status.type !== 'retry' && status.type !== 'compact') {
return
}
@@ -79,6 +79,13 @@ export const SessionStatusIndicator = memo(function SessionStatusIndicator({
return 'bg-amber-500/20'
}
if (statusType === 'compact') {
if (intensity > 0.8) return 'bg-purple-500'
if (intensity > 0.5) return 'bg-purple-500/70'
if (intensity > 0.2) return 'bg-purple-500/40'
return 'bg-purple-500/20'
}
if (intensity > 0.8) return 'bg-blue-500'
if (intensity > 0.5) return 'bg-blue-500/70'
if (intensity > 0.2) return 'bg-blue-500/40'
@@ -120,7 +127,7 @@ export const CompactStatusIndicator = memo(function CompactStatusIndicator({
const [frame, setFrame] = useState(0)
useEffect(() => {
if (status.type === 'idle') return
if (status.type !== 'busy' && status.type !== 'retry' && status.type !== 'compact') return
const interval = setInterval(() => {
setFrame(prev => (prev + 1) % 8)
@@ -134,13 +141,13 @@ export const CompactStatusIndicator = memo(function CompactStatusIndicator({
}
const pulseFrames = ['●', '◐', '○', '◑', '●', '◐', '○', '◑']
const color = status.type === 'retry' ? 'text-amber-500' : 'text-blue-500'
const color = status.type === 'retry' ? 'text-amber-500' : status.type === 'compact' ? 'text-purple-500' : 'text-blue-500'
return (
<span className={`inline-flex items-center gap-1.5 ${className}`}>
<span className={`${color} text-sm font-mono`}>{pulseFrames[frame]}</span>
<span className={`text-xs ${color}`}>
{status.type === 'retry' ? `Retry #${status.attempt}` : 'Working'}
{status.type === 'retry' ? `Retry #${status.attempt}` : status.type === 'compact' ? 'Compacting' : 'Working'}
</span>
</span>
)