Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .ai/contexts/project-delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,27 @@ DIRECTORY_SCAN_MS. Numeric limits below are code bounds, not measured latency.
grouped scope, foreign rejection, metadata/search deletion, changing ownership, producer fences,
legacy receipts and remote identity. Physical folder/transcript removal is separate.

## Deletion dialog and worktree history

- `confirmAndDeleteProjectFolder` shows one explanatory message whenever a capabilities plan
opens the dialog, refused plans included (Confirm disabled); a failure without a plan never
opens it. The message has no branch for discard/archive, Git worktree inventory or folder
selection, so its worktree sentence is conditional on ownership: "Worktree session metadata
grouped under this project is discarded or archived with it. Independently owned worktree
history is kept in Switchboard." Changing a checkbox requests a fresh plan.
- Delete ownership (distinct from the visibility rules above): local inventory groups the
`.worktrees`, `.claude-worktrees`, `.claude/worktrees` and `.work-files/worktrees` layouts
under the project when the ancestor directory exists (`resolveWorktreePath` checks only that
the directory exists, not that it is a Git repository), nested layouts with missing
intermediate worktrees included. Such groups are selected even without Git worktree rows;
Discard erases their session metadata, leaving it unchecked archives it, and the disk-folder
choice does not change which metadata is selected. A verified group with a distinct owner and
a matching `parentProjectPath` is `kept` and gets no writer units; histories outside these
layouts stay outside the manifest. Remote ownership is exact host/path.
- Tests: test/dom-project-delete-history.test.js checks the visible prose against real planner
previews (both metadata choices, selected/unselected folders, grouped, independently owned
and absent histories); discovery ports and IPC transport are fixtures.

## Superseded previews (#1106)

