Skip to content

fix: fold web searches, answer reasoning, and OpenAI narration into working blocks - #30529

Merged
ibetitsmike merged 19 commits into
mainfrom
mike/working-block-answer-work
Oct 12, 2026
Merged

ibetitsmike merged 19 commits into
mainfrom
mike/working-block-answer-work

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Closes CODAGT-1373.

With Collapse assistant steps on, the "Worked for" block counted a row only when its last visible block was a tool call or reasoning. Final answer messages usually also carry the turn's last reasoning and web search, so "Thinking about ..." and "Searched N results" rendered between the block and the answer, and a message ending in search results split the block in two.

An answer message that also did work now joins the block it ends: its reasoning, searches, and narration before its last tool call or search fold into the block, and only the answer renders after it. Each search counts as one step, even without citations or a row of its own, and citations streamed between text deltas no longer split the answer. Turns without tools, searches, or labeled narration render as before; Copy still copies the whole message. With the preference off, text on either side of a web search now renders as separate paragraphs, where main ran a lead-in into the answer when the search found nothing.

Two provider fixes keep the live and saved views in agreement:

  • Anthropic searches that find nothing stay in the saved message (fix(providers/anthropic): keep metadata on web searches with no results fantasy#65). Before, chatd's step sanitizer dropped them on save, and the live block vanished with them.
  • OpenAI narration stays inside the block (feat(providers/openai): capture and replay Responses message phase fantasy#66). OpenAI labels each message as commentary or final answer, but the label was dropped, so narration before a tool call streamed below the live block like an answer, then jumped into the block when the call arrived. fantasy now keeps and replays the label, chatd marks commentary with a new narration field on ChatMessagePart (stream deltas and saved parts), and the client treats labeled narration as work. A turn whose only work is narration gets a block labeled without a step count.

go.mod pins fantasy's coder_2_33 branch at 351055280157, which also carries the media-batch fix main had pinned from an unmerged branch (coder/fantasy#64).

Screenshots

UAT round 5 frames after reload; main and this PR ran on the same test server.

Anthropic, narration and a web search before the answer:

Anthropic answer on main, then this PR collapsed and expanded

OpenAI, reasoning and four searches before the answer (one "Searched" row holds all four):

OpenAI answer on main, then this PR collapsed and expanded

Testing

  • Vitest: workingBlockGrouping.test.ts (grouping, the row split, and every streamed prefix against the saved message for each provider part order, labeled narration included), streamState.test.ts, ConversationTimeline.test.tsx. Each recorded mechanism toggle fails a named test (the one survivor on 769a8aa9c60 gained a test in 11c77eb8832).
  • Go: TestActiveServer_AnthropicKeepsPairedWebSearchBeforePersist (searches with no results survive saving), TestProcessStepStreamLabelsNarration, and TestOpenAIResponsesNarrationKeepsPhase (saved narration and phase replay through the database). fantasy tests cover both provider fixes.
  • Storybook: eleven new stories, including LabeledNarrationFolds and the two WithoutSteps labels.
  • Dogfood UAT through Coder Agents (chat, evidence in the workspace's .mux-uat/round-N/): round 5 on 769a8aa9c60: PASS (Anthropic searches that find nothing through completion, reload, and follow-up replay; OpenAI and the preference-off view as in round 4). Round 6 on 301b9c51bbf: FAIL under its criterion that the preference-off view match main exactly: an Anthropic lead-in before a search that found nothing renders as its own paragraph, where main runs it into the answer ("Go 1.21.The search results"). The split is intended (856c8624992) and kept: the text matches main's character for character, and main already breaks there when the search has citations. Re-assessed from the round's evidence against the corrected criterion: PASS after reload; the live preference-off stream was not captured remotely and was checked with a local render probe. Every OpenAI narration check passed: in six runs no frame showed narration outside the block (main showed it in all six), and follow-ups replayed the phases. Rounds 1, 3, and 4 failed; each defect is fixed or listed below. Since round 6 the branch was rebased onto main and gained one refactor of the step-count span (0c300957a21), covered by Vitest; live UAT has not run on the rebased head.
  • Known limitations: a turn whose only work is an uncited search shows no block (as on main); a block drops for 200 to 450 ms while an unlabeled lead-in streams before its search (seconds on main); saving a step remounts an expanded reasoning row collapsed (as on main); an interrupted narration replays without its label; a block's duration leaves out narration time, since text parts carry no timestamps.

Review record

  • Codex: five findings fixed (90aa50e9f58, 71527c6ac1c with 00f93209730, 236410c613c, 74a56409562, 98ef3b1c35e). Declined: Copy with trailing citations (Copy takes the whole message, as on main) and the live row counting its searches as one (the live label shows no step count). No issues on 769a8aa9c60, 6d516f0b9b0, 301b9c51bbf, or 0c300957a21.
  • Human review: @jakehwll approved 301b9c51bbf and asked for filters instead of the shared index cursor in groupWorkingBlocks; done in 0c300957a21, with a test that a search between two blocks counts once.
  • frontend-review, coder-frontend-review (8 roles, 9 rounds), and test audits: valid findings fixed. Declined: stories for searches that render no row (same header as existing stories), a Vitest for the no-step label (stories cover it), live subagent status in a live answer's work section, splitting the PR. Follow-up: split ChatMessageItem.

Xum opened this PR on behalf of @ibetitsmike.

@linear-code

linear-code Bot commented Oct 8, 2026

Copy link
Copy Markdown

CODAGT-1373

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 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-12T15:28:39.685735Z 0c30095 Manual request
ℹ️ 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.

@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: 6bf0b4dd2b

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

@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: 856c862499

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

@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: 00f9320973

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 236410c613

ℹ️ 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".

@ibetitsmike ibetitsmike changed the title fix(site): fold web search and answer reasoning into working blocks fix: fold web search and answer reasoning into working blocks Oct 9, 2026
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

@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: 769a8aa9c6

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 769a8aa9c6

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 2cb255e976

ℹ️ 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".

@ibetitsmike
ibetitsmike marked this pull request as ready for review October 9, 2026 09:51
@ibetitsmike
ibetitsmike requested a review from a team as a code owner October 9, 2026 09:51
@pr-queue-manager
pr-queue-manager Bot requested a review from jakehwll October 9, 2026 09:52

@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: 2cb255e976

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

@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: 11c77eb883

ℹ️ 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".

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 6d516f0b9b

ℹ️ 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".

@ibetitsmike ibetitsmike changed the title fix: fold web search and answer reasoning into working blocks fix: fold web searches, answer reasoning, and OpenAI narration into working blocks Oct 9, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 301b9c51bb

ℹ️ 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".

…er-row reasoning and web search into working blocks

With Collapse assistant steps on, the final answer row's reasoning and web
search sources rendered after the Worked for block, and rows ending in
sources split blocks. An answer row that did work now joins the block it
ends: its reasoning, tools, and sources fold in, and its answer text renders
right after the block. Web search result groups count as steps. Tool-less
turns keep their reasoning visible.
…ess frontend review of working block answer split

Rename the ChatMessageItem part prop to section with one RowSection type,
inline single-use values, trim comments, use example.com fixture URLs, and
add a story for a tool-less turn whose answer searched the web.
…ation before an answer's web search into its working block

An answer row now splits at its last work step, so text that precedes a provider web search folds with the step instead of rendering after the block as answer text.
…lify working block answer split

Share RowSection with splitRowBlocks via satisfies instead of a widened
return type, drop the off-by-one answerStart offset, tighten comments, and
wait for the streamed answer in the AnswerStreamsAfterBlock story.
…e answer split around working blocks

Assert that an answer's narration, reasoning, and web search stay inside the
collapsed block and render inside it when expanded, that the answer stays
inert while an earlier prompt is edited, and that live answer text streams
outside the block while its reasoning stays mounted.
…tions from splitting a streaming answer

OpenAI's Responses API streams url_citation annotations between the
answer's text deltas, and chatd publishes each one as a live source
part, so a streaming answer arrived as text, sources, text.
splitRowBlocks treated those sources as the answer's last step and
folded the text before them into the working block until the message
persisted. Only the last reasoning or tool call now bounds the answer;
sources still fold, and hidden blocks stay in the work section.

Vitest no longer asserts DOM presence, order, or the inert attribute
(FE1). The copy test checks only the clipboard payload, the split rules
gained pure-function tests, and the story EditingBeforeAnswerWorkFolds
captures the answer dimming itself while an earlier prompt is edited.
…ation before web searches

Text a model writes before a provider-executed web search is narration,
but the parser and the stream builder dropped those calls, so a turn
without reasoning rendered its lead-in after the working block as the
first paragraph of the answer. Both now mark the text before the call,
and the row split treats the mark as the narration boundary.

Searches count as steps by their provider-executed results instead of
their citation groups. In a turn without tools, a live OpenAI block
otherwise vanished when the answer started and came back at the first
citation, and a search without citations counted as no step.

Answer text merges only across citations, never across hidden tools or
file references.
…answer's uncited web search

An answer whose only work was a web search without citations did not join
the block it ends, so the block's step count and duration left the search
out. It now joins, and its empty work section renders nothing inside the
block. A row that shows no work still never starts a block, so a turn
whose only work is such a search renders as before instead of as a block
that expands to nothing.
… sections without visible blocks

The empty work section guard now uses the same visibility rule as block
membership, so a hidden tool in an answer whose only other work was an
uncited search no longer leaves an empty row inside the block.
…e answer story plays at expanding the block

The AnswerStreamsAfterBlock and SearchAnswerStreamsAfterBlock play
functions ended with a findByText wait on the streamed answer, which
turned them into DOM assertions. Play functions only drive state, so
they now reuse expandBlock and leave the rendered answer to Pixel.
An Anthropic web search that found nothing streamed to clients but was
dropped when its step was saved: fantasy attached no metadata to the empty
result, and chatd's step sanitizer removes provider tool results without it.
With working blocks folding web searches, the live block then vanished when
the turn ended.

Pin the coder/fantasy fix that attaches empty metadata, which replays as an
empty result list, and cover the empty case in the persistence test.
coder/fantasy#64 and #65 merged the OpenAI media-batch fix and the
Anthropic empty web search fix into coder_2_33, so the pin no longer
points at unmerged branches. The new commit's source tree is identical
to the previous pin's.
…rches an interrupt commits apart from their row

An interrupted turn commits a web search's call and result as separate
messages that render no row, so the working block's step count missed
the search, and a cited answer after it counted its citations instead.
Count provider results across the block's messages, and count citations
only when no provider result exists.
…ess frontend review of the interrupted search count

Name the live-turn condition, rename the source block counter, and keep
only the interrupt test cases that fail without the fix.
…rches that render no row before a block

A web search step that renders nothing, persisted between the previous
row and a block's first step, was skipped before the block's span, so
the block reported one step too few and started its clock too late.
Count the provider results of hidden messages since the previous row,
and leave the previous row's own results out.
…ess frontend review of the pre-block search count

Drop the cursor comment's clause about adjacent blocks; the span comment
already states which hidden messages a block counts.
OpenAI Responses models label each assistant message as commentary on
their work or as the final answer. fantasy, chatd, and the client
dropped the label, so narration streamed below a live working block as
if it were the answer and folded into the block only when the next tool
call arrived. Follow-up requests also replayed it without the label.

Pin coder/fantasy at 351055280157 (coder/fantasy#66), which keeps the
label on text parts and replays it. chatd marks commentary text with a
new narration field on every stream delta and on saved parts. The
client keeps narration and answer text in separate blocks and treats
narration as work, so it renders inside the working block from its
first delta, and a turn whose only work is narration still gets a
block, labeled without a step count.
Name the merge exception in appendTextBlock and the keep condition in
groupWorkingBlocks so neither guard stacks negations, correct the
narration comment, and drop the provider list from the field doc. Add a
story for a turn whose only work is narration, compare replayed phases
as values, and send empty end metadata in the chatloop test so a nil
check cannot pass it.
…er each working block's span

groupWorkingBlocks walked the parsed entries with one shared index
cursor and mutable accumulators. Each block now filters the entries in
its span, counts provider results with a helper, and maps the span to
timestamps. Spans still start where the previous one ended, and a new
test checks that a search between two blocks counts once.
@ibetitsmike
ibetitsmike force-pushed the mike/working-block-answer-work branch from 301b9c5 to 0c30095 Compare October 12, 2026 15:22
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum requested this review on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 0c300957a2

ℹ️ 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".

@ibetitsmike
ibetitsmike requested a review from jakehwll October 12, 2026 15:36
@ibetitsmike
ibetitsmike merged commit 41f5caa into main Oct 12, 2026
40 checks passed
@ibetitsmike
ibetitsmike deleted the mike/working-block-answer-work branch October 12, 2026 20:53
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants