Skip to content

feat(chat): port t3code chat rendering, composer and settings features - #951

Merged
devswha merged 25 commits into
mainfrom
feat/t3-rendering
Oct 13, 2026
Merged

devswha merged 25 commits into
mainfrom
feat/t3-rendering

Conversation

@devswha

@devswha devswha commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Change

This branch carries two things that were built on top of each other:

  1. The large-file, diff and chat rendering base (the four earlier commits): React 19 with source line navigation, bounded virtualized source previews, a local and remote repository diff viewer, and a virtualized chat history with source search.
  2. Ports from t3code (MIT, revision e82a1ce), adapted to a client that only bridges herdr's pty. Each adaptation is listed under "T3 Code" in THIRD_PARTY_NOTICES.md.

What a user sees from the ports:

  • Chat: day-aware timestamps, smooth live follow, animated work blocks, a full-screen image viewer with copy and save, Markdown and HTML on copy, skill chips, the files a turn edited, the scroll position kept per conversation, a turn minimap, long user messages folded to twelve lines. A work row reads as the agent's own summary or description of the call instead of the tool id.
  • Composer: the card's model group as divider-separated text with a working-folder strip under it, a prompt stash, a notice stack, Compact beside the context ring, a message at the length limit, terminal selections quoted into the draft.
  • Files, diff, palette, sidebar: Changes as a folder tree, file-type glyphs, path copy and a header skeleton in the diff viewer, one diff worker pool, Settings pages, aliases and folder browsing in the palette, a project's favicon in the sidebar.
  • Settings: separate Light and Dark palettes under System, contrast, font smoothing and panel motion, an installed-font picker, interface and code fonts, shortcuts recorded by pressing them.

Not in this PR: the plan card (no real plan-mode transcript to confirm the payload), new-turn anchoring, inline HTML replies, prompt links, a toast stack, a tooltip primitive, the older-turn divider and the haptic cue. The composer strip shows the folder only, not the branch.

HTTP additions: GET /api/workspace/diff/files and GET /api/workspace/diff/file for the repository diff viewer (types in shared/protocol.ts, proxied to a remote PC through MACHINE_PROXY_PATH, gated as read-only). No WS shape changes. server/transcript-records.ts changes only which text a tool call's summary carries.

Toolchain: this PR carries the Vite 8 / TypeScript 7 / bun --bun vite move from #830 by @todor-a (credited in the changelog fragment). It supersedes #830, which should be closed when this merges so the toolchain entry is not folded twice.

Known, left for follow-ups: folding a work block near the end of a conversation moves its header by 6px (10px on a phone); the review's nine notes (stale "today/yesterday" after midnight, unthrottled scroll-position reads, and others).

Validation

