Dashboard sessions: switch get_thoughts to structured JSON for the renderer #69
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
The dashboard's session detail pane parses
get_thoughtsoutput by splitting a flat text blob on a regex anchored atThought #\d+ (timestamp):headers. The formatter contract is ambiguous because a thought's own content can structurally match the header pattern, producing spurious splits with no schema-fallback safety net.Source: code review of branch
phase-8/dashboard-ui-pr3-sessionsFile:
crates/cognix-server/assets/sessions.js:22,crates/cognix-server/assets/sessions.js:180,crates/cognix-mcp/src/tools/core.rs(get_thoughtsformatter)Branch:
phase-8/dashboard-ui-pr3-sessionsFailure mode
splitThoughtsTextsplits on/\n\n(?=Thought #\d+ \([^)]*\):\n)/.Thought #7 (foo):— e.g. a chat log, a screenshot transcript, or a thought quoting the formatter's own output — is split into multiple cards with bogus indices/timestamps.parseThoughtCardmatches each fragment's header regex on the bogus part, so the schema-fallback path is not reached; the user sees corrupted but plausible-looking cards.No thoughts have been recorded yet.against the formatter's hard-coded sentinel, with no shared constant and no synchronization test. Either side changing wording silently regresses the empty state into the schema-fallback path.Why deferred from
phase-8/dashboard-ui-pr3-sessionsget_thoughtscontract.list_sessions,get_session) already return JSON envelopes; aligningget_thoughtsis the natural follow-up.Proposed work
get_thoughtsto return a structured payload (e.g.{ thoughts: [{ index, timestamp, content }, ...] }) at least forlevel: 'concise' | 'full'invocationscrates/cognix-server/assets/schema.js(e.g.assertThoughtsListShape) and switchsessions.jsto consume the structured shapeNo thoughts have been recorded yet.empty marker with an explicit empty-list signal in the payloadsplitThoughtsTextandparseThoughtCardfromsessions.jslevel: 'minimal'or stdio-friendly text format if existing non-dashboard consumers rely on it (auditcognix-cliand any agent integrations first)Acceptance
Thought #99 (faux):\nspoofrenders as a single card whose body includes the canary text verbatimschemaFallbackTexte2e/dashboard/dashboard.spec.tscontinue to passget_thoughtscallers outside the dashboard (or, if the contract is changed, all callers updated in the same PR)References
phase-8/dashboard-ui-pr3-sessionssessions.js:22regex content-driven split +sessions.js:180empty-state magic-string couplinglist_sessionsandget_session#70