Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
fix(tui): slash commands do not light the "Processing" block
Salman Qureshib1da06c51d9e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5c4a097e..9bfe4e24 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,7 @@## Unreleased — instant attach+- **Slash commands no longer show "Processing".** `/memory`, `/bots`, `/help` and friends are answered without the model; the turn indicator and heartbeat are raised only when a command actually falls through to a model turn. (`/memory` opens a menu that stays open as long as you use it — with the spinner up it looked like a hung agent.)- **`mercury` attaches instantly to a running daemon.** The daemon binds its web listener *first* at boot (channels and bots come after), an unauthenticated loopback `/api/health` answers with pid/version/booting, and the launcher polls every 250 ms instead of 750 ms. A port owned by another process (an old global install, another Mercury) is now reported in one line — *Port 6174 is owned by another Mercury (PID …) — stop it or set web.port* — instead of a 15-second wait followed by a pointless restart. The web server also retries a busy port for 5 s, so a restart right after a stop no longer loses the dashboard.## Unreleased — bots in your pocket (ADR-023)diff --git a/src/core/agent.ts b/src/core/agent.tsindex d65fb2cc..3642b66c 100644--- a/src/core/agent.ts+++ b/src/core/agent.ts@@ -2262,9 +2262,20 @@ export class Agent {this.currentActivity = '';this.completedStepCount = 0;this.stepNarrative = [];- this.markProgress('Starting...');- this.pushLiveActivity('Starting task');- const stopHeartbeat = this.startForegroundHeartbeat(msg);+ // A slash command is handled below without the model: no "Processing"+ // block, no heartbeat — those are raised only if it falls through to a+ // real turn. (/memory opens a menu that blocks here for as long as it is+ // open; with the indicator up it read as a hung agent.)+ const isSlashCommand = msg.content.trim().startsWith('/');+ let turnIndicatorUp = false;+ const raiseTurnIndicator = (): void => {+ if (turnIndicatorUp) return;+ turnIndicatorUp = true;+ this.markProgress('Starting...');+ this.pushLiveActivity('Starting task');+ };+ if (!isSlashCommand) raiseTurnIndicator();+ const stopHeartbeat = isSlashCommand ? () => {} : this.startForegroundHeartbeat(msg);const heapBaseline = process.memoryUsage().heapUsed;const heapAbortThreshold = taskHeapAbortThreshold(getHeapStatistics().heap_size_limit, heapBaseline);const heapExitThreshold = taskHeapExitThreshold(getHeapStatistics().heap_size_limit, heapBaseline);@@ -2557,6 +2568,8 @@ export class Agent {// - Ambiguous (multiple contenders bunched near the top) → ask the// user to disambiguate before doing anything.// - No usable match → fall through to the normal LLM loop.+ // A command that reached the model is a real turn after all.+ raiseTurnIndicator();await this.routeSkillIntent(msg, trimmed, messages);this.lifecycle.transition('responding');diff --git a/src/core/slash-command-indicator.test.ts b/src/core/slash-command-indicator.test.tsnew file mode 100644index 00000000..6a33142f--- /dev/null+++ b/src/core/slash-command-indicator.test.ts@@ -0,0 +1,28 @@+import { describe, expect, it } from 'vitest';+import { readFileSync } from 'node:fs';+import { fileURLToPath } from 'node:url';+import { dirname, join } from 'node:path';++const agent = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'agent.ts'), 'utf8');++/**+ * A slash command must not light the "Processing" block or start the+ * foreground heartbeat: /memory, /bots, /help… are answered without the+ * model, and some (menus) block inside handleMessage for as long as the+ * user keeps them open. The indicator is raised only when a command falls+ * through to a real model turn.+ */+describe('slash commands do not show the processing indicator', () => {+ it('gates the turn indicator and heartbeat on the message not being a command', () => {+ const head = agent.slice(agent.indexOf('private async handleMessage('), agent.indexOf('const stopHeartbeat ='));+ expect(head).toContain("const isSlashCommand = msg.content.trim().startsWith('/')");+ expect(head).toContain('if (!isSlashCommand) raiseTurnIndicator();');+ expect(agent).toContain('const stopHeartbeat = isSlashCommand ? () => {} : this.startForegroundHeartbeat(msg);');+ });++ it('raises the indicator again right before a fallen-through command reaches the model', () => {+ const idx = agent.indexOf('await this.routeSkillIntent(msg, trimmed, messages);');+ expect(idx).toBeGreaterThan(0);+ expect(agent.slice(idx - 200, idx)).toContain('raiseTurnIndicator();');+ });+});