Skip to content
Open
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
49 changes: 45 additions & 4 deletions .ai/contexts/ipc-bridge.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Context: ipc-bridge

## Archived projects manager (#863 slices 2–3, #1167)
## Archived projects manager (#863 slices 2–4, #1167, #1171)

`settings-panel.js` mounts `renderArchivedProjects` from `archived-manager.js`
after the shared renderer helpers, dialogs, notices and sidebar controller.
Expand All @@ -9,14 +9,15 @@ hidden entries/kinds, archive timestamps, cached projects and
the working remote-host list. Host edits update labels without saving. The manager
groups Local first, then configured hosts in order, then unknown aliases; it never
collapses a worktree entry into its repository. The filter, selections and folds
are local to the mounted list. Filtering clears selections outside the results.
are local to the mounted list. Selection survives filtering and accepted snapshots;
only entries no longer archived are removed from the checked set.
Counts exclude deleted entries. Missing timestamps and unknown session counts
are omitted, never invented. Names use `shortProjectPath` (last two segments).

Unarchive uses the exact stored entry via `unarchiveProject` and/or `unarchiveFolder`, sequentially for a
bulk action. Successful entries leave the list, reload projects and get one B8
ten-second Undo notice for project archives only. Folder restores use an informational
notice; mixed restores explain that Undo only re-archives projects and that folders
ten-second Undo notice for project archives and sessions. Folder-only restores use an informational
notice; mixed restores explain that Undo re-archives sessions and project archives and that folders
must be archived again through Archive folder. Undo calls `archiveProjectSettings(path, folderKey)` and
reads the new writer timestamp. After reopening Settings, Undo refreshes the
currently mounted manager; a pending action does not consume its Undo notice.
Expand Down Expand Up @@ -63,6 +64,46 @@ Native controls provide Tab navigation; Enter/Space folds host groups and Escape
clears the filter. ResizeObserver alone controls the 720px stacked layout and
480px search disclosure. New surfaces use existing dark chrome tokens.

Slice 4 adds top-level archived sessions from `cachedAllProjects`, grouped by
host-qualified project path, with twelve initially visible rows per group.
Select-all covers the entire filtered group, including its collapsed tail.
Session keys are separate from project entry keys. Names use `cleanDisplayName`;
attribute values also escape quotes. Transcript uses `showJsonlViewer` without
opening a terminal. Show in sidebar enables the archive filter, clears competing
filters and search, cancels the deferred search redraw, expands the target's
ancestors and focuses the row. The archive-filter footer uses `archivedCounts`
over the all-project snapshot and the union of hidden project entries and
`archivedProjects` folder keys, excluding deleted entries and counting combined
archives once, just like the page. `loadProjects` supplies folder records as the
fourth `hiddenSettings` value, so folder changes also invalidate the sidebar render
key. The footer uses singular session and project-or-folder labels for one item.
Project row attributes escape quotes as session rows do. Settings owns the
description above the manager, without adding a redundant section title.
Entirely empty archives show only the shared "Nothing is archived" explanation;
the per-group explanations remain for a missing group when another has items.

The shared bulk action runs project/folder entries first, then
`persistSessionArchive(session, 0)`. Its optional error callback collects failures
for one `appAlert` rather than producing separate sidebar error notices. One
success notice reverses successful projects and sessions only; session Undo uses
`persistSessionArchive(session, 1)`. Folder-only restore still has no Undo.

The accepted `loadProjects` snapshot calls `window.refreshArchivedManager`, which
does no manager archive read when the Settings viewer is closed or its Archived
page is hidden. A skipped refresh marks the manager dirty; selecting Archived
refreshes that mounted manager from `cachedAllProjects`, updating its rows and nav
count. Refresh consumes the dirty flag, so revisiting an unchanged page does not
read settings again. The sidebar snapshot still reads folder archives for its count.
`loadProjects` starts the global and folder-archive settings reads together, then
checks generation obsolescence before continuing to the terminal snapshot.
Refresh reads folder records and preserves filter, selection, group expansion,
working host labels and row-control focus. A version counter rejects stale reads;
refreshes during an action are deferred until the action and any error alert end.
`projects-changed` also schedules a reload when Archived is visible above another
sidebar tab. Closed settings retain the normal deferred reload behaviour.
Tests: `dom-archived-sessions.test.js`, plus the existing archived manager,
session/folder Undo, archive-all and row-action error suites.

