Compare commits

..
2 Commits
Author SHA1 Message Date
FactorandOvis Fast 56be86391b feat: a green check confirms a send and info notices fade after 3 s
Co-Authored-By: Ovis Fast (Claude) <[email protected]>
2026-11-20 10:06:17 +01:00
FactorandClaude Opus 5.5 0fad0a2e4e docs: design and plan for the send confirmation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 10:05:15 +01:00
7 changed files with 169 additions and 15 deletions

No files matched your search

@@ -0,0 +1,29 @@
# Potwierdzenie wysyłki — plan implementacji
**Spec:** `docs/superpowers/specs/2026-11-20-send-confirmation-design.md` (czytaj całość).
**Gałąź:** `feature/send-confirmation`. Bez push.
## Ograniczenia globalne
- Czasy dosłownie: `SENT_MS = 1500`, `NOTICE_MS = 3000` (stałe eksportowane z `view.js` lub `state.js`, gdzie pasuje).
- Timery tylko przez `cx.timer.after` (jak `draftTimer`); poprzedni timer anulowany (`.cancel()`) przed nowym.
- Logika testowalna w czystej funkcji; GPUI tylko w `main.js`.
## Review Focus
1. Komunikat `info` A, po 2 s komunikat `problem` B: timer A nie może skasować B. Test w Task 1.
2. Dwie wysyłki w odstępie 1 s: ✓ widoczne do 1,5 s po drugiej (timer odnowiony).
3. Wysyłka nieudana (błąd `hc`): bez ✓, czerwony komunikat jak dziś.
4. Wysyłka do kolejki (agent pracuje): komunikat o kolejce znika po 3 s, ✓ się nie pokazuje (nic nie poszło do terminala).
### Task 1: czysta logika (test)
**Produkuje** w `view.js`: `export function noticeExpired(current, scheduled): boolean` — `true`, gdy `current` to ten sam obiekt co `scheduled` i `scheduled.level === "info"`.
- [ ] Testy w `tests/view.test.mjs` (RED): ten sam obiekt `info` → `true`; inny obiekt o tym samym tekście → `false`; `problem`/`error` → `false`; `current === null` → `false`.
- [ ] Implementacja, `npm test` PASS.
### Task 2: `main.js`
- `notice(text, level, cx)`: zapamiętaj obiekt komunikatu; dla `"info"` ustaw (anulując poprzedni) `this.noticeTimer = cx.timer.after(NOTICE_MS, (cx) => { if (noticeExpired(this.state.notice, scheduled)) { this.state = reduce(this.state, { type: "notice", notice: null }); cx.notify(); } })`. Gdy `cx` brak (wywołania bez `cx`) — użyj `cx` dostępnego w miejscu wywołania: przejrzyj wszystkie `this.notice(` i dopisz `cx`, gdzie jest w zasięgu; gdzie go nie ma, komunikat zniknie przy najbliższym `notice`/akcji (zapisz listę takich miejsc w raporcie).
- 4 × `this.notice("Wysłano do terminala.")` → `this.flashSent(cx)`: `this.sentUntil = Date.now() + SENT_MS`, timer `SENT_MS` → `cx.notify()` (odnowiony przy kolejnym wywołaniu); dodatkowo wyczyść bieżący komunikat `info` (stara informacja nie wisi).
- Render: gdzie dziś wybierany jest `renderStop` / `renderSend`, najpierw: `Date.now() < this.sentUntil` → `renderSent(t)` (kółko 32 px, `rounded(999)`, `bg(t.done)`, „✓”, `text_size(13)`, `font_semibold()`, bez `on_click`).
- Komentarz na górze `main.js` (linia ~23) i `delivery.js:16` o „Wysłano do terminala” zaktualizuj.
- [ ] `npm test` PASS, `node --check main.js` OK.
- [ ] README: jeśli wspomina „Wysłano do terminala”, popraw.
- [ ] Commit (oba taski razem albo osobno): `feat: a green check confirms a send and info notices fade after 3 s` + `Co-Authored-By: Ovis Fast (Claude) <[email protected]>`.
@@ -0,0 +1,14 @@
# Potwierdzenie wysyłki bez komunikatu — projekt (krótki)
Data: 2026-11-20 · Mod: `herdr/herdr-composer/mods/herdr-composer/`
## Cel i powód
Komunikat „Wysłano do terminala.” pod kartą composera zabiera miejsce w pionie terminalowi i wisi, aż zastąpi go inny. Potwierdzenie ma być tam, gdzie patrzy użytkownik (przycisk wysyłki), a komunikaty informacyjne mają nie zajmować miejsca na stałe.
## Zakres
- **✓ zamiast „Wysłano do terminala.”** Po udanej wysyłce (4 miejsca w `main.js`, dziś `this.notice("Wysłano do terminala.")`) przez **1,5 s** w miejscu przycisku wysyłki/Stop jest zielone kółko 32 px (`t.done`) z „✓” (kolor `t.solid_foreground` albo `t.background` — byle czytelny). Kliknięcie nic nie robi. Potem wraca `↵` albo Stop, zgodnie z bieżącym stanem. Druga wysyłka w trakcie odnawia 1,5 s. Komunikat „Wysłano do terminala.” znika całkowicie (nie jest ustawiany).
- **Komunikaty `info` znikają po 3 s.** Każdy komunikat poziomu `"info"` jest czyszczony po **3 s** — chyba że w tym czasie pojawił się inny komunikat (timer czyści tylko ten, który ustawił). `"problem"` i `"error"` zostają jak dziś (do zastąpienia).
- Bez zmian: toasty błędów, kolejka, chip statusu, Esc.
## Podejścia
Znikający komunikat / usunięcie komunikatu / ✓ na przycisku. **Wybrane: ✓ na przycisku** (decyzja użytkownika) plus znikanie pozostałych `info` po 3 s (decyzja użytkownika). Mój wybór: ✓ ma pierwszeństwo przed Stop przez 1,5 s (inaczej byłby niewidoczny, bo po wysyłce agent od razu „pracuje”); Stop w tym czasie zastępuje `Esc`.
+1 -1
View File
@@ -68,7 +68,7 @@ panel and otherwise, with an empty field and a working agent, stops the agent
(`hc interrupt`; the queue is held and nothing goes out on its own). Up/Down/Tab move (`hc interrupt`; the queue is held and nothing goes out on its own). Up/Down/Tab move
and accept in the suggestion menu; without a menu Up/Down move the cursor between lines. and accept in the suggestion menu; without a menu Up/Down move the cursor between lines.
**Sending.** Idle or done: out at once ("Wysłano do terminala."). Blocked: out at once with **Sending.** Idle or done: out at once (a green check on the send button for 1.5 s). Blocked: out at once with
`--force` (an answer), ahead of the queue. Working: into the queue ("Następna tura"). When `--force` (an answer), ahead of the queue. Working: into the queue ("Następna tura"). When
the turn ends (working or blocked, then idle or done) the first queued message counts the turn ends (working or blocked, then idle or done) the first queued message counts
down "Wysyłam za 3 s" (button "Anuluj" holds it) and goes out; the next waits for the down "Wysyłam za 3 s" (button "Anuluj" holds it) and goes out; the next waits for the
@@ -13,7 +13,7 @@
// for a plain shell with no agent, and also when it fails. Neither the exit // for a plain shell with no agent, and also when it fails. Neither the exit
// code nor those fields say whether the agent got the message. Therefore: // code nor those fields say whether the agent got the message. Therefore:
// - ok:true means "the text was pasted and Enter pressed", NOT "the agent // - ok:true means "the text was pasted and Enter pressed", NOT "the agent
// received it" - the UI says "Wysłano do terminala"; // received it" - the UI shows a green check on the send button;
// - the only failure is a non-zero exit code (its stderr becomes the notice); // - the only failure is a non-zero exit code (its stderr becomes the notice);
// - every `--json` call checks the payload for an "error" field, because `hc` // - every `--json` call checks the payload for an "error" field, because `hc`
// exits 0 even on error (measured: `hc wait t3 --json` for a missing // exits 0 even on error (measured: `hc wait t3 --json` for a missing
@@ -20,8 +20,8 @@
// an empty field (`hc interrupt`). // an empty field (`hc interrupt`).
// //
// `hc send` does not confirm a delivery - it pastes the text and presses // `hc send` does not confirm a delivery - it pastes the text and presses
// Enter. The composer says "Wysłano do terminala" and takes the confirmation // Enter. The composer shows a green check on the send button for a moment and
// from the agent's status. // takes the confirmation from the agent's status.
import { View, div, image } from "gpui-kit"; import { View, div, image } from "gpui-kit";
import { v_flex, h_flex, TextareaState, Textarea, InputState, Input, Popover, ScrollHandle, VirtualListScrollHandle } from "gpui-base"; import { v_flex, h_flex, TextareaState, Textarea, InputState, Input, Popover, ScrollHandle, VirtualListScrollHandle } from "gpui-base";
@@ -122,6 +122,9 @@ import {
isManualResize, isManualResize,
statusText, statusText,
targetAgent, targetAgent,
noticeExpired,
SENT_MS,
NOTICE_MS,
} from "./view.js"; } from "./view.js";
/** The placeholder of the field. */ /** The placeholder of the field. */
@@ -188,6 +191,13 @@ export default class Composer extends View {
this.draftLoading = new Set(); this.draftLoading = new Set();
this.draftTimer = null; this.draftTimer = null;
// The green check on the send button after a send (until `sentUntil`, ms
// since the epoch) and the timers that redraw the composer when it is over
// (`sentTimer`) and that clear an `info` notice (`noticeTimer`).
this.sentUntil = 0;
this.sentTimer = null;
this.noticeTimer = null;
// Attachments: the message that waits for the answer to "this agent may // Attachments: the message that waits for the answer to "this agent may
// not take images" (null when nothing waits), and whether the file dialog // not take images" (null when nothing waits), and whether the file dialog
// is open. // is open.
@@ -1080,7 +1090,7 @@ export default class Composer extends View {
this.closePanel(); this.closePanel();
this.textarea.replace(hit.item.text); this.textarea.replace(hit.item.text);
this.syncFieldAfterReplace(); this.syncFieldAfterReplace();
this.notice("Wstawiono w miejscu kursora — nic nie zostało wysłane."); this.notice("Wstawiono w miejscu kursora — nic nie zostało wysłane.", "info", cx);
cx.notify(); cx.notify();
} }
@@ -1725,9 +1735,10 @@ export default class Composer extends View {
? "Wiadomość wstrzymana — czeka na „Wyślij teraz”." ? "Wiadomość wstrzymana — czeka na „Wyślij teraz”."
: "Agent czeka na Ciebie — wiadomość czeka na „Wyślij teraz”.", : "Agent czeka na Ciebie — wiadomość czeka na „Wyślij teraz”.",
mode === "hold" ? undefined : "error", mode === "hold" ? undefined : "error",
cx,
); );
} else { } else {
this.notice("Wiadomość w kolejce — następna tura."); this.notice("Wiadomość w kolejce — następna tura.", "info", cx);
} }
cx.notify(); cx.notify();
} }
@@ -1765,7 +1776,7 @@ export default class Composer extends View {
this.state = reduce(this.state, { type: "settle", agent: key, id, outcome: "sent" }); this.state = reduce(this.state, { type: "settle", agent: key, id, outcome: "sent" });
this.persistQueue(key); this.persistQueue(key);
this.gates.set(key, closeGate(this.gateFor(key))); this.gates.set(key, closeGate(this.gateFor(key)));
this.notice("Wysłano do terminala."); this.flashSent(cx);
} else { } else {
this.state = reduce(this.state, { this.state = reduce(this.state, {
type: "settle", type: "settle",
@@ -1960,7 +1971,7 @@ export default class Composer extends View {
if (result.sent > 0) { if (result.sent > 0) {
this.gates.set(key, closeGate(this.gateFor(key))); this.gates.set(key, closeGate(this.gateFor(key)));
this.notice("Wysłano do terminala."); this.flashSent(cx);
} else if (claimed && !sent) { } else if (claimed && !sent) {
this.notice("Wiadomość nie poszła do terminala.", "error"); this.notice("Wiadomość nie poszła do terminala.", "error");
} }
@@ -1969,7 +1980,7 @@ export default class Composer extends View {
// the entry left the queue, so it is sent. // the entry left the queue, so it is sent.
const outcome = claimed ? failedHookOutcome(this.state.queue[key], claimed) : "uncertain"; const outcome = claimed ? failedHookOutcome(this.state.queue[key], claimed) : "uncertain";
if (outcome === "sent") { if (outcome === "sent") {
this.notice("Wysłano do terminala."); this.flashSent(cx);
} else { } else {
if (claimed) { if (claimed) {
this.state = reduce(this.state, { this.state = reduce(this.state, {
@@ -2031,7 +2042,7 @@ export default class Composer extends View {
this.persistQueue(key); this.persistQueue(key);
// The gate closes again: the next message waits for the next turn. // The gate closes again: the next message waits for the next turn.
this.gates.set(key, closeGate(this.gateFor(key))); this.gates.set(key, closeGate(this.gateFor(key)));
this.notice("Wysłano do terminala."); this.flashSent(cx);
} else { } else {
this.state = reduce(this.state, { this.state = reduce(this.state, {
type: "settle", type: "settle",
@@ -2193,7 +2204,7 @@ export default class Composer extends View {
this.state = reduce(this.state, { type: "hold_all", agent: key }); this.state = reduce(this.state, { type: "hold_all", agent: key });
this.gates.set(key, closeGate(this.gateFor(key))); this.gates.set(key, closeGate(this.gateFor(key)));
this.persistQueue(key); this.persistQueue(key);
this.notice("Przerwano agenta. Kolejka wstrzymana — nic nie wyśle się samo."); this.notice("Przerwano agenta. Kolejka wstrzymana — nic nie wyśle się samo.", "info", cx);
cx.notify(); cx.notify();
cx.spawn(async (cx) => { cx.spawn(async (cx) => {
@@ -2705,13 +2716,52 @@ export default class Composer extends View {
// Levels: "info"; "problem" - red in the composer, no toast (what the // Levels: "info"; "problem" - red in the composer, no toast (what the
// person did: an empty text, a duplicate file); "error" - red and a toast // person did: an empty text, a duplicate file); "error" - red and a toast
// (a send or an `hc` call that failed). // (a send or an `hc` call that failed).
this.state = reduce(this.state, { type: "notice", notice: { text, level } }); const notice = { text, level };
this.state = reduce(this.state, { type: "notice", notice });
if (level === "error") { if (level === "error") {
notify({ title: "Composer", body: text, level: "error" }); notify({ title: "Composer", body: text, level: "error" });
} }
// An `info` notice fades after NOTICE_MS. The timer clears only the notice
// it was set for (noticeExpired): a later one is left alone. Without a
// `cx` there is no timer - that notice stays until the next one.
if (this.noticeTimer) {
this.noticeTimer.cancel();
this.noticeTimer = null;
}
if (level === "info" && cx) {
this.noticeTimer = cx.timer.after(NOTICE_MS, (cx) => {
this.noticeTimer = null;
if (noticeExpired(this.state.notice, notice)) {
this.state = reduce(this.state, { type: "notice", notice: null });
cx.notify();
}
});
}
cx?.notify(); cx?.notify();
} }
/**
* A message went to the terminal: the send button shows a green check for
* SENT_MS (a second send renews it) and the old `info` notice is cleared.
*/
flashSent(cx) {
this.sentUntil = Date.now() + SENT_MS;
if (this.sentTimer) {
this.sentTimer.cancel();
this.sentTimer = null;
}
this.sentTimer = cx.timer.after(SENT_MS, (cx) => {
this.sentTimer = null;
cx.notify();
});
if (this.state.notice?.level === "info") {
this.state = reduce(this.state, { type: "notice", notice: null });
}
cx.notify();
}
/** An id of its own - the queue and the attachments count on it. */ /** An id of its own - the queue and the attachments count on it. */
newId() { newId() {
this.counter += 1; this.counter += 1;
@@ -3166,7 +3216,13 @@ export default class Composer extends View {
.child(div().w(1).h(18).flex_none().bg(t.border)) .child(div().w(1).h(18).flex_none().bg(t.border))
.child(this.renderDock(t, active)) .child(this.renderDock(t, active))
.child(this.renderChip(t, agent, status, files.length)) .child(this.renderChip(t, agent, status, files.length))
.child(stop ? this.renderStop(t, agent) : this.renderSend(t, agent, over)), .child(
Date.now() < this.sentUntil
? this.renderSent(t)
: stop
? this.renderStop(t, agent)
: this.renderSend(t, agent, over),
),
].filter(Boolean), ].filter(Boolean),
); );
} }
@@ -3268,7 +3324,7 @@ export default class Composer extends View {
if (action === "insert") { if (action === "insert") {
this.textarea.replace(button.text); this.textarea.replace(button.text);
this.syncFieldAfterReplace(); this.syncFieldAfterReplace();
this.notice("Wstawiono w miejscu kursora — nic nie zostało wysłane."); this.notice("Wstawiono w miejscu kursora — nic nie zostało wysłane.", "info", cx);
cx.notify(); cx.notify();
return; return;
} }
@@ -3505,6 +3561,19 @@ export default class Composer extends View {
); );
} }
/** The green check that confirms a send; it takes the place of the button for a moment. */
renderSent(t) {
return div()
.id("composer-sent")
.size(32)
.rounded(999)
.bg(t.done)
.flex()
.items_center()
.justify_center()
.child(div().text_size(13).font_semibold().text_color(t.solid_foreground).child("✓"));
}
/** The button that stops the agent. */ /** The button that stops the agent. */
renderStop(t, agent) { renderStop(t, agent) {
return div() return div()
@@ -609,3 +609,23 @@ export function fieldBackground(theme, panelBackground) {
} }
return best ?? panelBackground; return best ?? panelBackground;
} }
/** How long the green check stays on the send button after a send, ms. */
export const SENT_MS = 1500;
/** How long an `info` notice stays under the card, ms. */
export const NOTICE_MS = 3000;
/**
* Is it time to clear the notice? Only the very notice the timer was set for,
* and only an `info` one: another notice that came in the meantime (even with
* the same text) is none of this timer's business, and a `problem` or an
* `error` stays until something replaces it.
*
* @param {{level?:string}|null} current - the notice of the state now
* @param {{level?:string}} scheduled - the notice the timer was set for
* @returns {boolean}
*/
export function noticeExpired(current, scheduled) {
return current !== null && current === scheduled && scheduled.level === "info";
}
+23 -1
View File
@@ -2,7 +2,7 @@ import test from "node:test";
import assert from "node:assert/strict"; import assert from "node:assert/strict";
import { import {
targetAgent, agentKey, agentName, agentStatus, createGate, gatePasses, openGate, closeGate, targetAgent, agentKey, agentName, agentStatus, createGate, gatePasses, openGate, closeGate,
isPlainEnter, statusText, queueLabel, applySuggestion, insertedNewline, isPlainEnter, statusText, queueLabel, applySuggestion, insertedNewline, noticeExpired,
} from "../herdr/herdr-composer/mods/herdr-composer/view.js"; } from "../herdr/herdr-composer/mods/herdr-composer/view.js";
const agents = [{ address: "t1", app: "claude-code" }, { address: "a2" }]; const agents = [{ address: "t1", app: "claude-code" }, { address: "a2" }];
@@ -165,3 +165,25 @@ test("fieldBackground: the darkest color the theme has, darker than the panel",
assert.equal(fieldBackground({}, "#2a2c31"), "#2a2c31"); assert.equal(fieldBackground({}, "#2a2c31"), "#2a2c31");
assert.equal(fieldBackground({ background: "nope" }, "#2a2c31"), "#2a2c31"); assert.equal(fieldBackground({ background: "nope" }, "#2a2c31"), "#2a2c31");
}); });
test("noticeExpired: the same info notice expires", () => {
const info = { text: "a", level: "info" };
assert.equal(noticeExpired(info, info), true);
});
test("noticeExpired: another notice with the same text is not touched", () => {
const scheduled = { text: "a", level: "info" };
assert.equal(noticeExpired({ text: "a", level: "info" }, scheduled), false);
});
test("noticeExpired: a problem or an error stays, and so does an info that was replaced by one", () => {
const problem = { text: "b", level: "problem" };
const error = { text: "c", level: "error" };
assert.equal(noticeExpired(problem, problem), false);
assert.equal(noticeExpired(error, error), false);
assert.equal(noticeExpired(problem, { text: "a", level: "info" }), false);
});
test("noticeExpired: no current notice is nothing to clear", () => {
assert.equal(noticeExpired(null, { text: "a", level: "info" }), false);
});