Skip to content

feat(session-ui): flat execute layout and script diffs behind full_codemode - #66509

Merged
jlongster merged 14 commits into
devfrom
codemode-captured-stories
Nov 26, 2026
Merged

jlongster merged 14 commits into
devfrom
codemode-captured-stories

Conversation

@jlongster

Copy link
Copy Markdown
Contributor

Issue for this PR

No issue. Builds on #66469 (GET /api/experimental/flag).

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Puts a new Code Mode (execute) block layout behind the server's full_codemode flag, read in session-ui with useData().flag("full_codemode") (from #66469). Applies to both timelines (timeline and timeline-next).

full_codemode on

  • "Execute" is a static, muted title: not collapsible, no last-call subtitle.
  • Steps are listed flat under it, without chevrons, aligned with the title. Step names use the UI font, arguments stay muted monospace, and the error icon sits after the name.
  • Order is steps → diff cards → Output. When a script's changes are drawn right after it (Detailed, or Compact with the group open), the Output row moves below the last card. Otherwise it stays under the steps. This is scriptOutputLayout in timeline/script-output.ts.

full_codemode off

  • The execute block looks as it does on dev.
  • A script's diffs are hidden: no cards, and they don't count toward edit totals or group headers ("Edited N files"). This is gated where the facts are built (factsOf / placeFactOf / placeFacts), with the flag passed in from the app's timeline controller and SessionTimeline. Direct edit/write/patch calls are unaffected.

Ungated: blocks are spaced equally in both timelines (16px in the old timeline, 20px in the new one, measured box to box), with tight spacing inside a block. In the old timeline, title rows keep their 28px click area but take only their text height (6px padding taken back by margins, as the new timeline already does).

Story: adds "Code Mode / Captured states" (packages/session-ui/src/timeline-next/stories/codemode-captured.stories.tsx). It renders real captured Code Mode sessions (drive runs against the real core and server) through the real timelines, with a scenario picker, a state stepper with Play, old/new/side-by-side timelines, detail presets, and a full_codemode toggle. The fixtures in packages/session-ui/src/storybook/codemode-snapshots/ are about 144 KB of JSON (15 scenarios, 4–63 KB each, paths rewritten to /repo, the one 300 KB script literal replaced by the expression that builds it).

The branch history includes an "unwrap execute" prototype commit and the commit that removes it; together they make no change.

How did you verify your code works?

  • tsc -b in packages/session-ui and packages/app.
  • bun test src/timeline/ src/timeline-next/ src/tools/ in session-ui, plain and with --conditions=browser, including the reactivity tests. New tests: script-output.test.ts (Output moves only in the flat layout) and a facts test (with the flag off, a script's changes produce no file facts or counts; direct edits still do).
  • Component specs: session-tool-projection, session-lifecycle, tool-disclosure, session-timeline (43 pass). session-timeline.spec.ts is updated for the equal spacing.
  • Measured block gaps across the captured interleaved scenario in both timelines at Compact (groups open) and Detailed: every adjacent pair is equal.
  • Compared flag off against dev (story files copied onto an origin/dev worktree). The DOM matches; the only visual difference is the spacing.

Screenshots / recordings

Compact, every summary group open, old | new timeline (interleaved, final state)

Before (dev)

After, full_codemode off

After, full_codemode on

One execute block, Detailed (edits-patch)

flag off flag on
Old timeline
New timeline

Compact, flag off, groups closed: group headers don't count script changes ("Ran 3 commands" rather than "Edited 7 files · 3 commands").

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I couldn't check the UI visually, but I found nothing that would block a merge. The unit tests and type checks pass, and reading the code matches the description.

  • Tests: in packages/session-ui, bun test src/timeline/ src/timeline-next/ src/tools/ passes 241 tests with 3 skipped, and 244 pass with --conditions=browser.
  • Type checks: tsc -b is clean in packages/session-ui and packages/app.
  • Not run: the Playwright component specs, including the updated session-timeline.spec.ts, because no browsers are installed here. I also didn't open the story, so I'm relying on your screenshots for the visuals.

What I traced in the code:

  • Output placement: the key scriptOutputLayout builds for each change (messageID:partID) matches the id scriptFileFactOf gives that change. A script's changes always draw through ScriptChanges, as their own row or inside a context group, so a moved Output row always has a place to land. The execute renderer gets the part id from the existing props in both timelines.
  • Flag off: gating placeFacts / placeFactOf is enough. activityFacts and contextGroupFacts already drop a script's file facts and count only the changes that were placed, so with the flag off scripts add nothing to "Edited N files", and direct edits still count. The flag is re-read reactively, so turning it on or off updates the timeline.

One behaviour change worth confirming on purpose: without full_codemode, script diffs disappear for everyone, while dev shows them today. The description says this is intended.

Public API: unchanged. The change reads the existing full_codemode flag from #66469 and only touches the internal session-ui and app packages.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new commit is a small CSS fix, and I see no problems with it. It only touches the flat (full_codemode) layout in the new timeline: the execute title now sits as far above its steps as the steps sit from each other (6px). The layout with the flag off doesn't change. I didn't render it, since there are no browsers here. My first review left no open threads, and there are no new concerns. Public API: unchanged.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The new commit only changes CSS, and only for the flat (full_codemode) layout. I see no problems with it. In both timelines, the gap under the execute title now accounts for the difference between the title's and the steps' line heights, so the title's text sits as far above the first step's text as the steps sit from each other. The rules don't apply with the flag off. I didn't render it, since there are no browsers here. No earlier threads are open, and there are no new concerns. Public API: unchanged.

User decisions:
- Add a storybook story that renders captured Code Mode states
User decisions:
- Make the captured-states story match the real app's layout
User decisions:
- Prototype showing a script's inner calls as top-level timeline rows, desktop only
User decisions:
- Drop the unwrap-execute experiment
User decisions:
- Execute is a static title, not collapsible
- Steps listed under it without chevrons, aligned with the title
User decisions:
- Add a captured story with many interleaved execute blocks and thoughts
…pace blocks apart

User decisions:
- Mute the Execute title and Output row
- Step names in the UI font
- More space between blocks, same tight spacing inside a block
User decisions:
- Exactly equal space between top-level blocks
User decisions:
- Execute block order: steps, then diffs, then Output
User decisions:
- Gate the new execute layout on the server's full_codemode flag
- Equal spacing between blocks stays ungated
User decisions:
- Hide a Code Mode block's diffs when full_codemode is off
User decisions:
- New timeline, full_codemode on: the gap below the Execute title matches the gap above Output
…text

User decisions:
- The Execute title's text sits as far above its first call as one call's text sits above the next
@jlongster
jlongster force-pushed the codemode-captured-stories branch from 8671c00 to d26ff26 Compare November 26, 2026 15:49
User decisions:
- Center the View code button on the flat Execute title's line

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This push is a clean rebase onto newer dev (all earlier commits unchanged) plus a 5-line CSS fix, and I see no problems. The fix only applies in the old timeline with full_codemode on: it moves the execute title's "View code" button up so it sits centred on the title text. On the rebased head, the session-ui timeline and tool tests pass and tsc -b reports no errors in session-ui and app. I didn't render it, since there are no browsers here. There are no new concerns. Public API: unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant