feat: workspace fence toggle (workspaceFence pref + one-click off in error surfaces)
- New persisted built-in pref workspaceFence (default true) under the files card's secondary settings modal; host reads it per request via the settings seam (fenceEnabledOf — absent/malformed stays ON). - ensureWorkspacePath/ensureWorkspaceWritePath gain a fence param: disarmed skips the containment assert but keeps realpath resolution; wired through fs.tree/fs.read/fs.write, the media + html routes, and the upload path (writeWorkspaceUpload fence input). - Editor load failures and file-tree level errors show the localized reason plus a one-click global off (FenceErrorNotice) that flips the pref, adopts it into the store, and auto-retries the failed operation (reloadSeq / retryDir) — the raw wire text is never shown. - GitView's two client-side pre-checks (hidden open action + no-op defense) respect the pref; store threaded through TreePanel/FileTree. - i18n: 4 new keys across all 21 dictionaries; tests: fence-off route coverage, prefs parsing, schema default, editor toggles list; docs: guide §8/§8.1 + plans/2026-08-29 design record.
This commit is contained in:
1 parent
2088ef6891
commit
a9353ce627
44 files changed
+391
-38
No files matched your search
@@ -943,6 +943,7 @@ describe('side card settings routes', () => {
|
||||
terminalFontSize: 13,
|
||||
interceptOpenPath: true,
|
||||
editorExplorer: false,
|
||||
workspaceFence: true,
|
||||
terminalShell: '',
|
||||
terminalShellArgs: '',
|
||||
titleBarCompat: false,
|
||||
@@ -972,6 +973,34 @@ describe('side card settings routes', () => {
|
||||
expect(view.revision).toBe(1)
|
||||
})
|
||||
|
||||
it('disarms the workspace fence for the fs routes when the pref is off', async () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'dsh-sidebar-fence-off-'))
|
||||
const workspace = join(root, 'workspace')
|
||||
const outside = join(root, 'outside')
|
||||
mkdirSync(workspace)
|
||||
mkdirSync(outside)
|
||||
writeFileSync(join(outside, 'secret.txt'), 'global instructions')
|
||||
try {
|
||||
const route = mountWithSettings(createFakeSettings())
|
||||
// Default (fence on): the outside read is refused as usual…
|
||||
const refused = await invoke(route, 'fs.read', { sessionId: 'fence', cwd: workspace, path: join(outside, 'secret.txt') })
|
||||
expect(refused).toMatchObject({ ok: false, error: { code: 'forbidden' } })
|
||||
// …then the settings-page switch (or the fence notice's one-click off)
|
||||
// disarms every fs route for paths outside the workspace.
|
||||
const off = await invoke(route, 'settings.update', { patch: { workspaceFence: false } })
|
||||
expect(off.ok).toBe(true)
|
||||
const read = await invoke(route, 'fs.read', { sessionId: 'fence', cwd: workspace, path: join(outside, 'secret.txt') })
|
||||
expect(read).toMatchObject({ ok: true, value: { kind: 'text', content: 'global instructions' } })
|
||||
const tree = await invoke(route, 'fs.tree', { sessionId: 'fence', cwd: workspace, path: outside })
|
||||
expect(tree).toMatchObject({ ok: true })
|
||||
const write = await invoke(route, 'fs.write', { sessionId: 'fence', cwd: workspace, path: join(outside, 'written.txt'), content: 'ok' })
|
||||
expect(write).toMatchObject({ ok: true })
|
||||
expect(readFileSync(join(outside, 'written.txt'), 'utf8')).toBe('ok')
|
||||
} finally {
|
||||
rmSync(root, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
|
||||
it('refuses a stale write with settings-conflict (409)', async () => {
|
||||
const route = mountWithSettings(createFakeSettings())
|
||||
await invoke(route, 'settings.update', { patch: { openByDefault: false } })
|
||||
|
||||
Reference in new issue
Block a user