Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
Fix three regressions in conversation process-info rendering
wyt8b59dbfb1c5f
diff --git a/src/main/model/core-agent/event-mapper.ts b/src/main/model/core-agent/event-mapper.tsindex 4dbe1ceb..c3c535c6 100644--- a/src/main/model/core-agent/event-mapper.ts+++ b/src/main/model/core-agent/event-mapper.ts@@ -42,34 +42,6 @@ function resultPreview(s: string, max = 300): string {return oneLine.length > max ? oneLine.slice(0, max) + '…' : oneLine;}-/**- * Pick the most human-readable slice of a tool's input for the single-line- * progress log: bash → command, read/write/list → path, otherwise JSON.- * The full `input` is still forwarded on the structured event so the UI- * can render it richer if it wants to.- */-function inputSummary(name: string, input: unknown, max = 80): string {- if (input == null) return '';- const pick = (v: unknown): string => {- if (typeof v === 'string') return v;- if (typeof v === 'number' || typeof v === 'boolean') return String(v);- return '';- };- let raw = '';- if (input && typeof input === 'object') {- const rec = input as Record<string, unknown>;- if (name === 'bash') raw = pick(rec.command);- else if (name === 'read_file' || name === 'write_file' || name === 'list_files') raw = pick(rec.path);- if (!raw) {- try { raw = JSON.stringify(input); } catch { raw = String(input); }- }- } else {- raw = String(input);- }- const oneLine = raw.replace(/\s+/g, ' ').trim();- return oneLine.length > max ? oneLine.slice(0, max) + '…' : oneLine;-}-/*** Translate a raw retry reason (usually `err.message` from core-agent) into* a short user-facing phrase. The raw strings come from undici / pi-ai /@@ -137,7 +109,6 @@ export async function* mapCoreAgentEvents(}case 'tool_start': {- const argStr = inputSummary(ev.name, ev.input);yield {type: 'event',event: {@@ -145,10 +116,12 @@ export async function* mapCoreAgentEvents(data: { phase: 'start', id: ev.id, name: ev.name, arguments: ev.input },},};- yield {- type: 'progress',- text: argStr ? `▶ ${ev.name} · ${argStr}` : `▶ ${ev.name}`,- };+ // The renderer formats the `tool` stream event into a single+ // `■ ${name} · ${phase} · ${detail}` line via `_formatEventLine`.+ // We used to also yield a parallel `progress: ▶ ${name} · ${arg}`+ // line that carried the same info — that produced duplicate rows+ // (one ■ and one ▶) for every tool call. Trust the event-stream+ // rendering as the single source of truth.break;}@@ -167,13 +140,11 @@ export async function* mapCoreAgentEvents(},},};- const shortPreview = preview.length > 80 ? preview.slice(0, 80) + '…' : preview;- const marker = ev.isError ? '✗' : '✓';- const tail = shortPreview ? ` · ${shortPreview}` : (ev.isError ? ' failed' : '');- yield {- type: 'progress',- text: `${marker} ${ev.name}${tail}`,- };+ // Same dedupe rationale as `tool_start`: the renderer renders the+ // `tool` end event as `■ name · <phase_end> · preview` (or+ // `✗ ...` on isError), where <phase_end> is i18n-resolved by+ // `_formatEventLine::phaseCn`, so the parallel+ // `✓ ${name} · ${preview}` progress yield was a duplicate. Removed.// Next assistant text turn (if any) should be visually separated// from the previous one — matches the old "join turns with \n\n" rule.if (turnStarted) pendingSeparator = true;diff --git a/src/renderer/modules/conversation.js b/src/renderer/modules/conversation.jsindex 6aa7b81c..dcfd3300 100644--- a/src/renderer/modules/conversation.js+++ b/src/renderer/modules/conversation.js@@ -1348,11 +1348,73 @@ function _scrollToBottomNoAnim(container) {const prev = container.style.scrollBehavior;container.style.scrollBehavior = 'auto';container.scrollTop = container.scrollHeight;+ // Explicit jump-to-bottom = the user is now pinned to the bottom; arm+ // the sticky-follow flag so subsequent stream content keeps tracking.+ container._stickyEnabled = true;+ _bindStickToBottom(container);requestAnimationFrame(() => {container.style.scrollBehavior = prev || '';});}+// ─── Sticky-bottom auto-scroll ─────────────────────────────────────────────+// Track per-container "is the user pinned to the bottom?" so streaming+// content (process info / token deltas / new bubbles) auto-scrolls down+// only while the user wants to follow. Mid-stream scroll-up suspends+// auto-stick; scrolling back to (near) bottom resumes it. Tab-switch back+// re-applies the stick if it was on at the moment of going hidden.+//+// Why a threshold (32 px) instead of strict equality: programmatic scrolls+// (`scrollTop = scrollHeight`) and Chromium's sub-pixel rounding leave a+// 1–2 px gap that would otherwise toggle the flag off on the first scroll+// event. 32 px is comfortable for the user too — being "almost at bottom"+// counts as following.+const STICKY_BOTTOM_THRESHOLD = 32;+function _isNearBottom(el) {+ if (!el) return true;+ return (el.scrollHeight - el.scrollTop - el.clientHeight) <= STICKY_BOTTOM_THRESHOLD;+}+function _bindStickToBottom(el) {+ if (!el || el._stickyBound) return;+ el._stickyBound = true;+ if (el._stickyEnabled === undefined) el._stickyEnabled = true;+ el.addEventListener('scroll', () => {+ el._stickyEnabled = _isNearBottom(el);+ }, { passive: true });+}+// Scroll the container to the bottom, but only if the user hasn't scrolled+// up. Safe to call after every DOM mutation that adds height — the no-op+// branch (sticky off) lets the user keep reading process info undisturbed.+function _stickBottomIfPinned(el) {+ if (!el) return;+ if (el._stickyEnabled === false) return;+ el.scrollTop = el.scrollHeight;+}+// Convenience for stream handlers that hold a `msg` element. The container+// is whatever element the bubble lives in (chat-history for the main conv,+// or a skill/agent edit chat's messages box) — same generic stickiness+// applies to all of them.+function _stickBottomFromMsg(msg) {+ if (!msg) return;+ _stickBottomIfPinned(msg.parentElement);+}++// Tab visibility: while the renderer is hidden, scroll events don't fire+// and stream content piles up below the fold. On return, if the user was+// pinned to the bottom before going hidden, jump to the latest content so+// the conversation tracks live again.+if (typeof document !== 'undefined') {+ document.addEventListener('visibilitychange', () => {+ if (document.visibilityState !== 'visible') return;+ // Cover every chat history surface (main conv + skill/agent edit chats).+ const ids = ['chat-history', 'skills-chat-messages', 'agents-chat-messages'];+ for (const id of ids) {+ const el = document.getElementById(id);+ if (el && el._stickyEnabled !== false) _stickBottomIfPinned(el);+ }+ });+}+function appendChatMessage(message, autoScroll = true, opts = {}) {const container = opts.container? (typeof opts.container === 'string' ? document.getElementById(opts.container) : opts.container)@@ -1475,7 +1537,15 @@ function appendChatMessage(message, autoScroll = true, opts = {}) {}}- if (autoScroll) container.scrollTop = container.scrollHeight;+ if (autoScroll) {+ // Respect the user's scroll position: only follow if they were already+ // pinned to the bottom (sticky on). This preserves the legacy "new+ // message arrives → snap to bottom" behaviour for users who were+ // following, without yanking users who scrolled up to read older+ // process info. _bindStickToBottom is a no-op after first bind.+ _bindStickToBottom(container);+ _stickBottomIfPinned(container);+ }return msgDiv;}@@ -2161,16 +2231,24 @@ function _hideThinking(msg) {}// Map the leading glyph of a formatted line to a semantic CSS class so the-// stylesheet can tone errors red, approvals amber, etc.+// stylesheet can tone errors red, tool calls blue, etc. The full glyph+// palette + which event each one comes from is documented at the top of+// `_formatEventLine`. Keep the two in sync — adding a new glyph there+// without an entry here means the line renders in the default body color+// (the muted slate baseline), which is what produced the "everything is+// gray" look users complained about for CLI output.function _processKindOf(text) {const g = (text || '').trimStart().charAt(0);- if (g === '◯') return 'err';- if (g === '○') return 'warn';- if (g === '◉') return 'patch';- if (g === '■') return 'tool';- if (g === '▷') return 'out';- if (g === '◆' || g === '◇') return 'think';- if (g === '▶' || g === '●') return 'bound';+ if (g === '◯' || g === '✗') return 'err'; // hard error / failed tool end+ if (g === '○') return 'warn'; // awaiting approval / soft warn+ if (g === '◉') return 'patch'; // file change+ if (g === '■') return 'tool'; // tool call (start / end ok)+ if (g === '▷') return 'out'; // command / cli stdout-or-stderr+ if (g === '◆' || g === '◇') return 'think'; // reasoning / reply marker+ if (g === '▶' || g === '●') return 'bound'; // lifecycle start / end+ if (g === '▣') return 'plan'; // plan announcement+ if (g === '◐') return 'live'; // live generating preview+ if (g === '▪') return 'meta'; // lifecycle / fallback metareturn '';}@@ -2189,6 +2267,10 @@ function _streamingAppendProgress(msg, text) {body.appendChild(line);// Auto-scroll only within the process areabody.scrollTop = body.scrollHeight;+ // Outer chat-history follows too, so the user can read the latest line+ // without manually scrolling. _stickBottomIfPinned no-ops when the user+ // has scrolled up to read older process output.+ _stickBottomFromMsg(msg);}// Cancel any rAF queued by `_streamingAppendFinalDelta`. Callers that are@@ -2216,6 +2298,11 @@ function _streamingSetFinal(msg, text, { archive = false } = {}) {const finalEl = msg.querySelector('[data-role="final"]');if (!finalEl) return;_cancelPendingStreamRaf(msg);+ // Keep the user pinned through the placeholder → final-markdown swap+ // (collapsing the process pane changes scrollHeight). The helper no-ops+ // when the user has scrolled up to read; here that's the expected+ // behaviour — finalize shouldn't yank a reader back to the bottom.+ _stickBottomFromMsg(msg);// Always repaint on final: during streaming the DOM may contain// placeholder markers (from `_stripAgentCreateBlocksForStream` etc.)// that need to be replaced with the backend-cleaned prose. A previous@@ -3450,6 +3537,9 @@ function _streamingAppendFinalDelta(msg, piece) {),);finalEl.innerHTML = `<div class="markdown-body">${_renderMessageMarkdown(display)}</div>`;+ // Token deltas grow the bubble; keep the user pinned to the latest+ // text if they were following along (no-op once they scroll up).+ _stickBottomFromMsg(msg);};if (typeof requestAnimationFrame === 'function') {msg._streamRafHandle = requestAnimationFrame(flush);@@ -3548,8 +3638,19 @@ function _formatEventLine(evt) {}if (stream === 'command_output') {- const text = data?.text || data?.stdout || data?.stderr || '';- return text ? `▷ ${text}` : t('chat.stream.command_empty');+ // Distinguish stderr from stdout so CLI agents (claude code / codex /+ // openclaw / opencode / hermes) don't render their entire spool in a+ // single muted slate. We keep ▷ for stdout, swap to ○ (kind-warn,+ // amber) for stderr — many CLIs route progress and prompts to stderr,+ // so we stop short of treating it as a hard error (◯) which would dye+ // the whole sub-stream red. Falls back to stdout styling if the event+ // doesn't disambiguate via separate stdout/stderr fields.+ const stdout = data?.stdout;+ const stderr = data?.stderr;+ const text = data?.text || stdout || stderr || '';+ if (!text) return t('chat.stream.command_empty');+ const isStderrOnly = !stdout && stderr;+ return isStderrOnly ? `○ ${text}` : `▷ ${text}`;}if (stream === 'patch') {@@ -3581,6 +3682,59 @@ function _formatEventLine(evt) {return null;}+ // CLI-backed agents (claude code / codex / openclaw / opencode / hermes)+ // emit `LocalEvent`s that bus.ts wraps verbatim as `{stream:'cli', data:e}`.+ // Without this branch the catch-all below dumped them as+ // `▪ cli {json}` which is (a) unreadable JSON and (b) lands in+ // kind-meta — exactly the "all gray" symptom users see for CLI runs.+ // Field shapes mirror `local_agents/backends/base.ts::LocalEvent`.+ if (stream === 'cli') {+ const cliType = String(data?.type || '').toLowerCase();+ if (cliType === 'tool-event') {+ const name = String(data?.tool || 'tool');+ const isResult = data?.phase === 'result';+ const phase = phaseCn(isResult ? 'end' : 'start');+ let detail = '';+ if (isResult && data?.output != null) {+ detail = typeof data.output === 'string' ? data.output : JSON.stringify(data.output);+ } else if (data?.input != null) {+ detail = typeof data.input === 'string' ? data.input : JSON.stringify(data.input);+ }+ detail = detail.replace(/\s+/g, ' ').trim();+ if (detail.length > 160) detail = detail.slice(0, 160) + '…';+ const detailStr = detail ? ' · ' + detail : '';+ return `■ ${name}${phase ? ' · ' + phase : ''}${detailStr}`;+ }+ if (cliType === 'process-info') {+ // Fired once at CLI spawn; surface as a milestone so the user sees+ // the run starting. cmd/args is enough — full cwd is noisy.+ const cmd = String(data?.cmd || '').trim();+ return cmd ? `▶ ${cmd}` : null;+ }+ if (cliType === 'status') {+ // Bucket statuses into milestone (▶/●), warn (○) and error (◯) so+ // they pick up the right kind class downstream.+ const st = String(data?.status || '').toLowerCase();+ if (!st) return null;+ if (st === 'session_ready' || st === 'running') return `▶ ${st}`;+ if (st === 'result' || st === 'completed') return `● ${st}`;+ if (st === 'error' || st === 'failed' || st === 'timeout') return `◯ ${st}`;+ if (st === 'cancelled' || st === 'aborted') return `○ ${st}`;+ return `▪ ${st}`;+ }+ if (cliType === 'stderr-line') {+ // CLIs route progress + diagnostics to stderr — treat as soft warn+ // (○, kind-warn amber) rather than a hard error (◯, kind-err red),+ // matching the heuristic we use for `command_output` stderr above.+ const line = String(data?.line || '').replace(/\s+/g, ' ').trim();+ if (!line) return null;+ const trimmed = line.length > 160 ? line.slice(0, 160) + '…' : line;+ return `○ ${trimmed}`;+ }+ // Unknown CLI event types: hide rather than dump JSON.+ return null;+ }+return `▪ ${stream} ${JSON.stringify(data || {})}`;}@@ -3629,6 +3783,7 @@ function _streamingUpdateLive(msg, prefix, text, appendDelta) {const preview = msg._liveBuf.length > 200 ? '…' + msg._liveBuf.slice(-200) : msg._liveBuf;line.textContent = prefix + preview;body.scrollTop = body.scrollHeight;+ _stickBottomFromMsg(msg);}// Update the loading element (wherever it currently lives in DOM) with the reply.diff --git a/src/renderer/style.css b/src/renderer/style.cssindex fa8434cf..792315aa 100644--- a/src/renderer/style.css+++ b/src/renderer/style.css@@ -2711,7 +2711,7 @@ body.model-not-configured .main-content { flex-direction: column; }.stream-process {margin-bottom: 8px;- border-left: 2px solid #e5e7eb;+ border-left: 2px solid #cbd5e1;padding-left: 10px;}.stream-process:not([open]) { margin-bottom: 0; }@@ -2719,7 +2719,7 @@ body.model-not-configured .main-content { flex-direction: column; }cursor: pointer;list-style: none;font-size: 12px;- color: #6b7280;+ color: #475569;padding: 2px 0;user-select: none;display: flex;@@ -2736,7 +2736,7 @@ body.model-not-configured .main-content { flex-direction: column; }width: 16px;font-size: 13px;line-height: 1;- color: #6b7280;+ color: #475569;transition: transform 0.15s;}.stream-process[open] .stream-process-summary::before {@@ -2751,6 +2751,9 @@ body.model-not-configured .main-content { flex-direction: column; }padding: 4px 0;font-size: 11.5px;line-height: 1.55;+ /* Default body color = the Normal tier (see ramp below). Lines whose+ leading glyph isn't recognized by `_processKindOf` fall through to+ this baseline and read as supporting context. */color: #94a3b8;font-family: ui-monospace, SFMono-Regular, monospace;/* Force text-style rendering for symbols like ▶ ✓ ◆ ⚙ ▸ ✎ — otherwise@@ -2765,13 +2768,37 @@ body.model-not-configured .main-content { flex-direction: column; }white-space: pre-wrap;word-break: break-all;}-.stream-process-line.kind-err { color: #b91c1c; }-.stream-process-line.kind-warn { color: #b45309; }-.stream-process-line.kind-patch { color: #047857; }-.stream-process-line.kind-tool { color: #475569; }-.stream-process-line.kind-out { color: #64748b; }-.stream-process-line.kind-think { color: #6366f1; }-.stream-process-line.kind-bound { color: #334155; font-weight: 500; }+/* Four-tier hierarchy. The constraint: every content line must be+ visually LIGHTER than the section header (`.stream-process-summary`,+ slate-600 #475569 + 600) — content is supporting detail, the header+ is the label. An earlier pass had bound/tool lines at slate-900 + 600+ which inverted the hierarchy (content darker than its own label).+ Tiers:+ 1. Core — milestones / tool calls / plans / file edits;+ slate-500 + 500 weight. Distinguishable at a glance+ but still a notch below the header.+ 2. Normal — reasoning, live preview, stdout, meta; slate-400.+ Same as the body baseline so unrecognized lines+ read as plain text, not "missing styling".+ 3. Warn — awaiting approval / cli stderr. Kept as its own+ hue (light amber) because (a) red would over-alarm+ benign cli progress messages routed through stderr,+ and (b) folding into Normal loses the "someone is+ waiting on you" signal at the rail level.+ 4. Error — hard error / failed tool; red-500 + 500 weight.+ Glyphs in `_processKindOf` map into these classes — adding a new+ glyph there needs a matching rule here, otherwise the line falls+ back to the Normal baseline. */+.stream-process-line.kind-bound { color: #64748b; font-weight: 500; } /* ▶ ● lifecycle milestones */+.stream-process-line.kind-tool { color: #64748b; font-weight: 500; } /* ■ tool call */+.stream-process-line.kind-plan { color: #64748b; font-weight: 500; } /* ▣ plan announcement */+.stream-process-line.kind-patch { color: #64748b; font-weight: 500; } /* ◉ file change */+.stream-process-line.kind-think { color: #94a3b8; } /* ◆ ◇ reasoning / reply markers */+.stream-process-line.kind-live { color: #94a3b8; } /* ◐ live generating */+.stream-process-line.kind-out { color: #94a3b8; } /* ▷ command stdout */+.stream-process-line.kind-meta { color: #94a3b8; } /* ▪ fallback / lifecycle meta */+.stream-process-line.kind-warn { color: #d97706; } /* ○ awaiting approval / cli stderr */+.stream-process-line.kind-err { color: #ef4444; font-weight: 500; } /* ◯ ✗ hard error / failed tool */.stream-final {/* Appears below process section with a subtle divider when process is open */diff --git a/test/main/model/event-mapper.test.ts b/test/main/model/event-mapper.test.tsindex b18c5eab..438aa821 100644--- a/test/main/model/event-mapper.test.ts+++ b/test/main/model/event-mapper.test.ts@@ -23,8 +23,15 @@ async function collect(events: AgentRunEvent[]) {return out;}-describe('event-mapper › tool_start forwards input + summarizes progress', () => {- it('bash tool → progress shows the command, event carries full arguments', async () => {+describe('event-mapper › tool_start / tool_end emit a single structured event', () => {+ // The mapper used to yield both a `progress` text (▶ name · arg / ✓ name ·+ // preview) AND a structured `event` with the same info; the renderer+ // formatted both, producing duplicate rows in the process pane (one ■ from+ // the event branch, one ▶ or ✓ from the progress branch). The contract is+ // now: `tool_start` / `tool_end` yield ONE `event` only — formatting is the+ // renderer's job (`_formatEventLine`'s `tool` branch).++ it('bash tool → single event carries the full input + result preview', async () => {const out = await collect([{ type: 'tool_start', name: 'bash', id: 'c1', input: { command: 'curl -sSL https://example.com/article' } },{ type: 'tool_end', name: 'bash', id: 'c1', result: 'HTTP/1.1 200 OK\n\n<html>…</html>' },@@ -39,32 +46,28 @@ describe('event-mapper › tool_start forwards input + summarizes progress', ()expect(startEvent.event.data.name).toBe('bash');expect(startEvent.event.data.arguments).toEqual({ command: 'curl -sSL https://example.com/article' });- const startProgress = out.find(- (e) => e.type === 'progress' && typeof e.text === 'string' && e.text.startsWith('▶ bash'),- );- expect(startProgress).toBeDefined();- expect(startProgress.text).toContain('curl -sSL https://example.com/article');-const endEvent = out.find((e) => e.type === 'event' && e.event?.data?.phase === 'end');expect(endEvent.event.data.result_preview).toContain('HTTP/1.1 200 OK');expect(endEvent.event.data.isError).toBe(false);- const endProgress = out.find(- (e) => e.type === 'progress' && typeof e.text === 'string' && e.text.startsWith('✓ bash'),+ // No parallel `progress` rows for tool_start / tool_end. (Other yields+ // like `retry` still produce progress text — they're tested below.)+ const toolProgress = out.filter(+ (e) => e.type === 'progress' && typeof e.text === 'string'+ && (e.text.startsWith('▶ bash') || e.text.startsWith('✓ bash') || e.text.startsWith('✗ bash')),);- expect(endProgress.text).toContain('HTTP/1.1 200 OK');+ expect(toolProgress).toEqual([]);});- it('read_file tool → progress shows the path', async () => {+ it('read_file tool → start event carries the path on `arguments`', async () => {const out = await collect([{ type: 'tool_start', name: 'read_file', id: 'c2', input: { path: '/tmp/foo.md' } },{ type: 'tool_end', name: 'read_file', id: 'c2', result: 'hello' },{ type: 'done', result: { text: '', meta: { error: null } } },]);- const startProgress = out.find(- (e) => e.type === 'progress' && typeof e.text === 'string' && e.text.startsWith('▶ read_file'),- );- expect(startProgress.text).toContain('/tmp/foo.md');+ const startEvent = out.find((e) => e.type === 'event' && e.event?.data?.phase === 'start');+ expect(startEvent.event.data.name).toBe('read_file');+ expect(startEvent.event.data.arguments).toEqual({ path: '/tmp/foo.md' });});it('retry event → friendly Chinese progress, raw reason not leaked', async () => {@@ -93,17 +96,15 @@ describe('event-mapper › tool_start forwards input + summarizes progress', ()expect(retryProgress.text).toBe('Retry attempt 2·Connection dropped');});- it('tool_end with isError → progress uses ✗ marker and carries preview', async () => {+ it('tool_end with isError → end event flags isError + carries preview', async () => {const out = await collect([{ type: 'tool_start', name: 'bash', id: 'c3', input: { command: 'false' } },{ type: 'tool_end', name: 'bash', id: 'c3', result: 'exit 1: command failed', isError: true },{ type: 'done', result: { text: '', meta: { error: null } } },]);- const endProgress = out.find(- (e) => e.type === 'progress' && typeof e.text === 'string' && e.text.startsWith('✗ bash'),- );- expect(endProgress).toBeDefined();- expect(endProgress.text).toContain('exit 1');+ const endEvent = out.find((e) => e.type === 'event' && e.event?.data?.phase === 'end');+ expect(endEvent.event.data.isError).toBe(true);+ expect(endEvent.event.data.result_preview).toContain('exit 1');});});