Run on macOS (Apple silicon, Bun 1.4.0).

  • bun run typecheck: exit 0, after merging main.
  • bun run test:unit, after merging main: 3277 pass and 5 fail; the one failure the merge caused (server/repo-diff.test.ts, first-cookie confirmation) is fixed in the merge commit and passes. The other four fail on main on this Mac too and were not checked on Linux: three in scripts/check.test.ts (the temp directory makes the socket path longer than 100 characters) and one in server/voice.test.ts (the uploaded file's name).
  • Browser scripts, run before merging main and not again after: chat-virtual-browser-qa, repo-diff-browser-qa, virtual-source-browser-qa and the composer-fit, settings-pages, chat-greeting, font-swap, deep-link, palette-machines, keyboard-viewport and held-rows demo regressions all exit 0. Three of them were changed to follow the new behavior: the fixture server answers /pane/commands, the greeting check reads which surface a touch reaches, and the font-swap check sets its fallback through the interface font setting.
  • Screens looked at in Chromium at 1440x900 and 390x844: the chat features, the composer, dialogs and Settings, and a walk of the whole demo app in dark, light and Korean.
  • src/lib/i18n.test.ts, scripts/changelog-fold.test.ts and scripts/ci-browser.test.ts pass after the merge.

Review follow-up (Linux, this session)

Fixes from a review of the branch, on top of the main merge:

  • File viewer: a large text file whose read hits the deadline shows what arrived as a cut prefix ("Only part of this file is shown") instead of an error; the request and the read share one deadline.
  • Composer: the saved-drafts popover opens toward the inside of the card, so it stays inside the window above 640px.
  • Chat Find: Enter on the find bar's buttons presses them (only the field's Enter steps matches), and Safari's IME commit Enter (keyCode 229) is ignored. Mod+F is Cmd on macOS and Ctrl elsewhere, so macOS Ctrl+F keeps moving the caret.
  • Image viewer: held by ChatView instead of the virtualized row, so it no longer closes when its row leaves the render window; its bars (and the diagram viewer's) clear the safe areas.
  • Smaller: a terminal quote names no line range when only the visible text was read; the highlight worker pool keeps 12 results per cache; smooth follow settles without scrollend on older Safari (a debounced scroll fallback, not exercised by Chromium); the developer-facing openPalette(query) changelog entry is dropped.

Run on Linux (x64, Bun 1.4.3), at b66f80d:

  • bun run check fast: all steps ok (typecheck, build, 3345 unit tests pass, 0 fail).
  • browser-main as CI runs it (ui-regression, ui-contexts-regression, 2 workers): both pass.
  • browser-other as CI runs it (4 workers): 44 pass, 2 failed. file-preview-text-browser-qa expected the stalled body to fail; it now expects the cut prefix and passes. narrow-pane-demo-regression fails the same way on this PC at origin/main (5a4bfb3) and before these fixes (d648276): the font metrics here give 82 columns at 13px; it passed on CI's runner.
  • New browser assertions: the saved-drafts popover's box at 390, 800 and 1280px (composer-fit-demo-regression), and Enter on Previous match / Close search (chat-virtual-browser-qa); both pass.

devswha and others added 10 commits October 13, 2026 02:01
Preserve the verified latest-main integration as the base for large-file, diff and chat rendering work. Includes the Bun/TypeScript 7/Vite 8 build changes from #830 and isolated PWA update regression coverage.

Co-authored-by: Todor Andonov <[email protected]>
…rtcut recording

Ported from t3code: separate Light and Dark palettes under System, a contrast adjustment, font smoothing and panel motion preferences, an installed-font picker, interface and code fonts, and shortcuts recorded by pressing them with a search box.
… project favicons

Ported from t3code: Files -> Changes as a folder tree, file-type glyphs, a path copy button and a header skeleton in the diff viewer, one diff worker pool for the app, workspace-relative paths, Settings pages, aliases and folder browsing in the command palette, and a project's own favicon in the sidebar.
…t and quoting

Ported from t3code: the card's divider-separated model group and the working-folder strip under it, a prompt stash, a notice stack above the card, Compact beside the context ring, a message when the length limit is reached, terminal selections quoted into the draft, and a menu highlight that survives a refresh.
…arrated work rows

Ported from t3code: day-aware timestamps, smooth live follow, animated work blocks, a full-screen image viewer, Markdown and HTML on copy, skill chips, the files a turn edited, a scroll position kept per conversation, a turn minimap and long user messages folded. A work row now reads as the agent's own summary or description of the call.

The chat-virtual, chat-greeting and font-swap browser scripts follow the new command request, the virtualized chat's class and the interface font setting.
…docs

App and pane wiring for the ports, their ko, ja, zh and tr strings, the changelog, DESIGN.md and the T3 Code section of THIRD_PARTY_NOTICES.md.
Changelog entries move to a changelog.d fragment, as main now asks. The repo-diff route test confirms its first paired device, which main's first-cookie confirmation requires.
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 216 files, which is 66 over the limit of 150.

To get a review, reduce the PR to 150 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

⚙️ Run configuration
  • Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a59bdc5d-32b3-4695-be9a-6f712ffbfad1
📥 Commits

Reviewing files that changed from the base of the PR and between 5a4bfb3 and e769fa6.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock, !bun.lock
📒 Files selected for processing (216)
  • AGENTS.md
  • DESIGN.md
  • THIRD_PARTY_NOTICES.md
  • changelog.d/t3code-ports-and-chat-rendering.md
  • package.json
  • patches/@legendapp%[email protected]
  • scripts/AGENTS.md
  • scripts/build-site.ts
  • scripts/build-xterm.ts
  • scripts/chat-fallback-browser-qa.ts
  • scripts/chat-greeting-demo-regression.ts
  • scripts/chat-history-browser-qa.ts
  • scripts/chat-virtual-browser-qa.ts
  • scripts/chat-virtual-fixture.tsx
  • scripts/ci-browser.sh
  • scripts/ci-browser.test.ts
  • scripts/composer-fit-demo-regression.ts
  • scripts/demo-build.ts
  • scripts/file-preview-text-browser-qa.ts
  • scripts/file-viewer-regression.ts
  • scripts/fixed-sleeps.json
  • scripts/font-swap-demo-regression.ts
  • scripts/math-browser-qa.ts
  • scripts/pane-paging-demo-regression.ts
  • scripts/pwa-update-browser-qa.ts
  • scripts/repo-diff-browser-qa.ts
  • scripts/repo-diff-fixture.tsx
  • scripts/ui-regression.ts
  • scripts/virtual-source-browser-qa.ts
  • scripts/virtual-source-fixture.tsx
  • server/api.contract.test.ts
  • server/conversation.test.ts
  • server/device-access.contract.test.ts
  • server/hermes.test.ts
  • server/index.ts
  • server/machine-api.ts
  • server/machine-proxy.test.ts
  • server/repo-diff.test.ts
  • server/repo-diff.ts
  • server/transcript-records.ts
  • shared/protocol.ts
  • site/demo/transport.ts
  • src/AGENTS.md
  • src/App.tsx
  • src/components/AnimatedHeight.css
  • src/components/AnimatedHeight.tsx
  • src/components/ChatFind.css
  • src/components/ChatFind.tsx
  • src/components/ChatMinimap.css
  • src/components/ChatMinimap.tsx
  • src/components/ChatTimeline.css
  • src/components/ChatTimeline.tsx
  • src/components/ChatView.css
  • src/components/ChatView.tsx
  • src/components/CommandPalette.css
  • src/components/CommandPalette.tsx
  • src/components/Composer.css
  • src/components/Composer.tsx
  • src/components/ComposerNotices.css
  • src/components/ComposerNotices.tsx
  • src/components/ComposerStash.css
  • src/components/ComposerStash.tsx
  • src/components/DiffWorkerPool.tsx
  • src/components/DirectoryBrowser.tsx
  • src/components/FileGlyph.tsx
  • src/components/FileViewer.css
  • src/components/FileViewer.tsx
  • src/components/FilesDialog.css
  • src/components/FilesDialog.tsx
  • src/components/HighlightedCode.css
  • src/components/HighlightedCode.tsx
  • src/components/ImageLightbox.css
  • src/components/ImageLightbox.tsx
  • src/components/MachineSidebar.tsx
  • src/components/Markdown.tsx
  • src/components/MermaidLightbox.css
  • src/components/MermaidLightbox.tsx
  • src/components/PaneTerminal.css
  • src/components/PaneTerminal.tsx
  • src/components/PromptCard.css
  • src/components/RepoChanges.css
  • src/components/RepoChanges.tsx
  • src/components/RepoDiff.css
  • src/components/RepoDiff.tsx
  • src/components/RepoDiffViewer.css
  • src/components/RepoDiffViewer.tsx
  • src/components/SettingsDialog.css
  • src/components/SettingsDialog.tsx
  • src/components/Sidebar.css
  • src/components/Sidebar.tsx
  • src/components/Skeleton.css
  • src/components/Skeleton.tsx
  • src/components/TextFileView.tsx
  • src/components/TurnChangedFiles.css
  • src/components/TurnChangedFiles.tsx
  • src/components/VirtualSource.css
  • src/components/VirtualSource.tsx
  • src/components/WorkspaceFavicon.tsx
  • src/lib/actions.ts
  • src/lib/animatedHeight.test.ts
  • src/lib/animatedHeight.ts
  • src/lib/api.ts
  • src/lib/appearanceRendering.test.ts
  • src/lib/appearanceRendering.ts
  • src/lib/changeTree.test.ts
  • src/lib/changeTree.ts
  • src/lib/chatMinimap.test.ts
  • src/lib/chatMinimap.ts
  • src/lib/chatRowState.tsx
  • src/lib/chatRows.test.ts
  • src/lib/chatRows.ts
  • src/lib/chatScrollMemory.test.ts
  • src/lib/chatScrollMemory.ts
  • src/lib/chatSearch.test.ts
  • src/lib/chatSearch.ts
  • src/lib/chatTimestamp.test.ts
  • src/lib/chatTimestamp.ts
  • src/lib/clipboard.ts
  • src/lib/compactContext.test.ts
  • src/lib/compactContext.ts
  • src/lib/composerImageMime.test.ts
  • src/lib/composerImageMime.ts
  • src/lib/composerLabelFit.test.ts
  • src/lib/composerLabelFit.ts
  • src/lib/composerLength.test.ts
  • src/lib/composerLength.ts
  • src/lib/composerMenuHighlight.test.ts
  • src/lib/composerMenuHighlight.ts
  • src/lib/composerNotices.test.ts
  • src/lib/composerNotices.ts
  • src/lib/composerStrip.test.ts
  • src/lib/composerStrip.ts
  • src/lib/contrast.test.ts
  • src/lib/contrast.ts
  • src/lib/fileIcons.test.ts
  • src/lib/fileIcons.ts
  • src/lib/filePaths.test.ts
  • src/lib/filePaths.ts
  • src/lib/filePreviewText.test.ts
  • src/lib/filePreviewText.ts
  • src/lib/followScroll.test.ts
  • src/lib/followScroll.ts
  • src/lib/fontFamily.ts
  • src/lib/i18n.ja.ts
  • src/lib/i18n.ko.ts
  • src/lib/i18n.tr.ts
  • src/lib/i18n.zh.ts
  • src/lib/idleLease.test.ts
  • src/lib/idleLease.ts
  • src/lib/imageBox.test.ts
  • src/lib/imageBox.ts
  • src/lib/imageViewer.test.ts
  • src/lib/imageViewer.ts
  • src/lib/installedFonts.test.ts
  • src/lib/installedFonts.ts
  • src/lib/machineContext.tsx
  • src/lib/markdown.test.ts
  • src/lib/markdown.ts
  • src/lib/markdownClipboard.test.ts
  • src/lib/markdownClipboard.ts
  • src/lib/paletteFolders.test.ts
  • src/lib/paletteFolders.ts
  • src/lib/paletteFor.test.ts
  • src/lib/paletteFor.ts
  • src/lib/paletteSeed.test.ts
  • src/lib/paletteSeed.ts
  • src/lib/paletteSettings.test.ts
  • src/lib/paletteSettings.ts
  • src/lib/paneCommandCache.ts
  • src/lib/projectFavicon.test.ts
  • src/lib/projectFavicon.ts
  • src/lib/promptStash.test.ts
  • src/lib/promptStash.ts
  • src/lib/repoDiff.test.ts
  • src/lib/repoDiff.ts
  • src/lib/settings.ts
  • src/lib/shortcutRecorder.test.ts
  • src/lib/shortcutRecorder.ts
  • src/lib/shortcuts.ts
  • src/lib/skeleton.test.ts
  • src/lib/skeleton.ts
  • src/lib/skillMentions.test.ts
  • src/lib/skillMentions.ts
  • src/lib/sourcePreview.test.ts
  • src/lib/sourcePreview.ts
  • src/lib/sourceTheme.ts
  • src/lib/terminalFileLinks.test.ts
  • src/lib/terminalFileLinks.ts
  • src/lib/terminalQuote.test.ts
  • src/lib/terminalQuote.ts
  • src/lib/textPreview.test.ts
  • src/lib/textPreview.ts
  • src/lib/toolVerbs.test.ts
  • src/lib/toolVerbs.ts
  • src/lib/turnChangedFiles.test.ts
  • src/lib/turnChangedFiles.ts
  • src/lib/typography.test.ts
  • src/lib/typography.ts
  • src/lib/useRepoDiffViewer.ts
  • src/lib/useSkillMatcher.ts
  • src/lib/useTabReorder.ts
  • src/lib/userMessageFold.test.ts
  • src/lib/userMessageFold.ts
  • src/lib/viewport.ts
  • src/lib/viewportResume.test.ts
  • src/lib/viewportResume.ts
  • src/lib/workFoldHeight.test.ts
  • src/lib/workFoldHeight.ts
  • src/lib/workRowLabel.test.ts
  • src/lib/workRowLabel.ts
  • src/lib/workspacePath.test.ts
  • src/lib/workspacePath.ts
  • src/styles.css
  • tsconfig.json
  • tsconfig.tools.json
  • vite.config.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

devswha and others added 11 commits October 13, 2026 20:12
Brings in the repo-wide convention guards (#949).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
DESIGN.md's type scale and timing tables now state the src/styles.css
values verbatim (calc(N * var(--ui-scale)) and calc(N * var(--motion-scale)))
and say which Settings write those factors. Drop the
chat-history-browser-qa.ts fixed-sleep baseline, since this branch
removed that sleep.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…browser scripts for the t3 layout

- PromptCard.css: the composer's folder strip comes out of the prompt card's
  60% budget, so the transcript keeps two lines at 800x600 again.
- ui-regression: check the new controls-row order (model group, actions,
  round button) parted by the card's column gap.
- chat-fallback-browser-qa, math-browser-qa: stub /api/pane/commands, which
  the chat's skill matcher now asks for.
- file-viewer-regression: leave the sidebar's favicon probes out of the
  link's file requests.
- virtual-source-browser-qa: select and copy again when the virtualizer
  rebuilt the selected rows under the selection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tform Mod key

A virtualized row unmounts once it leaves the render window, so a viewer it
owned closed itself while the transcript followed new output. On macOS the
Find shortcut also took Ctrl+F from the composer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- a terminal quote names no line range when only the visible text was read
- the highlight worker pool keeps 12 results per cache, not 100
- smooth follow settles without scrollend on older Safari
- drop the developer-facing openPalette changelog entry

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A preview cut by the deadline holds less than the byte budget, so it must not
claim the budget's size as shown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
devswha added a commit that referenced this pull request Oct 13, 2026
Follow-up to #951.

## Problem
Chat turn times are day-aware ("11:59 PM" today, "yesterday at 11:59
PM", a date for older turns), but the label never updated after local
midnight: a turn shown with today's time kept that label on the next day
until the chat was reopened or the turn changed.

## Root cause
`TurnTime` in `src/components/ChatView.tsx` called
`formatChatTimestamp(ts, Date.now(), ...)` during render. Nothing
schedules a re-render at the day change, and `Turn` is memoized (a turn
that did not change keeps its object across polls), so the label
computed at the last render stayed.

## Change
- New `src/lib/localDay.ts`: `localDayKey` (start of the local day),
`msUntilNextLocalMidnight` (calendar-based, so DST days are right), and
`createDayStore`, a shared store with one timer to the next local
midnight while anything listens and none otherwise. The snapshot is read
from the clock each time, and the store re-checks when the page is shown
or focused again, because a sleeping device's timer clock can stop. A
timer that fires early re-arms instead of announcing the day.
- `useLocalDay()` exposes it via `useSyncExternalStore`. `TurnTime`
formats against the day key, so only the `<time>` elements re-render,
and only when the day changes; the memoized turns do not.
- `changelog.d/turn-time-midnight.md` (Fixed).

## Validation
- `src/lib/localDay.test.ts` (fake clock with injected timers): day key
and wait to midnight; listeners notified once at midnight and not
before, then again the next midnight; one shared timer and resume
listener for 50 subscribers, none after they leave; early timer re-arms;
waking past midnight after the timer slept notifies once and the stale
timer is replaced; a turn at 23:59 reads "11:59 PM" and then "yesterday
at 11:59 PM" after midnight.
- `bun run check fast`: all ok (3462 unit tests pass).
- `scripts/chat-history-browser-qa.ts` and
`scripts/chat-virtual-browser-qa.ts` pass. `scripts/chat-browser-qa.ts`
fails at the composer layout assertion ("the message on top, one row of
controls under it, one round button"), and it fails the same way on
unmodified `origin/main`, so it is unrelated to this change.

## Review
- Low: no test checked that `TurnTime` actually uses the day store, so
reverting it to `Date.now()` would pass CI. Fixed in 85c52e4:
`TurnTime` moved to `src/components/TurnTime.tsx`, `useLocalDay` reads
its store from `DayStoreContext` (the browser clock by default), and
`src/components/TurnTime.test.tsx` renders it inside a memoized wrapper
with a fake clock set years from the real one, checking the label reads
the time before midnight and "yesterday at" after. Verified the test
fails when the component formats against `Date.now()`.
- `bun run check fast`: typecheck, build and the new tests pass; four
unrelated unit files failed under load and pass when run alone.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
devswha added a commit that referenced this pull request Oct 13, 2026
#974)

Follow-up to #951.

## Problem
A diff drawn without colors (past the highlight bound, or highlighting
off) rebuilt every one of its rows on the main thread on each render:
every scroll step, wrap, split or resize. On the 10 000-line diff from
`repo-diff-browser-qa`, at a 4x CPU slowdown, each scroll step held the
page 130-270 ms.

## Root cause
`RepoDiff` passed `disableWorkerPool={!colored}` and wrapped only
colored diffs in `DiffWorkerPool`. Without a pool, `@pierre/diffs`'
`DiffHunksRenderer` takes its no-pool path: `renderDiffWithHighlighter`
over the whole diff, re-run on every render because `forcePlainText` (a
massive diff) re-renders unconditionally. With a pool it uses the
manager's `getPlainDiffAST(diff, startingLine, totalLines, ...)`, which
builds only the rows in view. `VirtualSource` had the same problem,
fixed in 867e802.

## Change
- `RepoDiff` always renders inside `DiffWorkerPool` and drops
`disableWorkerPool`. Plain diffs never reach a worker:
`tokenizeMaxLength: 0` keeps them massive, so no highlight is queued.
- Updated the pool comments in `DiffWorkerPool.tsx` and
`sourceTheme.ts`.
- Added `changelog.d/repo-diff-windowed-plain-rows.md` (Fixed).

## Validation
Measured with a scratch Playwright script (not committed) on the 10
000-line plain diff, desktop 1440px, CDP
`Emulation.setCPUThrottlingRate` 4. The numbers are the longest long
task per step across 3 runs:

| step | before | after |
|---|---|---|
| open | 248-280 ms (4 tasks, 781-872 ms total) | 82-91 ms (2-4 tasks,
163-295 ms total) |
| scroll to middle | 174-272 ms | 116-127 ms |
| scroll to end | 132-185 ms | 72-75 ms |
| small scroll steps (x5) | 134-224 ms | 57-98 ms |
| wrap on | 117-169 ms | 68-84 ms |
| split | 143-228 ms | 95-118 ms |
| fold context | 317-325 ms | 220-303 ms |

The fold step still costs about the same. Most of it is
`trimPatchContext` and re-parsing the patch on the page, which this
change does not touch.

- `CI=1 bun run check run --build bun scripts/repo-diff-browser-qa.ts`:
passes (all widths and themes, remote, demo)
- `bun run check fast`: passes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
devswha added a commit that referenced this pull request Oct 13, 2026
…977)

## Problem

After #951 the entry chunk grew from about 475 KB to about 572 KB gzip.
Part of that is `@legendapp/list`, which `ChatTimeline` pulls in, and
`ChatTimeline` was a static import of `ChatView`. So every page load
parsed the list library, even for someone who never opens the chat lens.

## Root cause

`ChatView.tsx` did `import { ChatTimeline } from "./ChatTimeline.tsx"`,
and `ChatView` is a static import of `PaneTerminal`. That put the
timeline and `@legendapp/list` in the entry chunk.

The list is only about 42 KB of the roughly 97 KB #951 added. The rest
is React 19 and the other #951 code. This PR does not touch that.

## Change

- New `src/components/chatTimelineLoader.ts`. It runs
`import("./ChatTimeline.tsx")` once, when the entry runs, so the chunk
is fetched right after the entry and not when chat is opened. It keeps
the loaded component and exposes `useChatTimeline()` (a
`useSyncExternalStore`). If the load fails, the loader forgets it so the
next read tries again. It does not use `React.lazy`, because that can
suspend once even when the module has already loaded.
- `ChatView`'s conversation read waits for the chunk (`await
loadChatTimeline()`) before it sets any turn. Once the chunk has loaded,
this check costs nothing. Because of the wait, the list never mounts
with a partly loaded conversation: it mounts once, with `scroller` and
`timeline` bound, and the restore, initial scroll-to-end and `onRead`
effects see the list.
- Until the chunk arrives, `ChatView` shows the same loading state
(header, then the "Loading conversation…" footer) inside the same
`.chat-view.chat-view-virtual` / `.chat-transcript-virtual` boxes, just
without the list. The two effects that bind the scroll node once
(`ResizeObserver` follow and `dismissKeyboardOn`) now depend on the
loaded component too, so they bind to the list's node when it mounts.
- `ChatTimeline.css` is still imported from `ChatView`, so it stays in
the entry CSS. `.chat-frame`, `.chat-frame-body` and the loading state
need it before the chunk arrives, so no styles change late.
- `src/AGENTS.md` (Chat lens row) describes the split.

Trade-off: the entry gets smaller, so there is less to parse and compile
before first paint. The total bytes of a cold load stay the same,
because the chunk is fetched right away and not on demand. If the chunk
cannot be fetched (offline after an update, for example), the chat error
line shows the browser's "Failed to fetch dynamically imported module"
text, and the next poll tries again. The other lazy viewers (RepoDiff,
VirtualSource) already behave this way. The service worker caches every
hashed `/assets/` file, so the new chunk is cached like the others.

## Measurements

`bun run build`. Before is `origin/main` 9dce921, after is this branch.

| | before | after | change |
|---|---|---|---|
| entry `index-*.js` raw | 1,876.45 kB | 1,744.59 kB | -131.9 kB |
| entry gzip (vite report) | 586.91 kB | 544.74 kB | -42.2 kB |
| entry `.js.gz` served | 579,664 B | 537,846 B | -41.8 KB |
| entry `.js.br` served | 498,834 B | 459,318 B | -39.5 KB |
| new `ChatTimeline-*.js` | none | 132.48 kB raw / 42.58 kB gzip | |

`LegendList` no longer appears in the entry chunk. No CSS chunk was
split off.

## Validation

Linux x64, Bun 1.4.3.

- `bun run check fast`: all steps ok (typecheck, build, unit tests 3455
pass / 0 fail).
- These three were run one after another on the pushed commit
(28591de), with no source changes during the runs, and each exited 0:
`CI=1 bun run check run --build bun scripts/ui-regression.ts`, `...
scripts/chat-fallback-browser-qa.ts` and `...
scripts/chat-virtual-browser-qa.ts`.
- A one-off browser run, not committed. The chat-virtual fixture was
built with code splitting, and the request for the chunk holding
`LegendList` was held. While it was held: the chunk was a separate
request, the conversation read had happened, "Loading conversation…"
showed, there were no turn rows, and `.chat-frame` was `position:
absolute`. After the chunk was released: rows rendered, the view sat at
the end (row 199 visible), and after the viewport was narrowed the view
was still at the end, so the `ResizeObserver` was bound to the list's
node.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
devswha added a commit that referenced this pull request Oct 13, 2026
## Change

The composer's saved drafts (the bookmark button beside Attach, from
#951) are removed before they ship. The box already keeps a draft per
pane, so the button only added a list of put-aside drafts that lived in
one browser and could not be reached again once the pane closed, for a
fourth control in the row.

- Deleted `ComposerStash.tsx` / `.css`, `lib/promptStash.ts` and its
test, and the wiring in `Composer.tsx` (`replaceDraft`).
- Dropped its ten strings from the four language files, its lines in the
guide, `DESIGN.md`, `src/AGENTS.md` and `THIRD_PARTY_NOTICES.md`, and
its popover check in `scripts/composer-fit-demo-regression.ts`.
- The feature was never released, so the two unreleased fragments that
announced it lose that sentence instead of gaining a "Removed" entry.

Drafts someone already saved stay in that browser's storage
(`herdr-web-ui:prompt-stash:*`) with nothing left to show them.

## Validation

- `bun run check fast` on macOS arm64, Bun 1.4.0: generated types,
typecheck and build ok. Unit tests: every file passes except
`server/voice.test.ts` ("streams deltas and the done text from a split
SSE answer"), which fails the same way on `main` a4b2295 on this Mac.
`portal`, `plugin`, `install-star` and `ci-setup` tests failed in a run
that shared the PC with another full suite; each passes alone here and
on `main`.
- `bun scripts/composer-fit-demo-regression.ts`: every remaining check
passes.
- Not run locally: the integration and browser lanes.
devswha added a commit that referenced this pull request Oct 13, 2026
…r the message box (#991)

## Change

The strip under the message box (#951) had a place for the branch that
nothing filled: `Composer` takes `branch`, and `PaneTerminal` passed
only `cwd`.

- The strip now names the workspace checkout's branch at its right end.
`lib/paneBranch.ts` is a small store the sidebar's `useWorktreeBranches`
publishes into and `PaneTerminal` reads (`usePaneBranch`), so the roster
stays the only reader of the git inventory and no second poll is added.
A detached checkout reads "Detached HEAD".
- A linked worktree is marked as one: its folder takes lucide
`FolderGit2` and the word Worktree after its name, from
`workspace.worktree.is_linked_worktree` in the snapshot.

It only names them; nothing in the strip is pressed. A repository with
no linked worktree open has no branch there (the roster does not
inventory it), and a PC whose roster is folded names the folder alone.

This touches the same lines of `Composer.tsx`, the guide, `DESIGN.md`,
`src/AGENTS.md` and the language files as #988; whichever merges second
needs a rebase.

## Validation

- `bun run check fast` on macOS arm64, Bun 1.4.0: generated types,
typecheck and build ok. Unit tests: every file passes except
`server/voice.test.ts` ("streams deltas and the done text from a split
SSE answer"), which fails the same way on `main` a4b2295 on this Mac.
`portal`, `plugin`, `install-star` and `ci-setup` tests failed in a run
that shared the PC with another full suite; each passes alone here and
on `main`.
- New unit test `src/lib/paneBranch.test.ts`; one new string, translated
in the four language files.
- A one-off browser script against the test herdr session, not
committed: a repository workspace and a worktree of it, each running
Codex. The worktree's strip read `login-form`, Worktree,
`feature/login-form`; the repository's read `test-project`, `main`, no
mark.
- Not run locally: the integration and browser lanes.
devswha added a commit that referenced this pull request Oct 14, 2026
Contrast, Text smoothing, Panel motion, the UI and code fonts and Folder and branch never shipped (#951, #1033 are after v0.4.8), so their changelog fragments no longer add them and trim-settings removes only the five that shipped. Drops the pace text from the guide, removed settings from DESIGN.md's page list, a vacuous test, the contrast.ts credit and FontFamilyInput's unused placeholder prop.
devswha added a commit that referenced this pull request Oct 14, 2026
## Change

Removes eleven settings and fixes each at the value most devices already
used. Only settings the maintainer added were considered; ones that came
from outside contributors were left alone.

| Setting | Now |
|---|---|
| Contrast | the palette as drawn |
| Text smoothing | grayscale |
| Panel motion | default speed (`prefers-reduced-motion` still turns
motion off) |
| Interface font, Code font | the built-in stacks (`--font-ui`,
`--font-mono`) |
| Show pace (plan meters) | off, and the pace marker, rate and "Runs
out" text are gone |
| Suggestion chip | always offered on a touch screen |
| Folder and branch | always shown |
| Fit 80 columns in a split pane | always on |
| Cursor shape, Blinking cursor | a blinking block; a program's own
DECSCUSR still changes it |

Five of them (contrast, text smoothing, panel motion, interface and code
font) came in at once with #951's port and none had a user asking for
it. The terminal and chat font families stay: those are the ones users
set.

- `lib/contrast.ts` and `lib/appearanceRendering.ts` are gone, with the
`[data-contrast]` layer, the `*-base` copies, `--contrast-far`,
`--motion-scale` and the `data-font-smoothing` rule in `styles.css`;
`DESIGN.md` follows.
- `usage.ts` loses `windowPace`, `formatRate` and `formatRunsOut`.
- A stored record that still names a removed setting loads without it
(`sanitizeSettings` drops unknown keys; a new test pins it). The shared
preferences list drops `showSuggestionChip` and `usagePace`.
- `shared/telemetry.ts` is unchanged on purpose: the snapshot sends the
fixed values for the five removed fields its schema still names, so the
Worker needs no redeploy.
- Browser scripts: `usage-regression` drops the pace checks,
`narrow-pane-demo-regression` the switch, `ui-regression` the chip-off
case, and `font-swap-demo-regression` sets its monospace fallback on
`<html>` instead of through the removed Interface font.

## Validation

- `bun run check fast`: generated types, typecheck, build, unit tests
(3588 pass, 0 fail).
- Ran locally: `settings-pages-demo-regression`,
`narrow-pane-demo-regression`, `font-swap-demo-regression` (the last
fails on this branch before its fix and passes after, matching main).
`ui-regression` and `usage-regression` were not run locally; CI's
browser lane runs them.
- Demo app, 1280×800, with every removed setting stored at a non-default
value: `<html>` carries no `data-contrast`, `data-font-smoothing`,
`--motion-scale`, `--font-ui` or `--font-mono`, sheets keep 360ms, and
Appearance, Chat, Terminal and Subscription usage show none of the
removed rows, with no page errors.
devswha added a commit that referenced this pull request Oct 14, 2026
Removes the "Files edited in this turn · Working tree" list that chat
work blocks drew under their rows. It repeated paths the edit rows
already show and added noise to every turn that touched files.

- Deletes `TurnChangedFiles.tsx`/`.css` and `lib/turnChangedFiles.ts`
with its test.
- Drops the `cwd`/`onOpenDiff` props and `ChatDiffContext` that only fed
it (App → PaneTerminal → ChatView). Files → Changes still opens diffs
through `useRepoDiffViewer`.
- Removes its three now-unused i18n entries (ko/ja/zh).
- The feature is unreleased (#951), so its line is dropped from
`changelog.d/t3code-ports-and-chat-rendering.md` instead of adding a
Removed entry.

Verified: `bun run typecheck`; `i18n`, `src/conventions`,
`scripts/conventions` and `changelog-fold` unit tests pass. No browser
check run.
devswha added a commit that referenced this pull request Oct 15, 2026
## Change

Removes the chat's own message search: the floating **Find in messages**
button, the Mod+F shortcut that opened it, and its panel (added in #951,
placement fixed in #1115). Mod+F in a chat goes back to the browser's
find. **Find in terminal** (Mod+Shift+F) is unchanged.

Removed along with it:
- `src/components/ChatFind.tsx`/`.css`, `src/lib/chatSearch.ts` and its
test
- the row match highlight, the user-message fold that opened on a match,
and `ChatRowMemory.outputChanged` (only search read it)
- the `--chat-find-menu-space` pane-menu inset from #1115
- seven strings in each of the ko/ja/zh dictionaries
- the Find rows in `docs/guide.md` and `DESIGN.md`

The feature was never released, so the unreleased fragments are edited
(`chat-find-menu-placement.md` deleted, the Find sentences dropped from
two others) and no Removed entry is added.

## Tests

- `scripts/chat-virtual-browser-qa.ts` used Find to reach offscreen and
older rows. A `reveal()` helper now scrolls there instead; the
search-only steps (match count, earlier-page cancel/retry) are gone.
Passes at all four sizes/themes.
- `scripts/narrow-pane-demo-regression.ts` drops its Find placement
block. The script still fails at "a split under 80 columns" (84 cols at
13px), **and fails the same way on current main** (checked on a clean
main worktree), so that failure is pre-existing and unrelated.
- `bun run check fast`: typecheck, build, 3740 unit tests pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
devswha added a commit that referenced this pull request Oct 15, 2026
## Change

Follows the direction in #798 and the note on #812: scoped on top of the
recorder from #951.

- **Exact modifiers in Record.** A chord other than Mod+Shift is stored
as pressed (`meta+PageUp`, `alt+meta+b`, `ctrl+k`) and shown that way in
the row and the palette. A bare stored key still means Mod+Shift, so
existing bindings are unchanged.
- **Risky chords**, as discussed in #798:
- refused: chords the browser, the OS or text editing keeps (Mod+W/T/N,
Mod+A/C/V/X/Z, ⌘+Q/H/M and ⌘+\` on a Mac, Ctrl+PageUp/PageDown, macOS
Ctrl+arrows), a non-Mac Meta chord, and a key without Ctrl, Alt or ⌘;
- plain Ctrl/Alt (no ⌘): the row warns that the terminal uses it and
saves only after **Save anyway** (Cancel keeps the old binding). This
covers Ctrl+K for the palette;
  - a few ⌘ chords the browser commonly uses get a note, but are saved.
- **More keys for Record:** Home, End and the punctuation keys.
Punctuation is matched by key position (`KeyboardEvent.code`), so it
works on any layout: on a Hungarian keyboard `É` is the `;` key. Letters
still match the character typed, so AZERTY keeps its M. Where Chromium
exposes the layout map, the row shows the user's own character.
- **The row's dropdown is unchanged.** Home, End and punctuation are
only available through Record, since a US character in a list would
point to a different key on most layouts. A recorded one is listed as
itself.

Commits are in order and each builds on the one before; the PR can be
squashed.

## Validation

- `bun run check fast`: generated types, typecheck, build pass. Unit
tests: 3748 pass; `server/portal.test.ts` failed 2 timing tests in the
parallel run and passes alone (31/0). This PR does not touch `server/`.
- New unit tests in `src/lib/shortcuts.test.ts` and
`src/lib/shortcutRecorder.test.ts`: exact chord storage and matching,
refusals and risks per platform, macOS Option chords, Home/End,
position-based punctuation (Hungarian, German, Russian; AZERTY M stays
M), the dropdown key list.
- New browser regression
`scripts/shortcut-exact-modifiers-demo-regression.ts` (added to
`scripts/ci-browser.sh`), on the demo: a safe exact chord is saved and
dispatched, Ctrl+K needs Save anyway and Cancel saves nothing, refusals,
End via Record shown in the dropdown, a Hungarian É bound by position,
the default released after rebinding, from the message box and after a
reload. PASS.
- Used daily on an iPad with a Hungarian hardware keyboard.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01VoME51Ex6avEzqEBmkYzGd

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Hako <[email protected]>
devswha added a commit that referenced this pull request Oct 25, 2026
## Change

Selecting text in one of the agent's chat replies drew a **Quote in
message** row over the message box (#1845). That row joined the composer
stack, so the chat moved under the reader's selection. The maintainer
asked for the feature to be removed. Measured on the demo, on main at
a1e4f8b:

| width | chat scroller height | selected reply's position |
| --- | --- | --- |
| 1440 | −44 px | unchanged |
| 390 (phone) | −84 px | moved 52 px (scrollTop +52) |

This PR removes the whole chat-reply feature:

- `.composer-quote-row` / `.chat-quote` (PaneTerminal.css) and the row,
its press hold and its pointerup listener (PaneTerminal.tsx)
- the reply selection tracking and the `.chat-reply` wrapper in
ChatView. The page-key line step goes back to `.chat-turn-agent >
.markdown`, in ChatView and in `pane-paging-demo-regression.ts`.
- ChatTimeline's `holdSelection` row pinning
- `formatReplyQuote`, `REPLY_QUOTE_LABEL` and
`ComposerDraftStore.appendQuote`, with the tests only they needed
- `scripts/reply-quote-demo-regression.ts` and its browser-lane line,
the DESIGN.md entry, and the Added fragment

The terminal lens keeps its own **Quote in message** (#951) as it was
before #1845. #1845 changed only one thing on that path: it moved the
fence into a shared `fenceFor` helper, which is now back inline in
`formatTerminalQuote`. The terminal still uses its three strings (Quote
in message, Added to the message draft, Too long for the message draft),
so they stay translated. Files that no later commit touched are restored
to their pre-#1845 state; ChatView, PaneTerminal, DESIGN.md and
ci-browser.sh were edited by hand, so later work in them is kept.

No new design. Chat selection goes back to the plain browser selection
and copy that DESIGN.md already describes (the Claude/ChatGPT
distinction between selecting text and copying an answer).

Changelog: users never got #1845 (`git tag --contains 314200a` is
empty). As in #1572, its unreleased Added fragment is deleted and no
Removed entry is added.

## Validation

- `bun run check fast` (through `dori heavy`): workflow syntax,
generated types and themes, typecheck, build, and unit tests (6714 pass)
all ok.
- No-movement QA on the demo build at 1440 (a real mouse drag) and at
390 phone emulation (a selection range, as a long press leaves it),
sampling 40 animation frames after the selection. On this branch the
reply's position, the scroller's height and scrollTop, and the message
box's position all stay put (deltas 0), no quote row is drawn, and the
selection stays. The same script on main shows the movement in the table
above.
- Terminal lens: `checkTerminalCopyOff`
(terminal-copy-off-regression.ts, which drags in the terminal and waits
for its Quote in message button) passes on an isolated test herdr.
`terminalQuote.test.ts` passes.
- Adjacent regressions: `pane-paging-demo-regression.ts`,
`chat-selection-copy-regression.ts` and `chat-virtual-browser-qa.ts`
pass. `scripts/ci-browser.test.ts` passes.
- Reviewed by Codex (gpt-6.1-sol, xhigh): no findings, APPROVE.

---------

Co-authored-by: mp <mp@local>
devswha added a commit that referenced this pull request Oct 25, 2026
…t as a turn (#1935)

Waiting for the maintainer's own review before merge.

Part of #992, the Claude Code part. pi, the omp family and Codex follow
as separate PRs, one at a time.

## Change

In a Claude Code pane, Chat dropped two kinds of picture:

- **A picture a tool returned.** Claude Code's `Read` of a screenshot
keeps the picture inline in `tool_result.content[]`. The parser kept
only the result's text, so the row showed nothing.
- **A prompt that is only a picture.** It was drawn, but the byte
scanner that pages the transcript and follows a `/rewind` (`opensTurn`
in `server/transcript-turns.ts`) needed text to see a prompt. So after a
rewind, a screenshot sent as the next prompt left the abandoned turns on
screen, and a page could not start at such a prompt.

What it does now:

- **Tool pictures:** each one is named in the row's existing
`tool.images` as `<entry uuid>:<block>:<place in the result>`, and `GET
/api/pane/conversation/image` reads it back by that ref. The row loads
it only once it is opened, like pi's. The conversation response carries
refs only, never base64.
- **Picture-only prompts** open a turn in the scanner as they do in the
parser. A record longer than the 1 MiB the chain reader parses is read
with its picture bytes cut to their first bytes, because on this PC 69
of 434 Claude picture prompts are longer than that (p90 1.5 MB). The
cold history scan also carries such a record whole across its 16 MiB
windows (up to the largest picture the chat shows), where it used to
drop any record over 64 KiB at a window edge. A picture in the same
record as a tool result opens nothing, so the result stays on the page
of the call it answers.
- **One check, both sides:** `claudeImageType` decides what is a picture
for the parser and the endpoint alike: PNG, JPEG, GIF or WebP by
declared type and by leading bytes, at most 8 MiB decoded (the cap Codex
images already have). So the page never names a picture the endpoint
refuses. This now also applies to pasted prompt pictures, which had no
size cap or byte check before.
- **Same history as the page:** the endpoint reads a Claude picture
after the last `/clear`, on the branch a rewind left, and only from an
entry the parser draws (not `isMeta` or a compaction under the same
uuid), and a tool's picture only from a result the page draws: one that
answers a call it shows, which no result before it answered. It searches
the transcript a window at a time, reads a candidate record's shape a
window at a time, and reads back whole only the picture it serves: never
a record or the transcript whole.

**HTTP contract:** `/api/pane/conversation/image` accepts a third ref
shape. There is no new endpoint and no new wire field (`tool.images`
already exists). Since it changes what that endpoint answers, this needs
a real review.

**Remote bundle:** the server files are in the remote PC bundle.
`REMOTE_BUNDLE_VERSION` is not raised here; the release does that.

**Design:** no new UI. It uses the row's picture gallery and viewer that
pi's tool pictures and pasted pictures already use (#951). It follows
the Claude and Codex apps, which show a picture a tool read inline with
that tool call.

**Not in this PR:** pi and omp-family user pictures, omp blob tool
pictures, Codex tool-output pictures (separate PRs), and local Markdown
images in answers.

## Validation

- **Unit tests** (`server/conversation.test.ts`,
`server/claude-incremental.test.ts`), each new one shown failing without
its fix:
- a `Read` result's PNG is named `<uuid>:<block>:<place>` with no base64
in the page, and `transcriptImage` returns its exact bytes;
- a picture-only prompt opens a turn (`turnStarts`), and after a
recorded `/rewind` (Claude Code 2.1.304 fixture) a picture-only next
prompt hides the abandoned turns, warm and cold, for a 16 B picture, a
900 KiB one, and a 2 MB one whose record crosses the cold scan's 16 MiB
window;
- refused, at the parser and the endpoint alike: an svg, non-raster
bytes declared `image/png`, a picture past 8 MiB (exactly 8 MiB passes),
a ref to the result's text, a ref with no picture, malformed refs, a
picture from before `/clear`, one from a turn a rewind abandoned, and an
`isMeta` record carrying the same uuid;
- a tool result and a picture in one record stay on the page of the
call, equal to a full parse;
  - live (incremental) parsing names the same refs as a cold parse;
  - existing `<uuid>:<index>` prompt pictures parse and serve as before.
- **Real transcripts on this PC** (shapes only, nothing printed): 5
Claude transcripts with `Read` pictures (PNG and JPEG, one from a
subagent): every picture passes the check, each is named once (Claude
Code's `api-request-blob` copies are not), and no base64 reaches the
page. 69 of 434 Claude picture prompts here are over 1 MiB, which is why
the large-record path exists.
- **Browser** (`scripts/claude-image-browser-qa.ts`, added to the CI
browser lane): a Claude stand-in on an owned herdr pane, the real server
and Chrome. A picture-only prompt sent after a rewind is its own turn
with its thumbnail decoded and no empty bubble, the rewound turns stay
hidden; the `Read` row fetches nothing while folded and decodes its
picture once opened; a ref the transcript does not hold is 404. Desktop
and phone (390 px, fresh mobile context) screenshots checked: the tool
picture in the opened Read row, the picture-only prompt as its own turn
with no empty bubble.
- **Reviews:** `omo-native-code-reviewer` (one HIGH: a tools-typecheck
error in the script; fixed) and Codex on Sol 6.1 (no HIGH; four MEDIUM
and one LOW, all fixed with tests); a delta review of the fixes
approved, and its one MEDIUM (the 16 MiB window case) is fixed with a
test.
- Rebased onto 4a4bdaa (0.4.16); the one conflict was an import in
`server/conversation.ts` (main's `claudeAttachSession`). After the
rebase: the touched suites pass (`server/conversation.test.ts`,
`server/claude-incremental.test.ts`, `scripts/ci-browser.test.ts`: 163
pass), `scripts/claude-image-browser-qa.ts` passes all three checks, and
a Codex (Sol 6.1) review of the rebase delta found nothing.
- **Merge pass gate review and re-check:** the endpoint served an orphan
tool result's picture, read the whole transcript, then still read a
matching record whole and took one JSON spelling of ids. All fixed
(03d6129, 0ba6e03): a picture only from a result the page draws, a
window, a record's shape and the picture's own text at a time, ids
matched however JSON writes them. Each finding has a test that fails
before its fix; Codex (Sol 6.1) reviewed each step and its findings are
fixed with tests
([reply](#1935 (comment))).
- `bun run check fast`: passes on this head (workflow syntax, generated
types and themes, typecheck, build, unit tests).
- **Before/after for the maintainer:** screenshots (desktop and phone)
and a short recording of each, from an isolated herdr test session, made
with the same fixture on main and on this branch:
http://100.123.228.51:18992/ (tailnet only, served while this PR is
open). One synthetic session on both sides: a `Read` of a chart
screenshot, a turn taken back with `/rewind`, then a prompt that is only
a screenshot. On main the Read row has no picture and the rewound turn
is still shown; on this branch the chart shows in the opened row (and
opens in the viewer) and the rewound turn is hidden.

---------

Co-authored-by: mp <mp@local>
devswha added a commit that referenced this pull request Oct 25, 2026
…turn (#1945)

Part of #992, the pi part. It follows #1935 (Claude Code), and uses the
same check and the same endpoint rules.

## Change

In a pi pane, Chat dropped the pictures sent to pi: a screenshot pasted
into a prompt was in the session file and never shown, and a prompt that
was only a picture opened no turn, so it vanished. Tool pictures were
shown, but checked only by declared type.

What it does now:

- **Prompt pictures:** a picture in a pi prompt, alone or beside words,
is named in the turn's image parts as `pi-prompt:<entry id>:<place among
its pictures>`, and `GET /api/pane/conversation/image` reads it back by
that ref. Only refs reach the page, never base64; the bytes are fetched
when the prompt is shown.
- **Picture-only prompts** are drawn as a turn and open one for paging
(`turnStarts`), as a prompt with words does.
- **One check:** `inlineImageType` (moved next to the Codex image code)
decides what is a picture for Claude and pi alike, for the parser and
the endpoint: PNG, JPEG, GIF or WebP by declared type and leading bytes,
at most 8 MiB decoded. pi tool pictures now pass it too, so a page never
names a picture the endpoint refuses.
- **Same history as the page:** the endpoint reads a pi picture on the
active `/tree` branch after the last clear, and as the parser draws it:
a tool's picture only from the first result that answers a call the page
shows (not an orphan result, a second answer, or a later block for the
same call), a prompt's only from a prompt the page shows. A clear or an
id is matched however JSON writes it. Records are read one at a time
(`piBranchRecords`, per-record cap), never the whole transcript.
- `scripts/pi-image-browser-qa.ts` now runs in the CI browser lane and
covers a picture-only prompt.

**HTTP contract:** `/api/pane/conversation/image` accepts one more ref
shape (`pi-prompt:`). No new endpoint, no new wire field.

**Design:** no new UI: the prompt thumbnails and the viewer pasted
pictures already use (#951).

## Validation

- **Unit tests** (`server/pi.test.ts`), each failing on the code before
its fix:
- prompt pictures named by entry and place, decoded on request; an svg
or non-raster bytes take no place; refs that name nothing are 404;
  - a picture-only prompt opens a page's turn;
- a picture a `/tree` or a clear left behind is out of the chat and out
of reach;
- a tool's picture only from the result the page draws: a call answered
twice, an answer with no picture before a duplicate, two result blocks
in one entry, a result answering no call, a call made again after an
answer with no picture;
- an escaped `context_clear` and an escaped prompt id, read as the
parser reads them.
- `server/pi-large-history.test.ts`: its tool-picture fixture now
includes the call its result answers (it relied on the endpoint serving
an orphan result's picture, which the page never names); fake image
bytes in `server/omp-incremental.test.ts` are real raster headers now.
- **Browser** (`scripts/pi-image-browser-qa.ts`, real Chrome): the
picture-only prompt is its own turn with its thumbnail decoded from the
served bytes and no empty bubble; the tool row fetches nothing while
folded and decodes both pictures once opened; a result whose pictures
vanish leaves no stranded <img>. Its stub server now answers
`/api/pane/commands` as its siblings do.
- **Reviews:** Codex (Sol 6.1) reviewed the change three times: three
MEDIUMs (escaped clear, a picture from a result the page ignores,
escaped prompt id), then one (a call made again after an answer with no
picture). All fixed with tests. The last review approved with no
findings. One known limit it noted: if a pi session reused a call id and
both results carried a picture, the page would name the same ref twice
and the endpoint serves the first; pi writes unique call ids.
- `bun run check fast`: passes on this head (workflow syntax, generated
types and themes, typecheck, build, 6797 unit tests).

Co-authored-by: mp <mp@local>
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.

1 participant