WorkspaceListState gains archivedSessionIds (ReadonlySet, replaced only on membership change), installed as full snapshots from the list baseline, the unary echo, and the changed frame. Archiving the current session clears the selection into the New Session view state. Test doubles (test-runtime, fake APIs, fixture client) follow the widened IWorkspaces/IApiClient faces.
87 lines
3.9 KiB
TypeScript
87 lines
3.9 KiB
TypeScript
/**
|
|
* The outward workspaces-service face — what `ctx.workspaces` exposes to
|
|
* feature packages and the renderer host, and therefore exactly what the
|
|
* test runtime's workspaces double must implement. Wire-pump entry points
|
|
* (handleHostEnvelope/handleConnected/refresh/startInitialSelection) stay on
|
|
* the concrete class. Widening this interface is the explicit act of
|
|
* widening what features may do to the workspaces domain.
|
|
*/
|
|
import type { DirectoryListing, SessionId, WorkspaceId, WorkspaceView } from '@deepseek-ai/dsh-client-connection/client'
|
|
import type { WorkspaceListState } from '../workspaces/service.ts'
|
|
import type { ObservableSnapshot } from './store.ts'
|
|
|
|
/** The workspaces-service face injected as `ctx.workspaces`. */
|
|
export interface IWorkspaces {
|
|
/** The useWorkspaces standard feed (read face — writes stay inside the domain). */
|
|
readonly list: ObservableSnapshot<WorkspaceListState>
|
|
/**
|
|
* Connect a Workspace to its reusable or freshly created blank session.
|
|
* @param workspaceId - target workspace.
|
|
* @returns the connected session id.
|
|
*/
|
|
connectWorkspace(workspaceId: WorkspaceId): Promise<SessionId>
|
|
/**
|
|
* The New Session flow: connect the target (or recent) Workspace and open
|
|
* the resulting session; failures surface on the session list state.
|
|
* @param workspaceId - explicit target; omitted uses the recency projection.
|
|
*/
|
|
startSession(workspaceId?: WorkspaceId): void
|
|
/**
|
|
* Create a Workspace by name or register an existing path.
|
|
* @param input - exactly one Host create spelling.
|
|
* @returns the created or idempotently resolved Workspace.
|
|
*/
|
|
create(input: { name: string } | { path: string }): Promise<WorkspaceView>
|
|
/**
|
|
* Open the Host's native directory picker.
|
|
* @returns the selected path, or null when the user cancelled.
|
|
*/
|
|
pickDirectory(): Promise<string | null>
|
|
/**
|
|
* List one directory level through the Host's `browse` capability.
|
|
* @param path - absolute directory to list; absent lists the Host home directory.
|
|
* @param signal - aborts the wire request (and the Host's scan) when the caller supersedes it.
|
|
* @returns the level's listing with breadcrumb ancestry.
|
|
*/
|
|
listDirectory(path?: string, signal?: AbortSignal): Promise<DirectoryListing>
|
|
/**
|
|
* Create one child directory through the Host's `browse` capability.
|
|
* @param path - absolute existing parent directory.
|
|
* @param name - single non-blank path segment.
|
|
* @returns the created directory's absolute path.
|
|
*/
|
|
createDirectory(path: string, name: string): Promise<string>
|
|
/**
|
|
* Open a filesystem path with the Host operating system's default application.
|
|
* @param path - absolute or host-resolvable path.
|
|
*/
|
|
openPath(path: string): Promise<void>
|
|
/**
|
|
* Rename a Workspace.
|
|
* @param workspaceId - target workspace.
|
|
* @param title - the new display title.
|
|
* @returns the updated Workspace view.
|
|
*/
|
|
rename(workspaceId: WorkspaceId, title: string): Promise<WorkspaceView>
|
|
/**
|
|
* Delete a Workspace (its sessions fall back to the unaccounted group).
|
|
* @param workspaceId - target workspace.
|
|
*/
|
|
delete(workspaceId: WorkspaceId): Promise<void>
|
|
/**
|
|
* Move an accounted session within/into a Workspace's ordered list.
|
|
* @param workspaceId - target workspace.
|
|
* @param sessionId - accounted session to move.
|
|
* @param beforeSessionId - accounted anchor to insert before; omitted appends.
|
|
* @returns the updated Workspace view.
|
|
*/
|
|
insertSessionBefore(workspaceId: WorkspaceId, sessionId: SessionId, beforeSessionId?: SessionId): Promise<WorkspaceView>
|
|
/**
|
|
* Archive a session into the registry-global set (hidden from grouping
|
|
* surfaces; session log and accounting slot remain). Archiving the current
|
|
* session clears the selection into the New Session view state.
|
|
* @param sessionId - session to archive.
|
|
*/
|
|
archiveSession(sessionId: SessionId): Promise<void>
|
|
}
|