STEERING, NOT FOLLOW-UPS — pi-agent-core's two rails, used deliberately:
agent.steer() injects at the next response boundary INSIDE the live run
(one logical turn, the model changes course); followUp() would only extend
an ended run — not built. The same rail job markers already ride
(steeringMode 'all', the 2026-09-26 doctrine).
- POST /api/chats/[id]/steer: 404/400 honest guards; no live turn → 409
and the client silently falls back to a plain text send (the settle
race); live → steerLiveChat hands the message to the live agent's
steering queue AND parks it in the userSteers registry — the stranding
safety net. A steer stranded behind a question termination or abort
stays parked and rides the chat's NEXT run (handOffEligible), the same
deliver-or-requeue lifecycle as job markers. Reconciliation at settle:
delivered ids drop (reconcileUserSteers).
- Client: steer(text) queues + POSTs without flipping any turn state;
the drain's verbatim message events upsert the real user card by the
client-minted id (steer_<localid>) and the indicator fold drops the
line. canSend no longer gates on turnInFlight — Enter mid-turn steers;
Enter with an empty composer still stops; the square button stays Stop.
- The queued-steer indicator (owner spec): quiet one-liners above the
composer shell — right-aligned to where its corner rounding starts,
truncated with an ellipsis, fixed max width, ~half opacity, no
background, no container. Tunable later.
- Verified from pi-agent-core source: steering drains per completed turn
inside the loop; injected messages emit message_start/end verbatim;
finishTurn {action:'end'} (our question stopper) exits BEFORE the
steering poll — hence the registry.
52 lines
2.2 KiB
TypeScript
52 lines
2.2 KiB
TypeScript
/**
|
|
* The queued-steer indicator's pins (composer steering, owner arc
|
|
* 2026-10-03): the quiet one-liners above the composer shell, and the
|
|
* visibleQueuedSteers fold that decides which queued steers still show.
|
|
*/
|
|
import { describe, it } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
import { QueuedSteersBody } from "../components/queued-steers.tsx";
|
|
import { visibleQueuedSteers } from "../components/session-core.ts";
|
|
|
|
describe("QueuedSteersBody (the quiet queue above the composer)", () => {
|
|
it("renders one truncated right-aligned line per queued steer — no background, no container chrome", () => {
|
|
const html = renderToStaticMarkup(
|
|
<QueuedSteersBody
|
|
steers={[
|
|
{ id: "steer_a", text: "also cover Venus while you are at it, please and thank you" },
|
|
{ id: "steer_b", text: "short one" },
|
|
]}
|
|
/>,
|
|
);
|
|
assert.match(html, /data-testid="queued-steers"/);
|
|
assert.equal(html.match(/<span/g)?.length, 2, "one span per steer");
|
|
assert.match(html, /truncate/, "single-line truncation with ellipsis");
|
|
assert.match(html, /items-end/, "right-aligned stack");
|
|
assert.match(html, /max-w-\[240px\]/, "fixed-width stash");
|
|
assert.match(html, /muted-foreground\/60/, "quiet, roughly half opacity");
|
|
assert.doesNotMatch(html, /bg-|border|rounded/, "no background, no container");
|
|
assert.match(html, /also cover Venus/, "the text rides the line");
|
|
});
|
|
|
|
it("empty queue renders nothing", () => {
|
|
assert.equal(renderToStaticMarkup(<QueuedSteersBody steers={[]} />), "");
|
|
});
|
|
});
|
|
|
|
describe("visibleQueuedSteers (the fold: a line dies when its card lands)", () => {
|
|
it("a queued steer stays visible until its id lands in the messages", () => {
|
|
const queue = [
|
|
{ id: "steer_a", text: "a" },
|
|
{ id: "steer_b", text: "b" },
|
|
];
|
|
const before = visibleQueuedSteers(queue, [{ id: "msg_1" } as never]);
|
|
assert.equal(before.length, 2, "nothing landed yet — both lines show");
|
|
const after = visibleQueuedSteers(queue, [
|
|
{ id: "msg_1" } as never,
|
|
{ id: "steer_a", role: "user", content: "a" } as never,
|
|
]);
|
|
assert.deepEqual(after.map((s) => s.id), ["steer_b"], "the drained steer's line dropped");
|
|
});
|
|
});
|