Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions apps/desktop/src/state/delegateStatus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,22 @@ const input = (over: Partial<StatusInput> = {}): StatusInput => ({
});

describe("isStatusQuery", () => {
test("a bare status, in any case, with a question mark or room around it", () => {
for (const text of ["status", "Status", "status?", " STATUS ? ", "status??"]) {
test("the /status command alone, with room around it", () => {
for (const text of ["/status", " /status ", "/status\n"]) {
expect(isStatusQuery(text)).toBe(true);
}
});

test("anything longer is a message for the model", () => {
test("a plain status or anything longer is a message for the model", () => {
for (const text of [
"",
"status",
"Status?",
"status of the PR?",
"what is the status",
"status please",
"/status",
"statuses",
"status\nand then merge",
"/status please",
"/statuses",
"/status\nand then merge",
]) {
expect(isStatusQuery(text)).toBe(false);
}
Expand Down
6 changes: 3 additions & 3 deletions apps/desktop/src/state/delegateStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ export interface StatusInput {
}

/**
* A bare `status` or `status?` (any case, with room around it) is a question the app answers
* itself. Anything longer is a message for the model: "status of the PR?" is not this.
* The `/status` command alone (room around it is fine) asks for the delegates' status too. A plain
* "status" is a message for the model like any other, and so is "/status" with more after it.
*/
export function isStatusQuery(text: string): boolean {
return /^\s*status\s*\?*\s*$/i.test(text);
return text.trim() === "/status";
}

/** The rows, working ones first (what the reader asks about), then the rest in the order given. */
Expand Down
17 changes: 9 additions & 8 deletions apps/desktop/src/state/hostDelegates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,14 @@ export function delegateStatusInputs(s: AppState, orchestrator: string, max = In
}

/**
* A bare "status" in a thread that has delegates is answered here, from what the app already
* knows: the user's message and a local reply row go into the transcript, and no model turn runs
* (each one resent the whole context and cost as much as any other). The pull requests are read
* after the row is drawn and fill in as they arrive. False for a thread with no delegates, where
* the model answers as it always did.
* `/status` in a thread that has delegates adds their status here, from what the app already
* knows: a local reply row goes into the transcript, and no model turn runs (each one resent the
* whole context and cost as much as any other). With `withMessage` the user's message goes in
* before it; without, the harness's own `/status` report answers the message in its panel. The
* pull requests are read after the row is drawn and fill in as they arrive. False for a thread
* with no delegates, where `/status` goes to the harness as it always did.
*/
export function answerStatusLocally(threadId: string, text: string): boolean {
export function answerStatusLocally(threadId: string, text: string, withMessage = true): boolean {
if (!isStatusQuery(text)) return false;
const s = useApp.getState();
if (!s.threads[threadId]) return false;
Expand All @@ -154,8 +155,8 @@ export function answerStatusLocally(threadId: string, text: string): boolean {
...t,
items: [
...t.items,
{ kind: "user", id: localId("user"), text: text.trim(), at: now },
{ kind: "status", id: statusId, at: now, rows },
...(withMessage ? [{ kind: "user" as const, id: localId("user"), text: text.trim(), at: now }] : []),
{ kind: "status" as const, id: statusId, at: now, rows },
],
}));
for (const row of rows) {
Expand Down
8 changes: 6 additions & 2 deletions apps/desktop/src/state/sendActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
engine,
errorText,
harnessesOn,
isReportCommand,
newThreadChoice,
peekThread,
projectThreadChoice,
Expand Down Expand Up @@ -201,8 +202,11 @@ export async function submit(text: string, extras: ComposeExtras = emptyExtras):
await cancel(id);
return true;
}
// A bare "status" in a thread with delegates is answered from what the app knows, with no turn.
if (!hasExtras(extras) && !get().editing[id] && answerStatusLocally(id, trimmed)) return true;
// `/status` with delegates lists them locally; a harness `/status` report still opens its panel.
if (!hasExtras(extras) && !get().editing[id]) {
const report = isReportCommand(id, trimmed, extras);
if (answerStatusLocally(id, trimmed, !report) && !report) return true;
}
const edit = get().editing[id];
if (edit && !isRunning(thread)) {
cancelEdit(id);
Expand Down
19 changes: 10 additions & 9 deletions docs/orchestrator.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,15 +1031,16 @@ model turn:
(`readDelegatePull` in `state/host.ts`, `_rustcode/pulls/state`), shared and
kept for 30 s, repeated every 25 s while the panel is open and the window is
visible, and skipped for a delegate outside a worktree.
- **A bare `status`.** Typing `status` or `status?` (any case, nothing else) in a
thread with delegates is answered by the app: the message and a *Status* card
go into the transcript, marked **Local reply · no model turn**, and nothing is
sent to the harness. The card carries the same rows as the panel and fills in
the pull requests as they arrive. Any longer message (`status of the PR?`)
goes to the model as before, and so does `status` in a thread with no
delegates. The card is the app's, not the thread's: it is not stored by the
engine, so a reload drops it. The matcher and the rows are pure
(`state/delegateStatus.ts`).
- **`/status`.** Typing `/status` alone in a thread with delegates adds a
*Status* card to the transcript, marked **Local reply · no model turn**. When
the harness answers `/status` as a report, that report still opens in its
panel above the composer; otherwise the message goes into the transcript
with the card and nothing is sent to the harness. The card carries the same
rows as the panel and fills in the pull requests as they arrive. A plain
`status` is a message for the model, and `/status` in a thread with no
delegates goes to the harness as before. The card is the app's, not the
thread's: it is not stored by the engine, so a reload drops it. The matcher
and the rows are pure (`state/delegateStatus.ts`).

## Orchestration tools v3

Expand Down
Loading