From b83df2dbdabcc459bff12738d2935cf16fe32339 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:24:45 +0800 Subject: [PATCH] fix(agents): keep the session status line readable in a narrow panel The status line under a session wraps what doesn't fit to the next line instead of shrinking every fact to a letter or two; the changes chip starts that line and the meters end it. The current-file hint keeps to one line, and references in the composer get a remove button like the attached blocks. --- src/features/agents/Composer.module.css | 4 ++++ src/features/agents/ReferenceChip.module.css | 21 ++++++++++++++++++++ src/features/agents/ReferenceChip.tsx | 18 +++++++++++++++-- src/features/agents/Session.module.css | 19 +++++++++++------- src/features/agents/SessionEditor.tsx | 2 +- src/features/agents/composerEditor.ts | 12 +++++++++-- 6 files changed, 64 insertions(+), 12 deletions(-) diff --git a/src/features/agents/Composer.module.css b/src/features/agents/Composer.module.css index cb108060b..95bf5658c 100644 --- a/src/features/agents/Composer.module.css +++ b/src/features/agents/Composer.module.css @@ -438,7 +438,10 @@ .suggestion:focus-visible { outline: 2px solid var(--focus-ring); } +/* The file name truncates first; the hint stays on one line. */ .suggestionHint { + flex: none; + white-space: nowrap; color: var(--fg-faint); } .removeChip { @@ -458,6 +461,7 @@ color: var(--fg-strong); } .attachmentName { + min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; diff --git a/src/features/agents/ReferenceChip.module.css b/src/features/agents/ReferenceChip.module.css index ea9768fbe..de19740be 100644 --- a/src/features/agents/ReferenceChip.module.css +++ b/src/features/agents/ReferenceChip.module.css @@ -43,6 +43,27 @@ color: var(--fg-muted); font-variant-numeric: tabular-nums; } +/* In the composer: a × at the end removes the reference, as on the attached blocks. */ +.removable { + padding-right: 2px; +} +.chipRemove { + display: grid; + flex: none; + place-items: center; + width: 16px; + height: 16px; + padding: 0; + border: 0; + border-radius: var(--radius-small); + background: none; + color: var(--fg-muted); + cursor: pointer; +} +.chipRemove:hover { + background: var(--bg-hover); + color: var(--fg-strong); +} /* The file is gone (renamed or deleted since it was referenced). */ .missing { color: var(--fg-muted); diff --git a/src/features/agents/ReferenceChip.tsx b/src/features/agents/ReferenceChip.tsx index eb4d598f8..cf8625e64 100644 --- a/src/features/agents/ReferenceChip.tsx +++ b/src/features/agents/ReferenceChip.tsx @@ -55,8 +55,8 @@ export function openReference(path: string, mention: Mention) { const nameOf = (m: Mention) => basename(m.rel.replace(/\/$/, "")) || m.rel; const iconOf = (m: Mention) => (m.dir ? "folder" : fileIconName(nameOf(m), m.rel)); -/** The chip as DOM, for the composer's editor. */ -export function chipElement(path: string, mention: Mention): HTMLElement { +/** The chip as DOM, for the composer's editor; `onRemove` adds its × button. */ +export function chipElement(path: string, mention: Mention, onRemove?: () => void): HTMLElement { const chip = document.createElement("span"); chip.className = styles.chip!; chip.dataset.refPath = path; @@ -74,6 +74,20 @@ export function chipElement(path: string, mention: Mention): HTMLElement { lines.textContent = linesLabel(mention.lines); chip.append(lines); } + if (onRemove) { + chip.classList.add(styles.removable!); + const remove = document.createElement("button"); + remove.type = "button"; + remove.className = styles.chipRemove!; + remove.setAttribute("aria-label", tx("Remove")); + remove.append(iconNode("close", 10)); + remove.addEventListener("mousedown", (e) => e.preventDefault()); + remove.addEventListener("click", (e) => { + e.stopPropagation(); + onRemove(); + }); + chip.append(remove); + } if (!mention.dir) void fileExists(path).then((exists) => { if (!exists) chip.classList.add(styles.missing!); diff --git a/src/features/agents/Session.module.css b/src/features/agents/Session.module.css index 3b8715800..795297af0 100644 --- a/src/features/agents/Session.module.css +++ b/src/features/agents/Session.module.css @@ -41,9 +41,11 @@ /* The task's state and its terminal and changes, just above the composer. */ .statusBar { display: flex; + /* What doesn't fit moves to the next line whole, instead of every fact shrinking to a letter. */ + flex-wrap: wrap; /* The changes chip sits above the line; the facts stay on that line's baseline. */ align-items: flex-end; - gap: 6px; + gap: 2px 6px; min-width: 0; padding: 0 2px; overflow: hidden; @@ -54,6 +56,7 @@ .agent { display: inline-flex; flex: 0 1 auto; + max-width: 100%; align-items: center; gap: 4px; height: 22px; @@ -70,6 +73,7 @@ .where { display: inline-flex; flex: 0 1 auto; + max-width: 100%; align-items: center; /* The chips' own padding spaces them. */ gap: 2px; @@ -87,20 +91,21 @@ height: 22px; white-space: nowrap; } -/* The changes sit above the meter, time and terminal; those keep their one row at the right. */ +/* The rest of the line: the changes at its start, the meter, time and terminal at its end. + On a line of its own (a narrow session) the changes line up with the facts above. */ .statusEnd { display: inline-flex; - flex: 0 1 auto; - flex-direction: column; - align-items: flex-end; - gap: 2px; + flex: 1 1 auto; + flex-wrap: wrap; + align-items: center; + gap: 2px 8px; min-width: 0; - margin-left: auto; } /* Shrinks before the terminal buttons do: in a narrow docked session the meters clip, not the controls. */ .statusMeters { display: inline-flex; flex: 0 1 auto; + margin-left: auto; align-items: center; height: 22px; gap: 8px; diff --git a/src/features/agents/SessionEditor.tsx b/src/features/agents/SessionEditor.tsx index 3a0038d44..b9e1637bf 100644 --- a/src/features/agents/SessionEditor.tsx +++ b/src/features/agents/SessionEditor.tsx @@ -387,7 +387,7 @@ function SessionStatus({ {statusLabel(task.status)} {task.status === "limited" && task.resetsMs != null && ` · ${tx`resets ${formatSentAt(task.resetsMs)}`}`} - {/* What changed sits above the meter, time and terminal; those keep their one row at the right. */} + {/* What changed sits before the meter, time and terminal, or above them when the row is full. */} {(!!changes?.length || !!commits.length) && ( diff --git a/src/features/agents/composerEditor.ts b/src/features/agents/composerEditor.ts index 26da11b5d..941b56456 100644 --- a/src/features/agents/composerEditor.ts +++ b/src/features/agents/composerEditor.ts @@ -79,8 +79,16 @@ class ChipWidget extends WidgetType { eq(other: ChipWidget) { return other.path === this.path && other.text === this.text; } - toDOM() { - const chip = chipElement(this.path, this.mention); + toDOM(view: EditorView) { + const chip = chipElement(this.path, this.mention, () => { + const from = view.posAtDOM(chip); + const at = view.state.field(painted).chips.find((c) => c.from === from); + if (!at) return; + // The space typed after the reference goes with it. + const end = view.state.sliceDoc(at.to, at.to + 1) === " " ? at.to + 1 : at.to; + view.dispatch({ changes: { from: at.from, to: end }, userEvent: "delete" }); + view.focus(); + }); // Keep the editor's focus and caret; a click opens the file. chip.addEventListener("mousedown", (e) => e.preventDefault()); chip.addEventListener("click", (e) => {