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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(grok): usar session_summary como título mientras grok aún no ha nombrado la sesión
Xavi Guardia1268d189fbfc
diff --git a/docs/grok-agent.md b/docs/grok-agent.mdindex 09c90ecdc..670e788d3 100644--- a/docs/grok-agent.md+++ b/docs/grok-agent.md@@ -275,7 +275,15 @@ resolve **nothing** there (`GROK_ENCODED_CWD_MAX_BYTES`); a session id must matcThe session **name** (what `/resume` shows and what a node title with `titleAuto` adopts) is read by`core/grok-session.ts` → `pickGrokSessionMeta` over `summary.json`, in preference order-`TITLE_KEYS = ['title', 'generated_title']`, plus `current_model_id` as the model. Reads are capped+`TITLE_KEYS = ['title', 'generated_title', 'session_summary']`, plus `current_model_id` as the model.+`generated_title` is the real key (`/rename` rewrites it in place). `session_summary` is accepted+only as a fallback, and only when it is ≤ 80 characters — the longest observed title in a 49-file+1.0.13 corpus is 49 characters; a longer value is **refused, not truncated**, because this result+is adopted as the node title with no other length cap (header, sidebar, kanban card, window title,+`project.json`). 20 of those 49 files have `session_summary` and no `generated_title` yet (young+sessions); without the fallback they read as nameless. `'title'` stays first as forward+compatibility: it is absent from every real file, costs one failed lookup, and would win the day+grok splits a manual title from a generated one. Reads are cappedat 256 KB and answer `null` — never a throw — for an absent, oversized or unparseable file.Resolution is a **direct open** of the directory a hook told us about: `rememberGrokSessionDir` /`grokSessionDirFor` / `forgetGrokSession` keep a bounded (512-entry, least-recently-seen-evicted)diff --git a/src/core/grok-session.test.ts b/src/core/grok-session.test.tsindex add3bda6e..acc5897b2 100644--- a/src/core/grok-session.test.ts+++ b/src/core/grok-session.test.ts@@ -52,6 +52,42 @@ describe('pickGrokSessionMeta', () => {expect(pickGrokSessionMeta(JSON.stringify({ generated_title: 'auto' }))?.title).toBe('auto')})+ it('falls back to session_summary when grok has not generated a title yet', () => {+ // Measured: 20 of 49 local summary.json files (1.0.13) carry session_summary and no+ // generated_title — young sessions. Those used to read as nameless.+ expect(+ pickGrokSessionMeta(JSON.stringify({ session_summary: 'Release checklist review' }))?.title+ ).toBe('Release checklist review')+ })++ it('prefers generated_title over session_summary', () => {+ expect(+ pickGrokSessionMeta(+ JSON.stringify({ generated_title: 'Plan the release', session_summary: 'Something else' })+ )?.title+ ).toBe('Plan the release')+ })++ it('refuses a session_summary longer than the cap rather than truncating it', () => {+ // The cap exists because pickGrokSessionMeta feeds the node title with no other length+ // bound, so a sentence adopted here reaches the header, the sidebar, the kanban card,+ // the window title and project.json. A truncated sentence is "degrades to something+ // wrong"; null is the node keeping its own name.+ const long = 'x'.repeat(81)+ expect(pickGrokSessionMeta(JSON.stringify({ session_summary: long }))?.title).toBeNull()+ expect(pickGrokSessionMeta(JSON.stringify({ session_summary: 'x'.repeat(80) }))?.title).toBe(+ 'x'.repeat(80)+ )+ })++ it('does not let an over-long session_summary hide a generated title', () => {+ expect(+ pickGrokSessionMeta(+ JSON.stringify({ generated_title: 'Plan the release', session_summary: 'x'.repeat(200) })+ )?.title+ ).toBe('Plan the release')+ })+it('returns a null TITLE (not a null meta) when the session has no name yet', () => {// A session with a model but no title is normal early in its life — the node keeps its own// title and the poll simply finds nothing to adopt.diff --git a/src/core/grok-session.ts b/src/core/grok-session.tsindex 31d7b7fa0..3f438a7f0 100644--- a/src/core/grok-session.ts+++ b/src/core/grok-session.ts@@ -49,19 +49,26 @@ export interface GrokSessionMeta {/*** Title keys in PREFERENCE order.*- * MEASURED (grok 1.0.13, 2026-09-02): there is only ONE key. `/rename <name>` typed into a live- * session rewrites **`generated_title`** in place — the same field the model-generated name uses —- * and no `title` key ever appears in `summary.json`. Grok does not distinguish a manual title from a- * generated one the way claude's `custom-title` / `ai-title` pair does.+ * MEASURED (grok 1.0.13, 2026-09-02): `/rename <name>` typed into a live session rewrites+ * **`generated_title`** in place — the same field the model-generated name uses — and no `title`+ * key ever appears in `summary.json`. Grok does not distinguish a manual title from a generated one+ * the way claude's `custom-title` / `ai-title` pair does.*- * `'title'` was here as an explicitly-marked guess at the manual key, kept first so a real manual- * title would win the moment someone confirmed it. Someone did, and the answer is that the key does- * not exist. It stays in the list ONLY as a harmless forward compatibility: if a future grok ever- * splits the two, a manual title would win immediately. A key that is absent from every file costs- * one failed lookup and can never produce a wrong name — which is why removing it would buy nothing- * and lose that.+ * `'title'` stays first as forward compatibility: a key absent from every file costs one failed+ * lookup and can never produce a wrong name. If a future grok splits the two, a manual title wins.+ *+ * `session_summary` is the fallback for a session too young to have `generated_title` yet. Measured+ * across 49 local summary.json files (1.0.13): 20 of them carry `session_summary` and no+ * `generated_title`; where both exist they are identical in 28 of 29; the longest value in the+ * corpus is 49 characters. It is accepted only under SESSION_SUMMARY_TITLE_MAX: a longer value is+ * **refused, not truncated**, because this result is adopted as the node title with no other length+ * cap on the path (header, sidebar, kanban card, window title, project.json). Null is the node+ * keeping its own name; a truncated sentence is a wrong name.*/-const TITLE_KEYS = ['title', 'generated_title'] as const+const TITLE_KEYS = ['title', 'generated_title', 'session_summary'] as const++/** Longest observed title in the 1.0.13 corpus is 49 characters. 80 is "a title, generously". */+const SESSION_SUMMARY_TITLE_MAX = 80/** Pure: the meta from a summary.json body. null when this is not a summary object at all. */export function pickGrokSessionMeta(summaryJson: string): GrokSessionMeta | null {@@ -76,10 +83,12 @@ export function pickGrokSessionMeta(summaryJson: string): GrokSessionMeta | nulllet title: string | null = nullfor (const k of TITLE_KEYS) {const v = rec[k]- if (typeof v === 'string' && v.trim()) {- title = v.trim()- break- }+ if (typeof v !== 'string') continue+ const trimmed = v.trim()+ if (!trimmed) continue+ if (k === 'session_summary' && trimmed.length > SESSION_SUMMARY_TITLE_MAX) continue+ title = trimmed+ break}const model = typeof rec.current_model_id === 'string' ? rec.current_model_id : nullreturn { title, model }