Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(grok): restore errored:true on StopFailure, and retire the last test pinning the removed branch

Xavi Guardia04f00aed337c
diff --git a/src/server/agent-status.test.ts b/src/server/agent-status.test.ts
index 541ee874b..5e1deb853 100644
--- a/src/server/agent-status.test.ts
+++ b/src/server/agent-status.test.ts
@@ -404,7 +404,7 @@ describe('wireAgentStatus — the grok raw-listener branch', () => {
expect(grokSessionDirFor('gs-4')).toBeUndefined()
})
- it('replaces the old session association when PostCompact mints a new id', () => {
+ it('KEEPS the old session association across compaction — grok does not mint a new id', () => {
const fh = fakeHooks()
const ctx = recTail()
wireAgentStatus(platform, { hooks: fh.hooks as never, contextTail: ctx.tail as never })
@@ -420,7 +420,12 @@ describe('wireAgentStatus — the grok raw-listener branch', () => {
sessionId: 'gs-after',
cwd: '/w/project'
})
- expect(grokSessionDirFor('gs-before')).toBeUndefined()
+ // This used to assert the OPPOSITE, on the belief that grok mints a new session id when it
+ // compacts. Measured on 1.0.13: it does not — `pre_compact` and `post_compact` carry the same
+ // `sessionId`. So the retirement branch could not fire and was removed, and this asserts the
+ // case it existed for: even with a DIFFERENT id, the earlier association survives. Nothing else
+ // retires an id but SessionEnd.
+ expect(grokSessionDirFor('gs-before')).toBe(sessionDir('/w/project', 'gs-before'))
expect(grokSessionDirFor('gs-after')).toBe(sessionDir('/w/project', 'gs-after'))
platform.cast(platform.attach({ sendText: () => {}, sendBinary: () => {} }), IPC.ptyDestroy, [
diff --git a/src/shared/agents/normalize.ts b/src/shared/agents/normalize.ts
index 45e3a14b4..6137717f0 100644
--- a/src/shared/agents/normalize.ts
+++ b/src/shared/agents/normalize.ts
@@ -716,7 +716,13 @@ export function normalizeGrok(env: RawHookEnvelope): NormalizedAgentEvent | null
// a set nothing reads is the same dead weight the PostCompact branch was. The day one of them
// earns a distinct badge, that is where the set comes back — and it must still fall through to
// `done`, never to null.
- if (ev === 'stopfailure') return { ...base, kind: 'state', state: 'done', lastMessage }
+ // `errored: true` is NOT decoration: `erroredTurn.ts` is the one definition of "this turn died",
+ // shared by every agent and by both shells, and dropping it here made grok the only agent whose
+ // failed turn looked like a clean one. It went missing when this branch's version of the return
+ // was taken over upstream's without diffing what upstream had — the same "believe the side you
+ // are holding" that the rest of this comment is about.
+ if (ev === 'stopfailure')
+ return { ...base, kind: 'state', state: 'done', errored: true, lastMessage }
if (ev === 'permissiondenied') return { ...base, kind: 'state', state: 'working' }
if (ev === 'stopcancelled') {
const cancelReason = GROK_CANCEL_REASONS[grokCanonical(p.reason)]