- One pending preview per webContents/canonical host-project pair: replacement aborts
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ What changes for you in each release of Switchboard. How to write an entry: [doc
- Quit and window close no longer ask for confirmation when only idle Claude sessions are open, startup restore is enabled and Switchboard tracks no running background work; unsaved file edits still ask, and Restart to update keeps its background option. (#1023)

### Fixed
- The project deletion dialog now explains that worktree session metadata grouped under the project is discarded or archived with it, while independently owned worktree history is kept. (#1374)
- The **Shell** button opens a shell again for a session whose shell you closed while it was still starting and whose session id then changed, as when a fork is re-keyed; it used to stay unable to open one until the window was reloaded. (#1384)
- Forking a Claude session requests the tab’s allocated id and gives its transcript 10 seconds to appear before considering another file. The fallback also handles copied compacted history beyond 8 MiB, within a bounded search; identical foreign forks remain ambiguous after the grace period. (#1350)
- Moving a session to the background after choosing **Stop the old job** now waits for evidence that the old job ended. If the worker is still running at the deadline, the session stays in the foreground; if its end cannot be confirmed, Switchboard explains that uncertainty. (#1340)
Expand Down
7 changes: 5 additions & 2 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,11 @@ includes its host alias; unarchiving it does not register a local schedule.
**Delete Project** opens the same preview as **Delete** on the project header.
Choose whether to discard session names, pins and app metadata (initially off)
and project settings (initially on when available). Unselected session metadata
is archived. Shared path-only settings cannot be deleted. Only confirmed,
available choices are remembered; Cancel changes nothing.
is archived. Worktree session metadata grouped under the project follows that
choice too, whether or not you remove the worktree folder. Independently owned
worktree history is kept in Switchboard. Shared path-only settings cannot be
deleted. Only confirmed, available choices are remembered; Cancel changes
nothing.

The preview shows the full host and path, counts, and expandable complete
targets and effects. Project files, schedules, memory and `.work-files` stay on
Expand Down
2 changes: 1 addition & 1 deletion public/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ async function confirmAndDeleteProjectFolder(project, button, { onUnavailable, o
message: [`${project.remoteAlias || 'Local'} — ${capabilities.plan.project.projectPath}`,
'Choose which app data to discard. Retained session metadata is archived.',
'Kept on disk: the project folder. Only individually selected linked worktree folders are removed, including their ignored files. All remote server files are kept.',
'Other transcripts, schedules, memory and .work-files stay on disk. Linked worktree history is kept in Switchboard.',
'Other transcripts, schedules, memory and .work-files stay on disk. Worktree session metadata grouped under this project is discarded or archived with it. Independently owned worktree history is kept in Switchboard.',
'Kept schedules may reactivate when you add the project again. Retained transcripts may restore their titles.',
...(capabilities.plan.warnings || []).filter(row => row.code === 'WORKTREE_UNAVAILABLE').map(row => 'Worktree inventory unavailable: ' + row.error)],
choices: [
Expand Down
94 changes: 94 additions & 0 deletions test/dom-project-delete-history.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { setupSidebarDom, makeSampleProject } = require('./dom-setup');
const flush = () => new Promise(resolve => setImmediate(resolve));

function setup(t) {
const ctx = setupSidebarDom();
t.after(() => ctx.destroy());
ctx.evalPublic('setting-defaults.js');
const w = ctx.window, p = makeSampleProject({ folder: 'repo' });
w.api.platform = 'win32';
w.cachedAllProjects = w.cachedProjects = [p];
const calls = { preview: [] };
return { ...ctx, w, p, calls,
start: () => w.confirmAndDeleteProjectFolder(p),
confirm: () => ctx.document.querySelector('.choice-dialog-confirm'),
cancel: () => ctx.document.querySelector('.choice-dialog-cancel')?.click(),
};
}

for (const layout of ['.worktrees', '.claude-worktrees', '.claude/worktrees', '.work-files/worktrees', 'external', 'independent-child', 'none', 'grouped-without-git-row']) {
for (const discard of [false, true]) test(`project deletion explains worktree history: ${layout}, discard=${discard}`, async t => {
const { createProjectDeletePlanner } = require('../src/main/projects/project-delete-plan');
const { groupedOwner } = require('../src/main/projects/project-delete-owner');
const dir = fs.realpathSync(fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'delete-wording-')));
t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
const repo = path.join(dir, 'repo');
fs.mkdirSync(repo);
const h = setup(t);
h.p.projectPath = repo;
const project = groupedOwner({ alias: null, projectPath: repo });
const grouped = !['external', 'independent-child', 'none'].includes(layout);
const childPath = path.join(grouped ? repo : dir, grouped
? (layout === 'grouped-without-git-row' ? '.worktrees' : layout) : 'separate', 'child');
const child = groupedOwner({ alias: null, projectPath: childPath });
const group = (owner, id) => ({ ...owner, folderKey: id, runtime: 'claude', verified: true });
const member = (owner, id) => ({ ...owner, id, conversationId: id, partId: id, folderKey: id,
runtime: 'claude', cwd: owner.projectPath, verified: true, indexed: true, present: true,
liveness: { state: 'stopped', source: 'descriptor' } });
const groups = [group(project, h.p.folder)];
const members = [member(project, h.p.folder)];
if (layout !== 'none') {
groups.push({ ...group(child, 'child'), ...(layout === 'independent-child' ? { parentProjectPath: repo } : {}) });
members.push(member(child, 'child'));
}
const worktrees = ['none', 'grouped-without-git-row'].includes(layout) ? []
: [{ path: childPath, branch: 'topic', removable: true, fingerprint: 'disk', sessions: [], dirty: [] }];
const planner = createProjectDeletePlanner({
waitForIndex: async () => {},
readSnapshot: async () => ({ complete: true, initialScanComplete: true, revision: '1', declaredHosts: [],
projects: [{ ...project, folderKeys: [h.p.folder] }] }),
discoverOwnership: async () => ({ complete: true, groups, members, candidates: [] }),
discoverSchedules: async () => ({ complete: true, schedules: [], candidates: [] }),
readRuntimeState: async () => ({ complete: true, tabs: [], jobs: [], candidates: [] }),
readRevision: async () => '1',
worktrees: { preview: async () => worktrees },
});
let lastPlan;
h.w.api.previewProjectDelete = async request => {
h.calls.preview.push(request);
const reply = await planner.preview(JSON.parse(JSON.stringify(request)));
lastPlan = reply.plan;
return { ...reply, token: 'wording-preview' };
};
h.w.localStorage.setItem('deleteProject.sessions', discard ? '1' : '0');
const pending = h.start();
try {
for (let i = 0; i < 100 && (!h.confirm() || h.confirm().disabled); i++) await flush();
assert.ok(h.confirm() && !h.confirm().disabled, 'the real planner must produce a confirmable dialog: ' + h.document.body.textContent);
assert.equal(lastPlan.categories.sessions.effect, discard ? 'discard' : 'archive');
assert.equal(lastPlan.members.some(row => row.id === 'child'), grouped);
if (layout === 'independent-child') assert.equal(lastPlan.groups.find(row => row.folderKey === 'child').effect, 'kept');
for (const selected of worktrees.length ? [false, true] : [false]) {
if (selected) {
h.document.querySelector('[data-choice-id="worktree:0"]').click();
for (let i = 0; i < 100 && h.confirm().disabled; i++) await flush();
assert.equal(h.confirm().disabled, false);
assert.equal(lastPlan.worktrees[0].selected, true);
assert.equal(lastPlan.members.some(row => row.id === 'child'), grouped, 'disk selection does not select metadata');
}
const dialog = h.document.querySelector('.choice-dialog').cloneNode(true);
dialog.querySelectorAll('details').forEach(node => node.remove());
assert.match(dialog.textContent, /Worktree session metadata grouped under this project is discarded or archived with it\./,
'visible wording must explain that grouped worktree metadata follows the project choice');
assert.match(dialog.textContent, /Independently owned worktree history is kept in Switchboard\./);
assert.doesNotMatch(dialog.textContent, /Linked worktree history is kept in Switchboard\./);
assert.match(dialog.textContent, /Other transcripts, schedules, memory and \.work-files stay on disk\./);
}
} finally { h.cancel(); await pending; }
});
}
2 changes: 1 addition & 1 deletion test/fixtures/theme-dark.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"cssHash": "c1180992aaefa3142b645b1441a6d827be5874ac6da33af2c703713e7715f39a",
"inline": {
"sidebar.js": "2a6e5970804b3b476808185da71d1ea57c85882e34e37bf9f0a2a6d15c87f491",
"sidebar.js": "b04a503b6c8ef6d41ef492ff9595a2c3e83258f907defa20a9863c8172338e67",
"jsonl-viewer.js": "d74bf42a3c33ba87b8f4cf9441df0814380890a6ca0c239f3479207f36c73e2a",
"viewer-toolbar.js": "a8a83a1c55716a17a5b53defbdb7b28344e0796096b5e738b9d1cdea1113cca6"
}
Expand Down
Loading