|
@@ -7,7 +7,6 @@
|
|
|
|
|
|
|
|
import { randomUUID } from 'node:crypto'
|
|
import { randomUUID } from 'node:crypto'
|
|
|
import { stat } from 'node:fs/promises'
|
|
import { stat } from 'node:fs/promises'
|
|
|
-import { basename } from 'node:path'
|
|
|
|
|
import { Context, Service } from '@deepseek-ai/cordis'
|
|
import { Context, Service } from '@deepseek-ai/cordis'
|
|
|
import type { SessionHeader, SessionId } from '@deepseek-ai/dsh-session'
|
|
import type { SessionHeader, SessionId } from '@deepseek-ai/dsh-session'
|
|
|
import type {} from '@deepseek-ai/dsh-session-persistence'
|
|
import type {} from '@deepseek-ai/dsh-session-persistence'
|
|
@@ -16,7 +15,7 @@ import { WorkspaceEntity } from './entity.ts'
|
|
|
import type { WorkspaceEntityHost } from './entity.ts'
|
|
import type { WorkspaceEntityHost } from './entity.ts'
|
|
|
|
|
|
|
|
export { WorkspaceMoveInvalidError } from './entity.ts'
|
|
export { WorkspaceMoveInvalidError } from './entity.ts'
|
|
|
-import { realpathNormalize } from './paths.ts'
|
|
|
|
|
|
|
+import { defaultWorkspaceTitle, realpathNormalize } from './paths.ts'
|
|
|
import { workspaceDomainSpec } from './spec.ts'
|
|
import { workspaceDomainSpec } from './spec.ts'
|
|
|
import type { WorkspaceDomainState, WorkspaceRecord } from './spec.ts'
|
|
import type { WorkspaceDomainState, WorkspaceRecord } from './spec.ts'
|
|
|
import type { Workspace, WorkspaceId as WorkspaceIdBrand } from './types.ts'
|
|
import type { Workspace, WorkspaceId as WorkspaceIdBrand } from './types.ts'
|
|
@@ -140,13 +139,13 @@ export class WorkspaceRegistry extends Service {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Create or reuse a workspace for an existing directory. The path is
|
|
|
|
|
- * canonicalized through `fs.realpath`; a nonexistent path rejects with the
|
|
|
|
|
- * original error and a non-directory rejects. Repeated calls for the same
|
|
|
|
|
- * canonical path return the existing entity without changing its title.
|
|
|
|
|
|
|
+ * Create or reuse a workspace for an existing directory. The fully qualified
|
|
|
|
|
+ * path is canonicalized through `fs.realpath`; a relative, nonexistent, or
|
|
|
|
|
+ * non-directory path rejects. Repeated calls for the same canonical path
|
|
|
|
|
+ * return the existing entity without changing its title.
|
|
|
* A newly created workspace is prepended to the durable registry order.
|
|
* A newly created workspace is prepended to the durable registry order.
|
|
|
* Different canonical paths may share a display title.
|
|
* Different canonical paths may share a display title.
|
|
|
- * @param path - Existing directory to own, in any path spelling.
|
|
|
|
|
|
|
+ * @param path - Existing directory to own, in a fully qualified path spelling.
|
|
|
* @param title - Display title used only when a new record is created.
|
|
* @param title - Display title used only when a new record is created.
|
|
|
* @returns the existing or newly durable workspace.
|
|
* @returns the existing or newly durable workspace.
|
|
|
*/
|
|
*/
|
|
@@ -271,7 +270,7 @@ export class WorkspaceRegistry extends Service {
|
|
|
* Resolve by canonical directory path without creating or mutating a
|
|
* Resolve by canonical directory path without creating or mutating a
|
|
|
* workspace. A missing path rejects during `realpath`; an existing unowned
|
|
* workspace. A missing path rejects during `realpath`; an existing unowned
|
|
|
* directory returns `undefined`.
|
|
* directory returns `undefined`.
|
|
|
- * @param path - Existing directory path in any spelling.
|
|
|
|
|
|
|
+ * @param path - Existing directory path in a fully qualified spelling.
|
|
|
* @returns the workspace owning the canonical path, when one exists.
|
|
* @returns the workspace owning the canonical path, when one exists.
|
|
|
*/
|
|
*/
|
|
|
async resolveByPath(path: string): Promise<Workspace | undefined> {
|
|
async resolveByPath(path: string): Promise<Workspace | undefined> {
|
|
@@ -287,7 +286,7 @@ export class WorkspaceRegistry extends Service {
|
|
|
if (entity.path === canonical) return entity
|
|
if (entity.path === canonical) return entity
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const workspaceName = title ?? basename(canonical)
|
|
|
|
|
|
|
+ const workspaceName = title ?? defaultWorkspaceTitle(canonical)
|
|
|
const table = this.requireTable()
|
|
const table = this.requireTable()
|
|
|
const state = this.requireState()
|
|
const state = this.requireState()
|
|
|
const id = WorkspaceId(randomUUID())
|
|
const id = WorkspaceId(randomUUID())
|
|
@@ -459,7 +458,7 @@ export class WorkspaceRegistry extends Service {
|
|
|
const createdAt = new Date(group.newestAt).toISOString()
|
|
const createdAt = new Date(group.newestAt).toISOString()
|
|
|
const record: WorkspaceRecord = {
|
|
const record: WorkspaceRecord = {
|
|
|
path: group.path,
|
|
path: group.path,
|
|
|
- title: basename(group.path),
|
|
|
|
|
|
|
+ title: defaultWorkspaceTitle(group.path),
|
|
|
sessionIds,
|
|
sessionIds,
|
|
|
createdAt,
|
|
createdAt,
|
|
|
updatedAt: createdAt,
|
|
updatedAt: createdAt,
|