feat(sidebar): group a tab by its folder when its cwd is not a repo (#631)

`sidebar_grouping` gains a third, opt-in mode, `repo-or-directory`: group by repository home as before, and when the repo probe has landed and answered "not a repo", group under the cwd itself instead of filing every such tab under Scratch. A probe that has not run yet resolves to no decision, so a tab keeps the group it already has rather than bouncing through Scratch mid-probe. The decision lives in one `resolved_group` free function shared by the per-frame key derivation and spawn-time seeding.

The default (`repo`) and flat modes behave exactly as before, and an unknown value in an existing config still degrades to `repo`.

Knock-on: `machine_mirror::subject_path_of` names a window after its most common group, so in the new mode a window of plain shells takes its name from the most common directory rather than from the first pane's cwd.

Closes #620.
This commit is contained in:
webdev
2026-08-14 15:57:36 +08:00
committed by GitHub
parent 0346e35b40
commit 422808191d
9 changed files with 115 additions and 27 deletions
+1 -1
View File
@@ -69,7 +69,7 @@ their id from the file name. [More about themes →](/customization/themes)
|---|---|---|---|
| `tab_bar_position` | enum | `"left"` | `left` (sidebar) or `top` (strip). |
| `new_tab_position` | enum | `"after-current"` | Or `end`. |
| `sidebar_grouping` | enum | `"repo"` | Or `none` for a flat list. |
| `sidebar_grouping` | enum | `"repo"` | Or `repo-or-directory` to group non-repo tabs by their folder, or `none` for a flat list. |
| `sidebar_diff_preview` | bool | `true` | Clicking a row's `+N M` opens the diff overlay. |
| `sidebar_width` | number | `220` | Pixels (1002000). |
| `sidebar_collapsed` | bool | `false` | |
+6 -4
View File
@@ -22,7 +22,10 @@ not its history — switching branches or `cd`-ing around inside a repository
never moves a row out from under its header.
**Settings → Window & Tabs → Sidebar grouping** switches between *By repo* (the
default) and *Flat*.
default), *By repo or folder*, and *Flat*. The default collects every non-repo
tab in Scratch; *By repo or folder* groups those tabs under their working
directory instead — for agents running in plain folders — leaving Scratch to
tabs whose shell has not reported a directory yet.
## What a row tells you
@@ -52,9 +55,8 @@ they simply stop opening the overlay.
## Rearranging
Drag a row to reorder it within its group, or drag a whole group header to move
the group. A row cannot be dragged into a different group: with the default repo
grouping a tab's group comes from its working directory, so `cd` is what moves
it.
the group. A row cannot be dragged into a different group: a tab's group comes
from its working directory, so `cd` is what moves it.
## Naming