Skip to content

Phase 3.2: PreviewPanel multi-tab#72

Open
baochipham942-eng wants to merge 4 commits intophase3-multi-previewfrom
phase3-2-preview-tabs
Open

Phase 3.2: PreviewPanel multi-tab#72
baochipham942-eng wants to merge 4 commits intophase3-multi-previewfrom
phase3-2-preview-tabs

Conversation

@baochipham942-eng
Copy link
Copy Markdown
Owner

Stacked on top of #71. Merge #71 first; GitHub will auto-retarget this PR's base to `main`.

Summary

  • Per-tab content/savedContent/mode lives in appStore, so switching tabs preserves edit buffers (including dirty indicator) across clicks.
  • New `PreviewTabs` component renders a tab row above the panel header. Click to activate, X or middle-click to close, amber dot marks unsaved edits.
  • LRU eviction at `MAX_PREVIEW_TABS = 8` so opening a 9th file drops the least-recently-activated one.
  • Dedup by path — clicking the same artifact twice focuses the existing tab instead of opening a duplicate.

Commits

sha what
`d043d2ff` tab-aware store model + panel reads active tab
`cfd872a1` PreviewTabs UI
`20f9886e` LRU eviction + 7 unit tests

Test plan

  • `npm run typecheck`
  • 7/7 new unit tests on `openPreview`/`closePreviewTab`/`markPreviewTabLoaded`/`markPreviewTabSaved` (total 16 renderer tests green)
  • `npm run build:renderer` clean
  • Manual: open 2+ artifacts in a chat, verify tabs appear, switch between them, keep dirty edits across switches, close via X/middle-click, open 9th file and confirm LRU drop

Out of scope (noted)

  • Session status "就绪" after restart — pre-existing behavior; `messageCount === 0` in `sessionPresentation.ts` when messages are lazy-loaded. Will be a separate PR if we fix.
  • Bug 2 (Skills/Task panel collision) still deferred, pending Codex app UX reference.
  • `shell:open-path` latent IPC bug in `WorkingFolder.tsx` — same no-handler shape as Bug 1; pending plugin-opener pass.

🤖 Generated with Claude Code

林晨 and others added 3 commits April 22, 2026 21:59
Introduces PreviewTab in appStore with per-tab content/savedContent/
mode/lastActivatedAt/isLoaded. Replaces previewFilePath with
previewTabs + activePreviewTabId. openPreview becomes a dedup-and-
activate action, so clicking the same artifact twice focuses the
existing tab instead of re-opening.

PreviewPanel now reads editor state from the active tab (content,
saved content, mode) and writes back via store actions
(updatePreviewTabContent, updatePreviewTabMode, markPreviewTabLoaded,
markPreviewTabSaved). Transient UI state (isLoading/isSaving/error/
isMaximized/isExporting) stays in the component.

No visible UI change yet: the tab bar arrives in the next commit. But
content state is now preserved across future tab switches because it
lives in the store rather than component-local useState.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds PreviewTabs.tsx rendering one row per open file above the panel
header. Clicking a tab activates it, X or middle-click closes it, and
the dirty indicator (amber dot) surfaces unsaved edits. closePreviewTab
in the store already picks the next most-recently-activated tab as
successor and hides the panel when the last tab closes.

With commit d043d2f's per-tab content state, tab switching now
preserves edit buffers — switching away from a markdown tab with
unsaved changes and coming back keeps the draft intact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Opening a 9th file now evicts the least-recently-activated tab.
lastActivatedAt switches from Date.now() to a monotonic counter so
rapid same-tick activations don't collide in MRU ordering.

Adds 7 unit tests covering dedup-by-path, LRU eviction, MRU successor
on close, panel hide on last-close, and the load/save content
lifecycle (markPreviewTabLoaded / markPreviewTabSaved).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 22, 2026

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

Project Deployment Actions Updated (UTC)
code-agent Ready Ready Preview, Comment Apr 22, 2026 2:31pm

QuickFileActions and FileResultDisplay both gated the "Open preview"
button behind an isHtml-only check, so clicking a.md / c.ts / d.csv
fell through to the OS default app. PreviewPanel already renders
markdown and csv/tsv via dedicated panes (Phase 2), so the UI was the
bottleneck.

Introduces src/renderer/utils/previewable.ts as the single source of
truth for "what PreviewPanel can render cleanly" (md/mdx/markdown,
csv/tsv, html/htm, txt). ToolCallDisplay's two file-action surfaces
now use isPreviewable() instead of the narrow isHtml check.

ts/tsx/jsx/json/yaml are intentionally out of scope — they need the
CodeMirror editor from Phase 3.3 to be usefully rendered.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant