Skip to content

Commit a91f87d

Browse files
committed
wrapup: surface run start on both TUI and Desktop
The command blocks its turn and fires no message events, so nothing indicated a running wrapup until completion. Send an ignored-message start notice (TUI toast / Desktop persisted chat line) and a socket action that kicks the sidebar's fast progress poll so the Wrapup row appears immediately. Cargo.lock: sibling subc SDK version bumps.
1 parent 468a107 commit a91f87d

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

packages/plugin/src/hooks/magic-context/wrapup-orchestrator.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
updateWrapupInProgress,
1919
} from "../../features/magic-context/storage";
2020
import { sessionLog } from "../../shared/logger";
21+
import { pushNotification } from "../../shared/rpc-notifications";
2122
import {
2223
getActiveCompartmentRun,
2324
markActiveCompartmentRunPublished,
@@ -32,6 +33,7 @@ import {
3233
} from "./protected-tail-boundary";
3334
import type { ManagedRecompContext } from "./recomp-orchestrator";
3435
import { setRecompStarting, setRecompTerminal } from "./recomp-orchestrator";
36+
import { sendIgnoredMessage } from "./send-session-notification";
3537

3638
export interface ManagedWrapupContext extends ManagedRecompContext {
3739
contextLimit: number;
@@ -314,6 +316,29 @@ export async function runManagedWrapup(
314316
return `## Magic Wrapup — Skipped\n\n${message}`;
315317
}
316318

319+
// The command blocks until the drain finishes and fires no message events,
320+
// so nothing would indicate the run until completion. Two best-effort
321+
// surfaces, neither may affect the drain:
322+
// - sendIgnoredMessage: TUI gets a toast; Desktop/headless gets a
323+
// persisted ignored chat message (its only progress surface).
324+
// - wrapup-progress-kick: starts the TUI sidebar's fast progress poll
325+
// (the toast above cannot do that).
326+
try {
327+
void sendIgnoredMessage(
328+
ctx.client,
329+
sessionId,
330+
`Magic Wrapup started — compacting about ${plural(expectedChunks, "chunk")} of history. This can take a few minutes; the result posts here when done.`,
331+
ctx.getNotificationParams(sessionId),
332+
);
333+
} catch {
334+
// Notification delivery must never affect the drain.
335+
}
336+
try {
337+
pushNotification("action", { action: "wrapup-progress-kick" }, sessionId);
338+
} catch {
339+
// Notification delivery must never affect the drain.
340+
}
341+
317342
if (ownershipLost) {
318343
stoppedForFailure = true;
319344
stoppedReason = ownershipLostReason;

packages/plugin/src/tui/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,15 @@ const tui: TuiPlugin = async (api, _options, meta) => {
797797
if (action === "show-embed-dialog") {
798798
return stillActive() && (await showEmbedDialog(api, requestedSessionId))
799799
}
800+
if (action === "wrapup-progress-kick") {
801+
// /ctx-wrapup blocks its command turn and fires no message events, so
802+
// the sidebar poll would never notice the run. Kick the fast progress
803+
// poll (same loop the recomp dialog kicks). The start toast arrives
804+
// separately via the ignored-message notification path.
805+
if (!stillActive()) return false
806+
kickRecompProgressRefresh()
807+
return true
808+
}
800809
if (action === "show-flush-dialog") {
801810
const flushMsg = String(n.payload?.message ?? "Flushed.")
802811
return stillActive() && showResultDialog(api, "Flush", flushMsg)

0 commit comments

Comments
 (0)