Skip to content

fix(claude-code-style): a coding task's result card shows the run's answer, not its JSON (FIX-2301) - #4127

Merged
jhoffner merged 9 commits into
mainfrom
claude/project-thread-k0bw6h
Oct 30, 2026
Merged

jhoffner merged 9 commits into
mainfrom
claude/project-thread-k0bw6h

Conversation

@jhoffner

Copy link
Copy Markdown
Collaborator

Problem

When a coding task finishes in the Claude Code-style lab, its Background result card in the main thread shows the run's whole output as raw JSON, for example {"issue":…,"answer":"Appended the line…","branch":"conductor/…","commits":1,"judged":true,"review":"accepted"}. The long branch name also runs past the edge of the card. Session mode and threads mode both draw the card this way. The threads-mode thread spotted it while taking the FIX-2289 screenshots.

Fix

The task notice line carries the output as text, and orchestration cuts that text short past a limit.

  • src/lib/result-summary.ts: when the summary is JSON with a string answer, the card shows the answer. It finds the answer even when the notice has cut the JSON short after it. Any other output shows unchanged.
  • The adapter's result entry runs its summary through this function.
  • The result card wraps long words, so a branch name or a URL stays inside the card.

Nothing changes in the packages; the fix stays in the lab's adapter and UI.

Verification

  • test/result-summary.test.ts, four tests:
    • shows the answer instead of the JSON
    • shows the answer from JSON that was cut short and won't parse
    • keeps escapes in the answer
    • leaves prose, and JSON without an answer, unchanged
  • Negative control: with the function returning its input unchanged, 3 of the 4 tests fail.
  • Lab: 53/53 tests pass, typecheck is clean, and the inventory passes.

No changeset: the lab is private.


Generated by Claude Code

…nswer, not its JSON (FIX-2301)

The task notice carries a coding run's output as JSON text. The card now
shows its answer, read even when the notice cut the JSON short, and wraps
long words so a branch name stays inside the card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiH4u1zR9xGAacFBGbb
@jhoffner jhoffner self-assigned this Oct 28, 2026
@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 30, 2026 12:10am UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 30, 2026 12:10am UTC
flow-state-dev-ui Ignored Ignored Preview Oct 30, 2026 12:10am UTC

Request Review

@linear-code

linear-code Bot commented Oct 28, 2026

Copy link
Copy Markdown

FIX-2301

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T00:11:03.926149Z bf77055 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Collaborator Author

Second look + architecture pass (read-only; for the follow-up agent to triage)

The fix is small and in the right place for what it sets out to do (lab adapter + UI only, private package, no changeset needed, negative control reported). I found one correctness gap worth fixing and one design note. No refactor opportunity beyond that.

1. Gap: an answer longer than ~500 chars falls back to raw JSON (worth fixing in this PR)

SUMMARY_LIMIT = 500 (packages/orchestration/src/tasks/notice/task-notice.ts:606) cuts the notice text mid-JSON. The PR handles "cut after the answer", but when the answer string itself is cut, ANSWER needs a closing quote, so it doesn't match and resultSummary returns the raw JSON — the exact bug this PR fixes, just for the longer-answer case. Coding-run answers are prose summaries, so this will happen. answer is typically the first key, so the visible JSON is mostly the answer.
Suggest: also accept an unterminated string ("answer"\s*:\s*"((?:[^"\\]|\\.)*) up to end of input), decode the escapes with a guarded JSON.parse of the closed-up string (drop a dangling \), and keep the trailing …. Add a test for the cut-inside-the-answer case; today's "cut short" test slices at 80 chars, which happens to land after the answer closes, so it doesn't cover this.

2. Regex isn't anchored to the top-level key

