refactor: dedupe the jscpd clones; drop the baseline loading gate

- Extract the shared New Session action into WorkspacesService.startSession
  (sidebar button and workspace browser both delegate; recent-Workspace
  targeting and the no-workspace clear live in one place).
- Fold the chip-insertion transaction shared by insert-ref and paste-upgrade
  into one InputMachine helper.
- Share the fixture's session-not-found guard across the sessionId-addressed
  catalog routes.
- Drop the AppFrame baselines-ready loading gate (user ruling: the bare
  status line reads worse than the shell's own pending rendering); both
  column occupants mount from first paint.
This commit is contained in:
imccyu
2026-07-27 08:51:05 +08:00
parent 084e64744a
commit dd2d9ca50a
9 changed files with 75 additions and 103 deletions
+3 -13
View File
@@ -13,19 +13,9 @@ export const inject = ['slots', 'layout', 'sessions', 'workspaces']
*/
export function apply(ctx: ClientContext): void {
const injectProps = (): SidebarRootInjected => ({
// The shell's New Session button targets the most recently active
// Workspace; an explicit Workspace still wins for scoped create actions.
startSession: (workspaceId) => {
const target = workspaceId ?? ctx.workspaces.list.getSnapshot().recentWorkspaceId
if (target === undefined) {
ctx.sessions.clear()
return
}
void ctx.workspaces.connectWorkspace(target).then(
(sessionId) => { ctx.sessions.open(sessionId) },
(reason: unknown) => { console.warn('new session failed:', reason) },
)
},
// The shell's New Session button rides the runtime's shared action
// (recent-Workspace targeting; explicit Workspace wins for scoped actions).
startSession: (workspaceId) => { ctx.workspaces.startSession(workspaceId) },
toggleSidebar: () => { ctx.layout.toggleSidebar() },
})
ctx.effect(