Repository navigation
feat(desktop): workspace views live in main; one copy of the pane layout - #9245
Draft
saddlepaddle wants to merge 7 commits into
Draft
saddlepaddle wants to merge 7 commits into
saddlepaddle wants to merge 7 commits into
Conversation
@superset/panes/core exports the store, layout utils and transfers without React, so the Electron main process can run pane reducers. connectWorkspaceStore makes a WorkspaceStateSource the only writable copy of a store's layout: actions write through to the source, and changes made elsewhere replace the store's layout.
applyPaneLayoutOp, describePaneLayout, preserveLocalPaneSelection and the pane kind constants move to src/shared/pane-layout, so the main process can apply pane layout ops without importing renderer modules. Pane data types stay in the renderer and are imported as types only.
…ocess A workspace_views table holds each v2 workspace's main area and right pane: tabs, the active tab and whether the right pane is open or full screen. The WorkspaceViews service in main is its only writer. It broadcasts every change, and applies pane layout ops itself. The bridge's /pane-layout endpoint now applies ops through that service instead of handing them to one renderer window, so a CLI op no longer needs a window open and does not time out waiting for one. The paneLayout relay (pane-layout-requests, its router and the renderer's GlobalPaneLayoutRequests) is gone. electronTrpc gains workspaceViews: list, onChange, put and remove.
v2WorkspaceViews is a TanStack DB collection fed by the workspaceViews router: it loads main's views, applies every change main broadcasts, and sends local writes to main. Changes that arrive during the first load are applied after it, so an older list cannot overwrite them. A kept terminal reported by main is marked for the background in this window. It is not per organization, so it lives outside the per-org collection cache and is never evicted with it.
… layout Each workspace's pane stores now mirror its view in v2WorkspaceViews through connectWorkspaceStore: store actions write through to the view, and changes from main (the CLI, another window) replace the store's layout. The two-way sync with v2WorkspaceLocalState, its snapshot comparisons, the per-window selection memory (v2-pane-selection) and the mounted-store registry (v2-pane-layout-stores) are gone. The active tab is part of the view, so windows showing the same workspace show the same tab. The right pane's open and full screen state is the view's rightPane.visibility, with the transitions in shared/workspace-views; stores/right-pane-full-screen and useRightPaneMode are gone. Views are created lazily from a workspace's old localStorage layout the first time anything needs them, and only after the collection has loaded from main. Writers and readers move to views: workspace creation, the pending cloud chat, agent browser opens and their saved state, hiding and removing a workspace, notifications, browser lifecycle and the resource snapshot. The old layout fields stay in localStorage, unwritten, for older builds.
Once the views load from main, every visible workspace with a saved localStorage layout gets a view, so CLI pane ops keep working on workspaces that have not been opened since the upgrade. A write that arrives before the views have loaded does nothing instead of throwing.
From review of this branch: - A failed first load from main is retried, and the views are not ready until a load succeeds. Before, a failed load marked an empty collection ready, and the migration and the first opens then wrote stale or empty views over the stored ones. - A renderer write sends only the areas it changed, and main merges them, so a CLI change to the right pane is not undone by a concurrent edit of the main area. - A CLI op on a workspace main has no view for creates one, as the saved layout used to, instead of refusing. - A browser's saved state never creates a view, so it cannot bring back the view of a hidden workspace. - Hiding or removing a workspace before the views load deletes its view once they have.
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
Contributor
🚀 Preview Deployment🔗 Preview Links
Preview updates automatically with new commits |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
Moves each v2 workspace's view (main area tabs, right pane tabs, the active tab, and whether the right pane is open or full screen) out of renderer localStorage and into
local.db, owned by the Electron main process. There is now one writable copy of the layout, and every write goes through one place, whether it comes from a click, an agent or the CLI.Before, the tabs lived twice: in
v2WorkspaceLocalStateand in a zustand store per area. A two-way sync kept them in step (snapshot comparisons,preserveLocalPaneSelection, per-window selection memory). Writers had to choose between the live store and the row, and anything outside the open window (CLI ops, background agent browsers) took its own path. CLI pane ops were relayed to one renderer window: they needed a window open, and timed out after 10 s.What changes
@superset/panes: a React-free./coreentry, andconnectWorkspaceStore. Store actions write through to a source; changes made elsewhere replace the store's layout.applyPaneLayoutOp/describePaneLayoutand the pane kind constants move tosrc/shared/pane-layout, so main can run them.workspace_viewstable (migration generated with drizzle-kit);WorkspaceViewsservice that is its only writer and broadcasts every change;workspaceViewsrouter (list,onChange,put,patch,remove)./pane-layoutendpoint applies ops in main. The relay to a renderer window (pane-layout-requests, thepaneLayoutrouter,GlobalPaneLayoutRequests) is deleted.v2WorkspaceViewsis a TanStack DB collection synced from main. Writes apply at once, and only the changed areas are sent to main, which merges them.v2-pane-selection,v2-pane-layout-stores,stores/right-pane-full-screen,useRightPaneModeand the old sync.rightPane.visibility(closed/open/fullScreen), with the transitions inshared/workspace-views, used by both main and the renderer.Migration of saved data
v2WorkspaceLocalStateare left in place, unwritten, so an older build opens with the layout as it was at upgrade time.Behaviour changes
Kept on purpose: the CLI still reaches the desktop through host-service. Its
panesrouter does host-side work that has to stay there:close;open filepaths against the worktree;Only the step after it changed.
Compatibility: host-service and the bridge's
/pane-layoutcontract are unchanged, so released CLIs work as before. The new electronTrpc procedures are internal: main and renderer ship together.How I tested it
connectWorkspaceStore;keepTerminal;bun test(9,062 pass, 0 fail),@superset/panestests (147 pass),bun run lint, and typecheck in desktop, panes and local-db.electron-vite buildsucceeds, the main bundle contains the new service, and0060_add_workspace_views.sqlis indist/resources/migrations.Checklist
type(scope): subject)bun run lintandbun run typecheckpass (CI fails on lint warnings too)Summary by cubic
Moves each v2 workspace's pane layout out of renderer localStorage into
local.db, owned by the Electron main process. There is now one writable copy of each workspace's view, and every write goes through main whether it comes from a click, an agent, or the CLI.Behavior changes
connectWorkspaceStore.Migration
/pane-layoutcontract and host-service are unchanged, so released CLIs work as before.Written for commit cc4f569. Summary will update on new commits.