Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
fix(agent): wake on local requests
Rahmanf463e8c33405
diff --git a/scripts/mso-agent-local.mjs b/scripts/mso-agent-local.mjsindex c5e30ed9..9682242a 100644--- a/scripts/mso-agent-local.mjs+++ b/scripts/mso-agent-local.mjs@@ -81,9 +81,11 @@ function historyRow(message, relayedToUser = false) {}export class LocalAgentBridge {- constructor({ session, composer }) {+ constructor({ session, composer, onRequest = (_message) => {}, persist = persistSession }) {this.session = session;+ this.persist = persist;this.composer = composer;+ this.onRequest = typeof onRequest === "function" ? onRequest : null;this.instanceId = `cli:${process.pid}:${randomUUID()}`;this.sessionId = null;this.state = "idle";@@ -212,11 +214,14 @@ export class LocalAgentBridge {this.session.history.push(historyRow(message, presentation.mode === "relay"));if (presentation.mode === "relay") this.session.history.push(relayAssistantRow(message));}- await persistSession(this.session);+ await this.persist(this.session);this.seen.add(id);if (!alreadyStored) this.composer.notify(sectionBlock("local", presentation.text, {columns: this.composer?.output?.columns, detail: String(message?.senderLabel || "peer"), colors: C,}));+ // Requests are actionable work, unlike notify/reply events. Wake the owning+ // interactive loop after durable persistence so it can make a correlated reply.+ if (!alreadyStored && message?.intent === "request") this.onRequest?.(message);if (message?.intent !== "request") await this.ack([id]).catch(() => undefined);}diff --git a/scripts/mso-agent-local.test.ts b/scripts/mso-agent-local.test.tsindex 22d2143e..f5d697ca 100644--- a/scripts/mso-agent-local.test.ts+++ b/scripts/mso-agent-local.test.ts@@ -51,6 +51,20 @@ describe("local agent TUI projection", () => {expect(localAgentPresentation(history, { senderLabel: "[agent-b]", intent: "reply", text: "piano", replyToMessageId: "localmsg_req", correlationId: "localcorr_x", requiresUserRelay: true }, plain).text).toContain("[agent-b] → user piano");});+ it("wakes the interactive loop only for a newly received correlated request", async () => {+ const requests: any[] = [];+ const bridge = new LocalAgentBridge({+ session: { history: [], agentSession: { id: "session-a" } },+ composer: { notify: () => {} },+ onRequest: (message: any) => requests.push(message),+ persist: async () => {},+ });+ bridge.sessionId = "session-a"; bridge.ack = async () => {};+ await bridge.accept({ id: "localmsg_request", targetSessionId: "session-a", intent: "request", text: "please answer" });+ await bridge.accept({ id: "localmsg_notify", targetSessionId: "session-a", intent: "notify", text: "FYI" });+ expect(requests.map((message) => message.id)).toEqual(["localmsg_request"]);+ });+it("deduplicates a replayed SSE message id before rendering it again", async () => {const notices: string[] = [];const bridge = new LocalAgentBridge({ session: { history: [], agentSession: { id: "session-a" } }, composer: { notify: (text: string) => notices.push(text) } });diff --git a/scripts/mso-agent.mjs b/scripts/mso-agent.mjsindex 4d909933..e57aa4bb 100644--- a/scripts/mso-agent.mjs+++ b/scripts/mso-agent.mjs@@ -68,7 +68,17 @@ async function main() {statusBar: restartUi.statusBar ?? true, permission: forcedPermission, pendingApproval: null,};const rl = new AgentComposer({ input: process.stdin, output: process.stdout, colors: C }); syncPromptHistory(rl, session);- const localBridge = new LocalAgentBridge({ session, composer: rl });+ let inboundRequestQueued = false;+ const localBridge = new LocalAgentBridge({+ session,+ composer: rl,+ onRequest: () => {+ // A local request otherwise only becomes model context on the next manual+ // turn. Cancel the idle editor and let the main loop run it immediately.+ inboundRequestQueued = true;+ rl.cancelCurrent({ echo: false });+ },+ });await localBridge.start();const interrupts = new AgentInterruptManager({ output: process.stdout, colors: C });const onSigint = () => {@@ -85,6 +95,11 @@ async function main() {try {while (true) {if (interrupts.exitRequested) break;+ if (inboundRequestQueued) {+ inboundRequestQueued = false;+ await runInteractiveRound(rl, session, null, interrupts, localBridge);+ continue;+ }let line = "";try {const answer = await rl.question(() => composerPrompt(session, C), {@@ -93,7 +108,10 @@ async function main() {separator: () => composerSeparator(session, C, process.stdout.columns),footer: () => composerFooter(session, C, process.stdout.columns),});- if (answer === null) break;+ if (answer === null) {+ if (inboundRequestQueued) continue;+ break;+ }line = answer.trim();} catch { break; }if (!line) continue;