Skip to content

fix(web): expand each side of a steer's fold on its own - #13

Merged
orbitingflea merged 1 commit into
mainfrom
fix/fold-expand-per-segment
Sep 2, 2026
Merged

orbitingflea merged 1 commit into
mainfrom
fix/fold-expand-per-segment

Conversation

@orbitingflea

Copy link
Copy Markdown
Owner

What changed

A steer is a message you send while the agent is still working on your previous one. As of #10, a steer splits the agent's turn into two "Worked for …" folds, one above the steer and one below. Clicking either fold opened and closed both. Now each fold opens and closes on its own.

The folds moved together because the timeline tracked expanded folds by turn id, and both halves of a steered turn share one turn id. Each fold now carries its own expand key, and the timeline tracks those keys instead. A fold's key is the id of the first entry that fold hides, so no two folds share a key.

The one exception is the fold that Stop cut short. It keeps the turn id as its key, because when you press Stop the timeline expands that fold and the only thing it knows at that point is which turn you stopped. That behaviour is unchanged.

This change is web only. Mobile folds per turn and has no steer split, so there is nothing to change there. Expanded state is local to the page, as before.

Screenshots

Same script as #12, run against two Docker containers built from production bundles. The before container runs main at fa64403; the after container runs this branch on top of it. Message A asks the agent to run a 25s command and then reply "done". Message B, sent while that command is still running, asks for another 25s command and then the reply "pong". Once the turn settles, the script clicks the first "Worked for" fold once.

Provider Before (main) After (this PR)
Claude Sonnet 5 one click opens both folds one click opens the first fold only
Codex gpt-5.6-luna one click opens both folds one click opens the first fold only

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes (not applicable)

Written by Claude Fable 5.1 running in Claude Code, driven from T3 Code.

A steer splits the agent's turn into a fold above the user message and a
fold below it. Clicking either one opened and closed both, because the
timeline kept the set of expanded folds by turn id and both halves of a
steered turn share one turn id.

Each fold now carries its own expand key: normally the id of the first
entry it hides, so the two halves of a steered turn expand on their own.
Only the fold that an interrupt cut short keys by its turn id, because on
Stop the timeline expands that fold knowing only which turn was stopped.

Written by Claude Fable 5.1 running in Claude Code, driven from T3 Code.
Copilot AI lite review requested due to automatic review settings September 2, 2026 22:48

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 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-09-02T22:56:43.653922Z e16e767 PR opened
ℹ️ 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.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M labels Sep 2, 2026

@orbitingflea orbitingflea left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

逐处中文说明(每个改动位置一条)。

id: string;
createdAt: string;
turnId: TurnId;
expandKey: string;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

折叠行不再暴露 turnId,改为暴露 expandKey:它就是“展开集合”里对应这一行的那个键。组件点击时原样传回,不需要知道它是 turn id 还是 entry id。

Comment on lines +341 to +346
/**
* What the expanded-folds set holds for this fold. Normally the anchor
* entry id, so each side of a steer expands on its own; the fold that an
* interrupt cut short keys by its turn id, which is all the interrupt knows.
*/
expandKey: string;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

这里定义了键的取法:默认用折叠里第一条被隐藏的 entry 的 id,所以同一个 turn 被 steer 切成的两段各有各的键。只有被 Stop 打断的那一段仍用 turn id,因为打断时组件只知道 turn id(见组件里的 effect)。

}): ReadonlyMap<string, TurnFold> {
interface Segment {
/** Last turn id in the segment; folds expand per turn id. */
/** Last turn id in the segment. */

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

注释里删掉了“folds expand per turn id”,因为现在展开不再按 turn id。


foldsByAnchorEntryId.set(firstHiddenEntry.id, {
turnId,
expandKey: turn?.state === "interrupted" ? turnId : firstHiddenEntry.id,

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

核心一行。turn 只对“最新 turn 的收尾段”非空(见上面的 latestTurnSegment),所以 turn?.state === "interrupted" 恰好只命中被打断的那一段;其余所有折叠都用锚点 entry id,键稳定且互不相同。

latestTurn?: TimelineLatestTurn | null;
runningTurnId?: TurnId | null;
expandedTurnIds?: ReadonlySet<TurnId>;
expandedFoldKeys?: ReadonlySet<string>;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

入参从 expandedTurnIds(turn id 集合)改成 expandedFoldKeys(键集合),类型放宽到 string,因为键可能是 entry id。

return;
}
setExpandedTurnIds((existing) => {
setExpandedFoldKeys((existing) => {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

下一个 turn 开始时删掉上一个 turn id,同样不变。

latestTurn,
runningTurnId,
expandedTurnIds,
expandedFoldKeys,

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

useMemo 传入和依赖数组同步改名。

aria-expanded={row.expanded}
data-scroll-anchor-ignore
onClick={() => ctx.onToggleTurnFold(row.turnId, row.id)}
onClick={() => ctx.onToggleTurnFold(row.expandKey, row.id)}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

点击折叠行时传回该行自己的 expandKey。

Comment on lines +1481 to +1502

// Each side of the steer expands on its own.
const expandedSide = (keys: ReadonlyArray<string>, latestTurn?: TimelineLatestTurn) =>
deriveMessagesTimelineRows({
...baseFoldInput,
timelineEntries,
...(latestTurn ? { latestTurn } : {}),
expandedFoldKeys: new Set(keys),
})
.filter((row) => row.kind === "turn-fold")
.map((row) => row.kind === "turn-fold" && row.expanded);
expect(expandedSide(["work-1-entry"])).toEqual([true, false]);
expect(expandedSide(["work-2-entry"])).toEqual([false, true]);
// An interrupt knows only the turn id; that expands the side it cut short.
expect(
expandedSide(["turn-1"], {
turnId: "turn-1" as never,
state: "interrupted",
startedAt: "2026-01-01T00:00:00Z",
completedAt: "2026-01-01T00:00:30Z",
}),
).toEqual([false, true]);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

新增断言:steer 前半段用自己的锚点键展开、后半段用自己的锚点键展开,两者互不影响;被打断时用 turn id 能展开被打断的那一段(后半段)。

},
],
expandedTurnIds: new Set(["turn-1" as never]),
expandedFoldKeys: new Set(["assistant-thought-entry"]),

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

这些旧测试原来用 turn id 展开一个已完成 turn 的折叠;现在已完成 turn 的折叠键是锚点 entry id,所以改成对应的 entry id。其余几处(544、556、728、1313、1536、1632、1780 行)同理,只是键值替换。

@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: e16e7676e2

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


foldsByAnchorEntryId.set(firstHiddenEntry.id, {
turnId,
expandKey: turn?.state === "interrupted" ? turnId : firstHiddenEntry.id,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the per-fold expansion key stable across pagination

Using firstHiddenEntry.id makes an expanded fold lose its identity when older history is prepended. mergeOlderPage prepends rows in packages/client-runtime/src/state/threads.ts, and the server explicitly permits a large fan-out group to be split across pages; loading the preceding chunk of that same user-message segment therefore selects an earlier firstHiddenEntry, while expandedFoldKeys still contains the old ID, so the open fold unexpectedly snaps closed. Derive the key from a stable segment boundary or migrate the expansion state when the anchor changes.

Useful? React with 👍 / 👎.

@orbitingflea
orbitingflea merged commit 8662025 into main Sep 2, 2026
6 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants