Skip to content

refactor(preview): extract the browser lifecycle behind an internal seam - #265

Merged
Tryanks merged 1 commit into
mainfrom
refactor/c4-preview-lifecycle
Aug 24, 2026
Merged

refactor(preview): extract the browser lifecycle behind an internal seam#265
Tryanks merged 1 commit into
mainfrom
refactor/c4-preview-lifecycle

Conversation

@Tryanks

@Tryanks Tryanks commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Architecture round, candidate C4.

Problempreview_panel.rs (1,796 lines) held four concerns at one stateful seam: chrome UI, per-conversation webview cache (incl. draft→stored key migration), platform creation (macOS sync + the Windows generation-tagged async slot machine from #253), and the MCP op broker. Callers had to know hidden ordering facts, and the --preview-smoke harness could only reach lifecycle through three shallow AppShell pass-throughs plus harness-only panel state — evidence the lifecycle had no real interface.

Change

  • New preview_panel/lifecycle.rs: session-keyed browser lifecycle — ensure / navigate / set_visible / drop_view / prune with Availability::{Ready, Starting(CreationPhase), Unavailable}; the two ordering facts (native children must hide before their GPUI owner unmounts; value ops wait for warmth) are documented on the interface itself. Draft→stored key migration lives with the cache it migrates.
  • Platform creation becomes adapters inside the module: macOS synchronous build_as_child; Windows shared-WebContext async build_as_child_async with the exact generation-cancel rule (live window + live panel + live generation) preserved; unavailable as the third state. Moved, not rewritten — this path shipped a crash fix days ago.
  • PreviewPanel keeps chrome + broker + store mirroring as the only production caller. The smoke harness drives the same lifecycle interface via one doc-hidden AppShell::preview_lifecycle accessor; all three smoke pass-throughs and the harness-only panel state are deleted.

Wins — three adapters justify the seam; platform bugs stay in their adapter; the harness exercises production lifecycle, not a parallel surface.

Verification — full --preview-smoke on macOS: all 10 phases + PASS (including drop-during-create and recreate-after-inflight-drop); cargo clippy --target x86_64-pc-windows-gnu -p tcode -- -D warnings clean; fmt / clippy / full workspace tests green.

🤖 Generated with Claude Code

preview_panel/lifecycle.rs owns the session-keyed slot map, platform
creation, visibility, warmth, draft-key migration, pruning, and
teardown behind ensure/navigate/set_visible/drop_view/prune with
Availability{Ready,Starting,Unavailable}; the two ordering facts
(hide-before-unmount, warm-before-value-ops) are documented on the
interface. The macOS-sync and Windows-async creation paths are
cfg-gated adapters inside the module; the Windows generation-cancel
rule, WebContext UDF, pending-URL replay, and unavailable messaging
are moved, not rewritten. PreviewPanel keeps chrome + MCP broker and
is the only production caller. The --preview-smoke harness now drives
the same lifecycle interface through one doc-hidden accessor — the
three AppShell smoke pass-throughs and all harness-only panel state
are deleted. Verified: full --preview-smoke PASS on macOS,
x86_64-pc-windows-gnu clippy clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Tryanks
Tryanks enabled auto-merge (squash) August 24, 2026 07:54
@Tryanks
Tryanks merged commit 6db0e94 into main Aug 24, 2026
7 of 9 checks passed
@Tryanks
Tryanks deleted the refactor/c4-preview-lifecycle branch August 24, 2026 09:17
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