diff --git a/.ai/contexts/changes-view.md b/.ai/contexts/changes-view.md index 47655c01a..bfbccd247 100644 --- a/.ai/contexts/changes-view.md +++ b/.ai/contexts/changes-view.md @@ -859,6 +859,70 @@ The split uses `createSplitter` (`public/splitter.js`, shared with the panel's s Switching rows is an exit like Back, the tab toggle and the panel's close button: it asks `confirmDiscardChangesEdits` when the buffer is dirty and returns without touching anything if the answer is no. Clicking the row that is already open is not a switch and asks nothing. The row cap (`MAX_CHANGES_ROWS`) and the idle refresh are unchanged by the layout — a refresh rebuilds the list while the editor keeps its instance and its DOM node, which the editor-host MutationObserver test pins with the list now rebuilding alongside it. +### List or tree + +The list has two views, switched by one `.icon-btn` in the list toolbar +(`#changes-list-view-btn`) and persisted under `localStorage.changesListView` +(`CHANGES_LIST_VIEW_KEY`), the same shape as the editor's +`changesDiffMode` toggle: the icon shows the current view, `data-view` carries +it, the tooltip names the other. `list` is the default and is what every +earlier release rendered; a stored `tree` is honoured at load, anything else +falls back to `list`. Ported from upstream `c380d187` (doctly/switchboard#98, +Vincenzo Favara), whose tree builder lived in `project-git-view.js`; the fork +has no Git tab, so the builder moved into `public/file-panel.js` next to the +rows it feeds, and the default stayed `list` (upstream later flipped to tree). + +`appendChangesRows(sessionId, tab, files, subSessionId)` is the single place +both the session's own rows and each subagent group's rows go through, so the +two render alike in either view. In `list` it is the flat loop it replaced. In +`tree`, `buildChangesTree` splits each path on `/` (git's separator on every +platform; the fork's rows carry repo-relative git paths) into folder nodes, +`sortChangesTreeLevel` puts folders before files, sorts each level with a +numeric, case-insensitive `localeCompare`, and compacts a folder whose only +child is a folder into one row named `a/b` (VS Code's compact folders), and +`changesTreeRows` flattens that into display rows, skipping the children of a +collapsed folder. A leaf is one status record, not one path: git reports two +records at one path after `git rm --cached f` (a staged deletion and an +untracked file), the flat list shows both, and the tree keeps both under the +folder, in git's order, each with its own click target (the leaf key carries +the record's index). A file row in tree mode shows the node's own name, carries +`.tree` and `--depth` for its indent, keeps `data-path` as the full repo path +(so the selection, the click handler, the untracked-count writeback and every +`[data-path=…]` selector are unchanged), and takes the full path — with the +rename arrow — as its `title`. The row cap applies before the tree is built: +the tree is made from the first `MAX_CHANGES_ROWS` files, and the +`+N more files not shown` note follows as before. + +A folder row is a `