Skip to content

The agent that grows with you

fix(desktop): show compaction progress for manual /compress

denis.dresvyanskiya59d15a0c85c
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/compaction-event.test.tsx b/apps/desktop/src/app/session/hooks/use-message-stream/compaction-event.test.tsx
index af283e77435..be7abc2365f 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/compaction-event.test.tsx
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/compaction-event.test.tsx
@@ -47,6 +47,34 @@ describe('useMessageStream compaction lifecycle', () => {
expect($compactingSessions.get()).toEqual({ [OTHER_SID]: true })
})
+ // Manual /compress pins `compressing` (methods_session._compress_live) and
+ // always clears it with `ready` from that function's `finally`. The desktop
+ // matched only the auto-compaction spelling, so /compress showed no phase at
+ // all — the TUI has handled both since createGatewayEventHandler.ts:904.
+ it('drives the compaction phase from the manual /compress spelling', () => {
+ mountStream()
+ setSessionCompacting(OTHER_SID, true)
+
+ emit('status.update', { kind: 'compressing', text: '\u280b compressing 42 messages (~120,000 tok)\u2026' })
+ expect($compactingSessions.get()).toEqual({ [OTHER_SID]: true, [SID]: true })
+
+ emit('status.update', { kind: 'ready' })
+
+ expect($compactingSessions.get()).toEqual({ [OTHER_SID]: true })
+ })
+
+ it('retires the manual /compress phase even when the compress aborted', () => {
+ mountStream()
+
+ emit('status.update', { kind: 'compressing', text: 'compressing\u2026' })
+ expect($compactingSessions.get()).toEqual({ [SID]: true })
+
+ // CompressionLockHeld / raise both land on the same `ready` edge.
+ emit('status.update', { kind: 'ready' })
+
+ expect($compactingSessions.get()).toEqual({})
+ })
+
it('clears the compaction phase on the structured completion edge', () => {
mountStream()
setSessionCompacting(OTHER_SID, true)
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.ts
index 330fe017acd..27ca3e5b9ed 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.ts
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.ts
@@ -37,10 +37,15 @@ export function handleStatusEvent(ctx: GatewayEventContext): boolean {
} = deps
if (event.type === 'status.update') {
- if (sessionId && payload?.kind === 'compacting') {
+ // `compacting`/`compacted` is auto-compaction's pair. Manual /compress
+ // pins `compressing` and always clears it with `ready` (the `finally` in
+ // methods_session._compress_live). Both spellings drive the same phase —
+ // the TUI has matched the pair since createGatewayEventHandler.ts:904;
+ // without `compressing` the desktop showed no progress for /compress.
+ if (sessionId && (payload?.kind === 'compacting' || payload?.kind === 'compressing')) {
setSessionCompacting(sessionId, true)
compactedTurnRef.current.add(sessionId)
- } else if (sessionId && payload?.kind === 'compacted') {
+ } else if (sessionId && (payload?.kind === 'compacted' || payload?.kind === 'ready')) {
reconcileSessionCompacting(sessionId, 'terminal')
compactedTurnRef.current.delete(sessionId)