feat(maestro): abbreviate paths in spawn dialog recent-dir picker
ci / rust (push) Failing after 1m43s
ci / rust (push) Failing after 1m43s
The working-directory picker showed raw absolute paths (`/home/naps62/...`), unlike the sidebar tree which collapses home to `~` and shrinks leading segments to initials. Reuse the sidebar's abbreviation so both read the same: `/home/naps62/git.naps.pt/naps62/maestro` → `~/g/n/maestro`, with the full path kept in the row tooltip and submitted verbatim. - types.ts: hoist `abbreviateFolderName` (+ a local `escapeHtml`) here so both the sidebar and spawn dialog share one implementation (catalog.ts imports spawn.ts, so the helper can't live in catalog without a cycle). - catalog.ts: import the shared helper instead of its own copy. - spawn.ts: abbreviate each recent-dir row via `abbreviateFolderName(abbreviateCwd(...))`. - styles.css: dim the collapsed stem in the picker too (`.recent-dir .folder-stem`). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+7
-1
@@ -8,6 +8,7 @@ import type {
|
||||
Session,
|
||||
SpawnPreset,
|
||||
} from "./types.js";
|
||||
import { abbreviateCwd, abbreviateFolderName } from "./types.js";
|
||||
|
||||
/** Seed values for the spawn form — used by "clone" to reopen the dialog with
|
||||
* the same daemon, cwd, command, and name as an existing session. */
|
||||
@@ -288,8 +289,13 @@ export function openSpawnModal(
|
||||
row.type = "button";
|
||||
row.className = "recent-row";
|
||||
row.dataset.cwd = dir.cwd;
|
||||
// Abbreviate exactly like the sidebar: home → `~`, then collapse leading
|
||||
// segments to initials (`~/g/n/maestro`). The full path stays in the tooltip
|
||||
// and `dataset.cwd` (what's actually submitted).
|
||||
const home = daemons.get(selectedHostId)?.home_dir;
|
||||
const display = abbreviateFolderName(abbreviateCwd(dir.cwd, home));
|
||||
row.innerHTML = `
|
||||
<span class="recent-dir">${escapeHtml(dir.cwd)}</span>
|
||||
<span class="recent-dir" title="${escapeHtml(dir.cwd)}">${display}</span>
|
||||
<span class="recent-cmd">${escapeHtml(dir.last_command)}</span>`;
|
||||
row.addEventListener("click", () => selectRecent(dir));
|
||||
return row;
|
||||
|
||||
Reference in New Issue
Block a user