ANSWER.exec(trimmed) matches the first "answer":"…" anywhere in the text. A non-coding task whose JSON nests one ({"rows":[{"answer":"x"}]}, or a string value that contains "answer":"…") would be collapsed to that nested value. The test "JSON with no answer" only covers {"rows":3}. Low likelihood, but cheap to tighten: require the match to be at the top level (e.g. try JSON.parse(trimmed) first and read .answer; use the regex only as the fallback for truncated text, anchored as ^\{\s*(?:"[^"]+"\s*:[^,]*,\s*)*"answer" or simply restricted to the object's first key since the run output puts issue/answer first).

3. Design note (no change requested): parsing display text vs. reading the output

The adapter is reverse-engineering structured data from noticeText, which already has a fixed-limit lossy summary and is itself parsed by RESULT_LINE. That's how the adapter reads results everywhere else in this file, so I'm not asking to change it here (CLAUDE.md: match the codebase's conventions). Flagging it only as debt: if more result shaping accumulates here, the better home is a typed field on the notice/task output rather than a second regex layer over truncated text. Not worth a package change for this fix.

4. Minor

  • README inventory table update is fine/expected from the inventory check.
  • [overflow-wrap:anywhere] + min-w-0 is the right wrap fix; no concern.
  • The text.length > 0 guard silently falls back to the JSON for "answer":""; fine, just noting it's intentional.

Verdict: fix item 1 (and ideally 2) before merge; everything else is fine as is.


Generated by Claude Code

…-k0bw6h

# Conflicts:
#	labs/claude-code-style/README.md
#	labs/claude-code-style/src/adapter.ts
…g enough on a busy runner

At the fastest fake-lab speed the first turn could end before the second
line landed on CI, so the line never showed as queued.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiH4u1zR9xGAacFBGbb
@jhoffner

Copy link
Copy Markdown
Collaborator Author

@claude resolve conflicts

…-k0bw6h

# Conflicts:
#	labs/claude-code-style/README.md
#	labs/claude-code-style/src/adapter.ts
#	labs/claude-code-style/test/screen.test.tsx

Copy link
Copy Markdown
Collaborator Author

I merged main in and resolved the conflicts (877f68b).

  • src/adapter.ts: kept both imports, main's new-project and this PR's result-summary.
  • test/screen.test.tsx: took main's version. Main already slowed the queued-line test, which covers what this PR's change to it did.
  • Lab README.md: main's copy had lost its inventory table markers, so the lab's inventory test fails on main as well. This PR restores the block and regenerates it.

The lab's tests pass 62/62 and typecheck is clean.


Generated by Claude Code

… main dropped the table

Jake removed the lab README's code-stats table on purpose, and #4176 did
the same for the Teammates lab's inventory. The file-kind and flow-size
checks stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiH4u1zR9xGAacFBGbb

Copy link
Copy Markdown
Collaborator Author

Correction to my last comment: the lab README's table was removed on purpose in #4198, not lost by accident. In 3f88be0 I put the README back to main's version and dropped the README table check from the lab's inventory script, matching what #4176 did for the Teammates lab:

  • The README table check, --write, and the inventory:write script are removed.
  • The file-kind and flow-size checks stay.

Lab tests pass 62/62, typecheck is clean, and the inventory check still passes.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f88be03eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…wer (FIX-2301)

A nested answer, such as one row's in a research result, no longer stands
in for the whole output, whether the JSON is complete or cut short.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiH4u1zR9xGAacFBGbb
jhoffner pushed a commit that referenced this pull request Oct 30, 2026
README stats tables are being removed on purpose; main's fix is #4127,
which drops the lab's table check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGmKnjZ6ePhvHf7KQh
jhoffner pushed a commit that referenced this pull request Oct 30, 2026
README stats tables are being removed on purpose; #4127 fixes main's
red inventory check by dropping the table check instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiD2NbgJTWT3D3ABjSA
jhoffner pushed a commit that referenced this pull request Oct 30, 2026
Jake is removing README stats tables on purpose; #4127 fixes main by
dropping the claude-code-style lab's table check instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGPxx9RA1XY7n7yd4v
jhoffner pushed a commit that referenced this pull request Oct 30, 2026
README stats tables are removed on purpose; #4127 fixes main by dropping
the lab's table check instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFsTymVutTnxtzVCSQ
jhoffner pushed a commit that referenced this pull request Oct 30, 2026
The README stats tables were removed on purpose; #4127 fixes main by
dropping the lab's table check instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiHKUc1cT214v6KRkYo
jhoffner pushed a commit that referenced this pull request Oct 30, 2026
The README file stats were removed on purpose; #4127 drops the lab's
table check instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGLaZPyJtz9dyX3YFd
jhoffner pushed a commit that referenced this pull request Oct 30, 2026
…eck instead

The README's file stats were removed on purpose. Main's claude-code-style
inventory test still checks for them; #4127 drops that check, and this
ports its inventory half (script, package.json, test name) so this PR's
CI is green. It no-ops once #4127 merges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiCe9dURdi162DtKRcA
@jhoffner
jhoffner merged commit 4a30fdb into main Oct 30, 2026
19 checks passed
@jhoffner
jhoffner deleted the claude/project-thread-k0bw6h branch October 30, 2026 01:46
jhoffner added a commit that referenced this pull request Oct 30, 2026
…ates lab) (#4230)

* FIX-2345: a finished task comes back as one line that opens it

In the Teammates lab, a task the conversation filed comes back as one
collapsed line, "researcher finished: <title>" (or "couldn't finish"),
that opens the task's popup with its whole result. The filer's own
reply stays expanded under it. A routed answer, which names no task,
still shows as said. The lab half of FIX-2345; the delivery half is
the workforce fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiCsRqCenZsFQRpJBHi

* chore: restore the Claude Code-style lab's inventory table

#4198's merge dropped the README's inventory block, so the lab's
inventory test is red on main and on every PR. Restored the markers and
regenerated with node scripts/inventory.mjs --write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGmKnjZ6ePhvHf7KQh

* Revert "chore: restore the Claude Code-style lab's inventory table"

README stats tables are being removed on purpose; main's fix is #4127,
which drops the lab's table check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGmKnjZ6ePhvHf7KQh

---------

Co-authored-by: Claude <noreply@anthropic.com>
jhoffner added a commit that referenced this pull request Oct 30, 2026
…4229)

* FIX-2346: conversations open at their end, with no scroll to watch

Every app opened or switched to a conversation by scrolling visibly from
the top down to the end. Each had its own scroll code, so the rule now
lives once in @flow-state-dev/react as useFollowLatest: a feed that opens
(mount, a resetKey change, or its first read filling it) lands at the end
before paint; content arriving live while the reader is at the end glides;
a reader who scrolled up is never pulled down.

- DevTool stream view, Shift Manager (conversation + task session), the
  Teammates lab (conversation + session popup) and the Claude Code-style
  lab (main thread, thread view, task sheet) use it. Shift Manager's
  lib/follow.ts and the Teammates lab's stick-to-bottom.ts are gone; their
  tests move to the hook.
- The ui registry's ScrollOnNewRequest (and the kitchen-sink copy) lands a
  first load or session switch instantly, before paint; only a request
  that follows one on screen scrolls smoothly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiHKUc1cT214v6KRkYo

* FIX-2346: drop an unused import from useFollowLatest

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiHKUc1cT214v6KRkYo

* chore: restore the Claude Code-style lab's inventory table

#4198 dropped the README's inventory markers, so the lab's inventory test
is red on main and on every PR. Markers restored and the table
regenerated with node scripts/inventory.mjs --write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiHKUc1cT214v6KRkYo

* Revert "chore: restore the Claude Code-style lab's inventory table"

The README stats tables were removed on purpose; #4127 fixes main by
dropping the lab's table check instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiHKUc1cT214v6KRkYo

---------

Co-authored-by: Claude <noreply@anthropic.com>
jhoffner added a commit that referenced this pull request Oct 30, 2026
)

* FIX-2286: a flow's reads, so watching a task board stores nothing

A flow can declare `reads`: blocks an app runs on a session and gets the
answer back from, stored nowhere. The engine serves them at
POST /:flowKind/:sessionId/reads/:readName on a read-only store overlay
(own request id in scratch; every other write refused with read_only),
after the action route's principal and session checks.

The client gains flow(kind).read(); orchestration gains taskToolReads;
Workforce's conversation board serves listTasks_tasks as a read that
skips the board's touch and pass (D2). Shift Manager's TasksPanel and
the Claude Code-style lab poll through it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGLaZPyJtz9dyX3YFd

* FIX-2286: use the current task tool name in the reads example

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGLaZPyJtz9dyX3YFd

* FIX-2286: a read works on a session no action has run in

Session creation stores no user or org record; the first run seeds
them. The read overlay refused that seed, so a read on a fresh session
answered 409 read_only. The first seed of a record the store doesn't
hold now lands in the read's scratch store and is dropped with it;
every other write, including one to the seeded record, still refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGLaZPyJtz9dyX3YFd

* FIX-2286: React's fake client gets read(); restore the lab inventory

The React test fake implements FlowHandle, which now has read(), so
the react typecheck failed. Separately, #4198 cut the inventory block
off the Claude Code-style lab README, failing its inventory test on
main and every PR; the block is restored and regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGLaZPyJtz9dyX3YFd

* FIX-2286: a read runs its request-end hooks when it ends

A read's context carries a request-end registry, so a block could add
a hook that never ran, leaving the registry owed forever: shutdown
waited on it and repeated polling grew the process-global map. runRead
now runs the registry on its way out (completed, or failed with the
error), which releases it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGLaZPyJtz9dyX3YFd

* FIX-2286: a read drains its side chains before it ends

A sequencer's .sideChain() work can outlive executeBlock, so a hook it
added after the read's step answered never ran and stayed owed. runRead
now drains the request's side-chain pool before running the request-end
registry, as every runAction ending does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGLaZPyJtz9dyX3YFd

* FIX-2286: take the lab README inventory back out

The README file stats were removed on purpose; #4127 drops the lab's
table check instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGLaZPyJtz9dyX3YFd

* FIX-2286: keep the lab README's ending as on main

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiGLaZPyJtz9dyX3YFd

---------

Co-authored-by: Claude <noreply@anthropic.com>
jhoffner added a commit that referenced this pull request Oct 30, 2026
…d, not a cut-off user turn (#4231)

* FIX-2345: a finished task's result reaches its filer as a getTask read

A turn a task's ending woke got orchestration's noticeText as its message: a
user-role turn, its output summary cut at 500 characters. The Teammates lab's
Chief of Staff read it as something the user pasted, and worked from the cut
text.

The woken turn, and an answer again about tasks that finished mid-turn
(FIX-2159), now read each ending as a getTask call and its result for that
task, the row in full (orchestration's readTaskView, lifted out of getTask so
both show one read). The visible line under the delegate's name is unchanged.
Routed resultTo: "conversation" tasks and waited-on rows keep their paths.

Amends FIX-1794 BR-22 / S7 and FIX-2078's notice handling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiCgGN8nZAYkhZm1pi8

* chore: restore the Claude Code-style lab's inventory table

The merge of #4198 dropped the README's inventory block, so the lab's
inventory test is red on main and on every PR. Restored and regenerated
with node scripts/inventory.mjs --write. A no-op once main carries it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFsTymVutTnxtzVCSQ

* Revert the Claude Code-style lab's inventory table restore

README stats tables are removed on purpose; #4127 fixes main by dropping
the lab's table check instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiFsTymVutTnxtzVCSQ

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants