revert: restore the reviewer-approved tree (97a192d7b)

ZiyaZhang approved 97a192d7b; the subsequent bot-review rounds (7-24)
landed after that approval and were not requested by a human reviewer.
This commit restores the approved tree verbatim as a forward commit
(pushed history stays intact). git diff 97a192d7b is empty.
This commit is contained in:
creatixchu
2026-07-30 09:22:16 +08:00
parent 53e85101b9
commit b46dcb16cb
24 changed files with 149 additions and 771 deletions

View File

@@ -1016,10 +1016,6 @@ export function createFixtureApi(options: FixtureOptions = {}): ApiProxy {
// same tree the browse primitives serve).
pickDirectory: request => ok(request, { path: `${FIXTURE_HOME}/Documents/project` }),
listDirectory: (request) => {
// The fixture accepts CANONICAL paths only: a decorated input
// (./, //, ..) misses the tree map and reads as unreadable, where
// the real backend resolve()s it first. The keyless lanes drive
// canonical paths, so the divergence stays out of transcripts.
const target = request.payload.path ?? FIXTURE_HOME
const children = childrenOf(target)
if (children === undefined) {

View File

@@ -48,10 +48,7 @@ export interface IWorkspaces {
* 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, in the shape the wire
* `HostApi.createDirectory` contracts: verbatim equal to the child's
* `entries[].path` in the parent's next listing (the browser anchors a
* create landing's selection on that equality).
* @returns the created directory's absolute path.
*/
createDirectory(path: string, name: string): Promise<string>
/**

View File

@@ -208,8 +208,7 @@ export class WorkspacesService implements IWorkspaces {
* 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, in the shape
* `IWorkspaces.createDirectory` contracts.
* @returns the created directory's absolute path.
*/
async createDirectory(path: string, name: string): Promise<string> {
const response = await this.api.host.createDirectory({ path, name })

View File

@@ -142,18 +142,13 @@ export class TestWorkspaces implements IWorkspaces {
* Browse child creation (recorded). The default joins parent and name.
* @param path - absolute existing parent directory.
* @param name - single path segment.
* @returns the created directory's absolute path, in the shape
* `IWorkspaces.createDirectory` contracts.
* @returns the created directory's absolute path.
*/
async createDirectory(path: string, name: string): Promise<string> {
this.calls.push({ method: 'createDirectory', args: [path, name] })
const stub = this.stubs.get('createDirectory')
if (stub !== undefined) return await (stub(path, name) as Promise<string>)
// Join in the parent's own separator flavor (a canonical parent ends
// with one only when it is a bare root), so the contract's verbatim
// equality holds for POSIX and Windows fixture trees alike.
const sep = path.includes('\\') ? '\\' : '/'
return path.endsWith(sep) ? `${path}${name}` : `${path}${sep}${name}`
return `${path}/${name}`
}
/**

View File

@@ -329,21 +329,12 @@ describe('workspaces', () => {
await expect(runtime.workspaces.listDirectory()).resolves.toMatchObject({ path: '/home/test', entries: [] })
await expect(runtime.workspaces.listDirectory('/home/test')).resolves.toMatchObject({ path: '/home/test' })
await expect(runtime.workspaces.createDirectory('/home/test', 'fresh')).resolves.toBe('/home/test/fresh')
// Canonical join in the parent's own separator flavor: bare roots do
// not double the separator, Windows parents keep backslashes (the
// IWorkspaces contract's verbatim entries[].path equality).
await expect(runtime.workspaces.createDirectory('/', 'top')).resolves.toBe('/top')
await expect(runtime.workspaces.createDirectory('C:\\', 'top')).resolves.toBe('C:\\top')
await expect(runtime.workspaces.createDirectory('C:\\Users', 'Alice')).resolves.toBe('C:\\Users\\Alice')
// The recorded signal seat mirrors the production face (undefined here;
// cancellation tests pass and observe a real one).
expect(runtime.workspaces.calls).toEqual([
{ method: 'listDirectory', args: [undefined, undefined] },
{ method: 'listDirectory', args: ['/home/test', undefined] },
{ method: 'createDirectory', args: ['/home/test', 'fresh'] },
{ method: 'createDirectory', args: ['/', 'top'] },
{ method: 'createDirectory', args: ['C:\\', 'top'] },
{ method: 'createDirectory', args: ['C:\\Users', 'Alice'] },
])
// Stubs replace the defaults like every sibling method.
const listing = { path: '/x', home: '/x', crumbs: [], entries: [] }