Skip to content

refactor(panel): drop Preview/Code tab; preview-first chrome#5

Open
kleopasevan wants to merge 2 commits intomainfrom
feat/artifact-panel-no-code-tab
Open

refactor(panel): drop Preview/Code tab; preview-first chrome#5
kleopasevan wants to merge 2 commits intomainfrom
feat/artifact-panel-no-code-tab

Conversation

@kleopasevan
Copy link
Copy Markdown
Member

Summary

Brings the artifact panel in line with the slides + document-script renderers: preview is the primary view, no top tab pair, source-of-truth controls live at the panel edges instead of consuming a chrome row.

Before

  • Top tab bar with Preview / Code split
  • Edit pencil hidden inside the Code-tab view-mode overlay
  • application/code tab forced to "Code" on open; text/document hid the bar entirely (one-off)

After

  • Single header Edit pencil (gated on onUpdateArtifact; hidden for text/document which keeps its internal modal-pencil; hidden during edit)
  • Preview always primary
  • Discrete bottom-corner Source button for non-code, non-document types — opt-in raw view that flips back via "Show preview". Pattern matches document-script-renderer's Code/Preview toggle.
  • application/code no longer shows the Source toggle (preview already IS the highlighted code)
  • text/document keeps its existing flow (script: floating pencil → EditDocumentModal; AST: legacy banner, read-only)

Why

The Preview/Code tab pair was confusing for non-developers and inconsistent with the rest of the artifact stack. Slides and document-script never used tabs. This refactor adopts the established pattern: preview is the answer to the user's question, the source view is one click away but stays out of the way.

Test plan

  • Typecheck clean for artifact-panel.tsx
  • Wider regression: 105/105 across tests/unit/features tests/unit/spreadsheet tests/unit/renderers
  • Manual smoke: spreadsheet, slides, code, mermaid, react, html, latex, markdown, text/document (script + AST) all render correctly; edit pencil works; source toggle flips back to preview

- removes the dual-tab affordance at the top of the artifact panel; preview is now the primary view for every artifact type
- adds a single Edit pencil to the panel header (gated on onUpdateArtifact, hidden for text/document which keeps its renderer-internal pencil)
- adds a discrete bottom-corner Source toggle for non-code, non-document types — matches the document-script-renderer pattern (Code/preview button at the bottom, not a top tab)
- application/code drops the redundant Source toggle since its preview is already syntax-highlighted code
- text/document keeps its existing controls (script: floating modal pencil; AST: read-only legacy banner)
- removes tab state, the tab-bar JSX, and the useEffect that exited edit on tab switch
- "Spreadsheet · json" → "Spreadsheet"; "Slides · json" → "Slides"; etc.
- language suffix is preserved only for application/code, where TS / Python / Rust is the actual differentiator
- applies to two callsites: panel header pill and the artifacts-list entries in chat-workspace's right rail
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.

2 participants