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

View File

@@ -34,19 +34,9 @@ export const inject = ['slots', 'sessions', 'workspaces']
*/
export function apply(ctx: ClientContext): void {
const browserInjected = (): WorkspaceBrowserInjected => ({
// Explicit group actions keep their target; an unscoped New Session
// action resolves through the runtime's recent-Workspace projection.
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) },
)
},
// Explicit group actions keep their target; unscoped New Session rides
// the runtime's shared action (recent-Workspace projection inside).
startSession: (workspaceId) => { ctx.workspaces.startSession(workspaceId) },
open: (sessionId) => { ctx.sessions.open(sessionId) },
renameWorkspace: async (workspaceId, title) => { await ctx.workspaces.rename(workspaceId, title) },
insertSessionBefore: async (workspaceId, sessionId, beforeSessionId) => {