Folder and project archives with the same exact entry share one row with both badges.
Folder dates accept the stored ISO timestamp; metadata includes the number of disabled
schedules. Deleted entries stay excluded. Combined restoration clears the project
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ What changes for you in each release of Switchboard. How to write an entry: [doc
### Changed
- Project Settings → This project shows the project's path, host and number of sessions, including archived ones, with Archive Project and Delete Project in a separate Danger zone. (#863)
- After a restart, Switchboard re-reads only Claude Code transcripts changed since the previous run. Codex history is still re-read in full. (#1144)
- Settings → Archived groups project and folder archives by host, shows their paths and archive dates, and filters by name, path or host. Folder archives show their disabled schedule count and can be restored after Undo expires, keeping schedules off until you choose Turn back on. Restore one or several projects with Undo, or delete an archived project through the existing preview without restoring it first. Worktree entries whose repository is gone can be deleted; entries still grouped under a repository explain that you can delete their repository instead. (#863, #1167)
- Settings → Archived groups project and folder archives by host, shows their paths and archive dates, and filters by name, path or host. Archived sessions are listed by project: open a transcript, or restore sessions and projects together with one Undo. With the archive filter on, the sidebar links to the page. Folder archives show their disabled schedule count and can be restored after Undo expires, keeping schedules off until you choose Turn back on. Restore one or several projects with Undo, or delete an archived project through the existing preview without restoring it first. Worktree entries whose repository is gone can be deleted; entries still grouped under a repository explain that you can delete their repository instead. (#863, #1167, #1171)
- Codex sessions run non-interactively by a program (`codex exec`: scripted reviews and fixes) are now left out of the sidebar and grid like Claude Agent SDK sessions, under the same **Hide SDK-launched Sessions** setting. They still count in the heatmap and are found by search; the ones you have open stay listed. Codex sessions already indexed are re-checked once at the next start. (#1145)

### Fixed
Expand Down
15 changes: 15 additions & 0 deletions docs/session-browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,21 @@ succeeds. Since #815, a scan worker that fails to start shows `Scan failed: <err

## Pin and archive

**Settings → Archived** lists archived top-level sessions by project and host.
Rows show their name, modified date, message count and size when available;
each group shows twelve rows followed by **Show N more**. **Transcript** opens
the read-only transcript. **Show in sidebar** clears conflicting filters,
enables the archive filter and reveals the row.

Select sessions and project or folder archives together, then **Unarchive selected (N)**.
Project and folder entries restore first, then sessions. One notice offers
**Undo** for restored sessions and project archives; folder archives must be
archived again with **Archive folder**. Failed items stay selected for retry.
Sessions belonging to an archived project appear after that project is restored.
The filter and checked items survive project updates. While the sidebar archive
filter is on, its footer counts archived top-level sessions and archived project
entries and links to this page with **Manage**. Deleted projects are excluded.

Name, pin and archive apply to the whole conversation, including compaction
mirrors, rolled continuation parts and a live background row. It stays listed while any part is
unarchived and is pinned when any part is pinned. Its name is the newest user
Expand Down
9 changes: 7 additions & 2 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,16 @@ Space. Select rows or a host group to unarchive several projects together.
**Unarchive** applies immediately. Project restores offer a ten-second **Undo**;
folder restores keep sessions archived and schedules off, with **Turn back on**
offered at the top of the restored group. Re-archive a folder with **Archive folder**;
in a mixed restore, Undo re-archives projects only. A combined row restores its
in a mixed restore, Undo re-archives sessions and project archives only. A combined row restores its
project archive first, then its folder archive. The row's
**More actions** menu offers **Copy path** and **Delete project…**. Delete opens
the same preview and confirmation as the sidebar, without unarchiving first.
Archived session management will be added separately.
Archived top-level sessions appear below, grouped by project and host, with dates,
message counts and available file sizes. Groups show twelve rows and **Show N more**.
Each row offers **Unarchive**, **Transcript**, and **Show in sidebar** in its menu.
Selection is shared with projects: **Unarchive selected (N)** restores project
entries first, then sessions, with one notice and Undo. The filter and checked
items survive project updates. Sessions of archived projects appear after Unarchive.

### Advanced

Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const ACTIVITY_CLASS_MESSAGE = 'Only public/session-activity-dom.js may write .c
// public/sidebar.js (and equivalents). Kept readonly so reassignment
// from another file gets flagged.
const rendererCrossFileGlobals = {
activeArchivedProjectsManager: 'readonly',
codexQuotaEnabled: 'readonly',
projectDeletionRestoreTargets: 'readonly',
projectDeletionKey: 'readonly',
Expand Down
32 changes: 29 additions & 3 deletions public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,27 @@ window.api.onCliBusyState((sessionId, busy) => {
setActivity(sessionId, busy, 'onCliBusyState');
});

function showArchivedSessionInSidebar(session) {
window.closeSettingsViewer();
document.querySelector('.sidebar-tab[data-tab="sessions"]')?.click();
showArchived = true;
showStarredOnly = showRunningOnly = showTodayOnly = false;
document.getElementById('archive-toggle')?.classList.add('active');
for (const id of ['star-toggle', 'running-toggle', 'today-toggle']) document.getElementById(id)?.classList.remove('active');
clearSearch();
if (clearRenderRaf) { cancelAnimationFrame(clearRenderRaf); clearRenderRaf = null; }
refreshSidebar({ resort: true, keepFocus: true });
const row = sessionItemEl(session.sessionId, sidebarContent);
if (!row) return;
for (let el = row.parentElement; el && el !== sidebarContent; el = el.parentElement) {
if (el.classList.contains('slug-group')) el.classList.remove('collapsed');
if (el.classList.contains('sessions-older') && el.style.display === 'none') el.previousElementSibling?.click();
if (el.matches('.project-sessions, .worktree-sessions')) el.previousElementSibling?.classList.remove('collapsed');
}
row.tabIndex = -1; row.focus(); row.scrollIntoView?.({ block: 'nearest' });
}
window.showArchivedSessionInSidebar = showArchivedSessionInSidebar;

// --- Single entry point for all sidebar renders ---
// resort=true: re-sort items by priority+time (use for user-initiated actions)
// resort=false (default): preserve existing DOM order, new items go to top
Expand Down Expand Up @@ -2267,7 +2288,9 @@ async function loadProjects({ resort = false } = {}) {
const response = await window.api.getProjects('both');
if (obsolete()) return state.outcome;
const { defaultProjects, allProjects } = response;
const globalSettings = await window.api.getSetting('global');
const [globalSettings, folderArchives] = await Promise.all([
window.api.getSetting('global'), window.api.getSetting('archivedProjects'),
]);
if (obsolete()) return state.outcome;
let activeTerminals;
try { activeTerminals = await window.api.getActiveTerminals(); } catch {}
Expand All @@ -2280,6 +2303,7 @@ async function loadProjects({ resort = false } = {}) {
setRemoteHostLabels(globalSettings?.remoteHosts);
cachedProjects = defaultProjects;
cachedAllProjects = allProjects;
window.refreshArchivedManager?.(cachedAllProjects, globalSettings)?.catch(error => console.warn('[switchboard] archived refresh failed', error));
window.clearReappearedProjectDeletionTargets?.(job.generation);
const newerPending = state.latest !== job && state.latest.pending;
loadingStatus.style.display = newerPending ? '' : 'none';
Expand Down Expand Up @@ -2359,7 +2383,7 @@ async function loadProjects({ resort = false } = {}) {
}
if (typeof observeSessionProjection === 'function') observeSessionProjection({ generation: job.generation, cause: 'projects', provenance: response.projection });
refreshSidebar({ resort: job.resort, skipUnchanged: true,
hiddenSettings: [globalSettings?.hiddenProjects, globalSettings?.hiddenProjectKinds, globalSettings?.hiddenProjectScopes] });
hiddenSettings: [globalSettings?.hiddenProjects, globalSettings?.hiddenProjectKinds, globalSettings?.hiddenProjectScopes, folderArchives || {}] });
renderDefaultStatus();
return state.outcome;
};
Expand Down Expand Up @@ -3279,7 +3303,9 @@ window.api.onProjectsChanged(payload => {
if (activeTab === 'schedules' && payload?.cause?.some(cause => ['archive', 'project-added', 'project-deleted', 'project-remap', 'worktree-deleted', 'watcher', 'session-exit', 'session-attach'].includes(cause))) queueSchedulesReload();
// Debounce to avoid rapid re-renders during bulk changes
if (projectsChangedTimer) clearTimeout(projectsChangedTimer);
if (activeTab !== 'sessions') {
const archivedPage = document.getElementById('settings-page-archived');
const archivedVisible = archivedPage && !archivedPage.hidden && document.getElementById('settings-viewer')?.style.display !== 'none';
if (activeTab !== 'sessions' && !archivedVisible) {
projectsChangedWhileAway = true;
return;
}
Expand Down
Loading
Loading