Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers

The lower branch removed `rootOf` and the `workspaceRoot` projection: a Session
has one directory, read through `ctx.workingDirectory.get`. This merge moves the
consumers of this branch to that read.

- sandbox-policy, workspace-files, and workspace-changes read `get`; the
  `recordedRootOf` read is removed. With the working-directory service mounted,
  a Session without a header directory is bounded by that service's default
  directory.
- The skill catalog, sidebar terminals, project instructions, `@` file
  candidates, the LSP workspace, and skill lookup return to the lower branch's
  code, which already reads the directory.
- The client helper exports `selectSessionDirectory` and `sessionDirectory`
  in place of the `{ root, cwd }` pair; `WorkspaceChangesSummary` keeps `cwd`,
  now the directory the turn started in.
- A stored `working-directory/change` inside the project moves the write
  boundary and file views with the directory; one outside returns to the project.
This commit is contained in:
LegGasai committed 2026-11-16 22:33:13 +08:00
commit c9b9859b74
955 files changed
+25445 -11344

No files matched your search

@@ -1,25 +1,14 @@
/**
* The directories of one Session as the Client knows them: the projected
* workspace root and current directory. Pure reads with type-only imports, so
* client plugins inline this module instead of requesting a module-table row
* this package does not publish.
* The directory one Session works in, as the Client knows it: the projected
* `workingDirectory`. Pure reads with type-only imports, so client plugins
* inline this module instead of requesting a module-table row this package
* does not publish.
* @module @deepseek-ai/dsh-api-session-controller/client/directories
*/
import type { SessionId } from '@deepseek-ai/dsh-session/types'
import type { ISessions } from '../contract/sessions.ts'
import type { SessionListState } from './service.ts'
/** Which checkout a Session works in and where its relative paths resolve. */
export interface SessionDirectories {
/**
* The workspace root: the checkout the Session works in, which file views and address bases use;
* the original project before any relocation.
*/
readonly root: string | undefined
/** The current directory the model's relative paths resolve from; the root while the Session reports none. */
readonly cwd: string | undefined
}
/** A projected string value by key, from a values object whose keys the Client compilation does not declare. */
function projectedString(values: object | undefined, key: string): string | undefined {
if (values === undefined) return undefined
@@ -28,28 +17,25 @@ function projectedString(values: object | undefined, key: string): string | unde
}
/**
* Select a Session's workspace root from a list snapshot, for `useSessions` selectors.
* Select a Session's directory from a list snapshot, for `useSessions` selectors. File views, address
* bases, and relative paths all use it; the header directory stays the original project.
* @param state - the sessions list snapshot.
* @param sessionId - the Session whose root is selected.
* @returns the projected `workspaceRoot`, else the header directory, else undefined for an unknown row.
* @param sessionId - the Session whose directory is selected.
* @returns the projected `workingDirectory`, else the header directory, else undefined for an unknown row.
*/
export function selectSessionRoot(state: SessionListState, sessionId: SessionId): string | undefined {
return projectedString(state.projectionsBySession[sessionId]?.values, 'workspaceRoot')
?? projectedString(state.byId[sessionId]?.projectionValues, 'workspaceRoot')
export function selectSessionDirectory(state: SessionListState, sessionId: SessionId): string | undefined {
return projectedString(state.projectionsBySession[sessionId]?.values, 'workingDirectory')
?? projectedString(state.byId[sessionId]?.projectionValues, 'workingDirectory')
?? state.byId[sessionId]?.cwd
}
/**
* Read a Session's directories at gesture time: the connected Session's projection faces first, then the list snapshot.
* Read a Session's directory at gesture time: the connected Session's projection face first, then the list snapshot.
* @param sessions - the sessions service.
* @param sessionId - the Session whose directories are read.
* @returns the workspace root and the current directory, each undefined when unknown.
* @param sessionId - the Session whose directory is read.
* @returns the directory, or undefined when unknown.
*/
export function sessionDirectories(sessions: ISessions, sessionId: SessionId): SessionDirectories {
const projections = sessions.binding(sessionId)?.session.projections
const liveRoot: unknown = projections?.faceOf('workspaceRoot').getSnapshot()
const root = (typeof liveRoot === 'string' ? liveRoot : undefined) ?? selectSessionRoot(sessions.list.getSnapshot(), sessionId)
const liveCwd: unknown = projections?.faceOf('workingDirectory').getSnapshot()
const cwd = (typeof liveCwd === 'string' ? liveCwd : undefined) ?? root
return { root, cwd }
export function sessionDirectory(sessions: ISessions, sessionId: SessionId): string | undefined {
const live: unknown = sessions.binding(sessionId)?.session.projections.faceOf('workingDirectory').getSnapshot()
return (typeof live === 'string' ? live : undefined) ?? selectSessionDirectory(sessions.list.getSnapshot(), sessionId)
}