fix(host,client): review round 24 — close-edge facts synced; wire-hop pointer; platform-flavored double join; loading reset

This commit is contained in:
creatixchu
2026-07-30 03:38:43 +08:00
parent df313b7531
commit 53e85101b9
5 changed files with 26 additions and 18 deletions

View File

@@ -149,8 +149,11 @@ export class TestWorkspaces implements IWorkspaces {
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>)
// Canonical join: a bare-root parent must not double the separator.
return path.endsWith('/') ? `${path}${name}` : `${path}/${name}`
// 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}`
}
/**

View File

@@ -329,9 +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: a bare-root parent yields /top, not //top (the
// 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([
@@ -339,6 +342,8 @@ describe('workspaces', () => {
{ 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: [] }