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.
This commit is contained in:
l0ng-ai
2026-11-14 19:24:55 +08:00
parent 9f7a35f170
commit b83df2dbda
6 changed files with 64 additions and 12 deletions
+4
View File
@@ -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;
@@ -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);
+16 -2
View File
@@ -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!);
+12 -7
View File
@@ -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;
+1 -1
View File
@@ -387,7 +387,7 @@ function SessionStatus({
<T>{statusLabel(task.status)}</T>
{task.status === "limited" && task.resetsMs != null && ` · ${tx`resets ${formatSentAt(task.resetsMs)}`}`}
</span>
{/* 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. */}
<span className={styles.statusEnd}>
{(!!changes?.length || !!commits.length) && (
<span className={styles.statusChips}>
+10 -2
View File
@@ -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) => {