Bug Description
When ctx_execute (or ctx_execute_file / ctx_batch_execute) runs in Pi, the collapsed TUI rendering shows only the opening of a markdown code fence (e.g. triple-backtick shell) and nothing else — no command, no output, no closing fence. The tool executes correctly, but the user sees a blank-looking result.
Root Cause
buildExecuteEcho() in src/server.ts prepends a markdown code fence to every ctx_execute response:
(fence opening)shell
<code>
(fence closing)
<actual output>
createContextModeResultRenderer() in src/adapters/pi/mcp-bridge.ts handles Pi's collapsed (non-expanded) view by:
- Taking the full response text
- Splitting it by newlines
- Finding the first non-empty line
- If ≤ 180 chars, showing only that line
The first non-empty line is the opening of the code fence — the triple-backtick + language tag. So in collapsed mode, the user sees:
ctx_execute
(fence opening)shell
…and nothing else. The actual command, closing fence, and output are all hidden.
The same issue affects ctx_batch_execute (its formatCommandOutput prepends # <label>\n\n$ <cmd>\n\n).
Fix
PR: https://github.com/danyal002/context-mode/pull/1 (against next)
Added stripEchoPreamble() in src/adapters/pi/mcp-bridge.ts that strips both echo formats before finding the first meaningful line in collapsed mode. The full echo still reaches the LLM via execute() and survives in FTS5 indexed chunks — this only affects what the Pi TUI shows in collapsed mode.
Platform
Pi
context-mode version
1.0.169
Debug script output
ctx-debug JSON
{
"version": "2.0.0",
"generated": "2026-08-27T15:25:28Z",
"sections": {
"1. System Info": {
"info": {
"OS type": "macos",
"uname -a": "Darwin COMP-K6MPF72D33 25.5.0 Darwin Kernel Version 25.5.0 arm64",
"Architecture": "arm64",
"macOS version": "26.5.1 (25F80)",
"Shell": "/bin/zsh"
}
},
"2. Runtime Versions": {
"info": {
"Node.js": "v26.5.0",
"Python": "Python 3.10.13",
"npm": "11.17.0"
}
},
"3. context-mode Installation": {
"info": {
"Installed version": "1.0.169",
"Plugin root": "/Users/danyal.khan/context-mode",
"Install method": "git clone / manual",
"npm latest": "1.0.169"
}
},
"4. better-sqlite3 Native Module": {
"checks": [
{ "pass": true, "label": "better-sqlite3 .node binary exists" },
{ "pass": true, "label": "require('better-sqlite3') succeeds" }
]
}
}
}
Exact prompt that triggered the bug
Any prompt that causes the agent to use ctx_execute with language: "shell". For example:
"Run ls -la using ctx_execute"
Full error output
Not a crash — the tool executes successfully. The bug is in the TUI rendering: the collapsed renderResult displays only the code fence opening (triple-backtick + shell) from the echo preamble instead of a meaningful summary line.
Steps to reproduce
- Start a Pi session with context-mode v1.0.169
- Send any prompt that triggers
ctx_execute with language: "shell" (e.g. "Use ctx_execute to run: echo hello")
- Observe the TUI — the tool result area shows only the fence opening with no command or output visible
- Expand the tool result (if possible) — the full output including echo and result is visible in expanded mode
Expected behavior
The collapsed view should show the first meaningful line of actual output (e.g. hello for echo hello), not the markdown code fence opening.
Related issues
Bug Description
When
ctx_execute(orctx_execute_file/ctx_batch_execute) runs in Pi, the collapsed TUI rendering shows only the opening of a markdown code fence (e.g. triple-backtick shell) and nothing else — no command, no output, no closing fence. The tool executes correctly, but the user sees a blank-looking result.Root Cause
buildExecuteEcho()insrc/server.tsprepends a markdown code fence to everyctx_executeresponse:createContextModeResultRenderer()insrc/adapters/pi/mcp-bridge.tshandles Pi's collapsed (non-expanded) view by:The first non-empty line is the opening of the code fence — the triple-backtick + language tag. So in collapsed mode, the user sees:
…and nothing else. The actual command, closing fence, and output are all hidden.
The same issue affects
ctx_batch_execute(itsformatCommandOutputprepends# <label>\n\n$ <cmd>\n\n).Fix
PR: https://github.com/danyal002/context-mode/pull/1 (against
next)Added
stripEchoPreamble()insrc/adapters/pi/mcp-bridge.tsthat strips both echo formats before finding the first meaningful line in collapsed mode. The full echo still reaches the LLM viaexecute()and survives in FTS5 indexed chunks — this only affects what the Pi TUI shows in collapsed mode.Platform
Pi
context-mode version
1.0.169
Debug script output
ctx-debug JSON
{ "version": "2.0.0", "generated": "2026-08-27T15:25:28Z", "sections": { "1. System Info": { "info": { "OS type": "macos", "uname -a": "Darwin COMP-K6MPF72D33 25.5.0 Darwin Kernel Version 25.5.0 arm64", "Architecture": "arm64", "macOS version": "26.5.1 (25F80)", "Shell": "/bin/zsh" } }, "2. Runtime Versions": { "info": { "Node.js": "v26.5.0", "Python": "Python 3.10.13", "npm": "11.17.0" } }, "3. context-mode Installation": { "info": { "Installed version": "1.0.169", "Plugin root": "/Users/danyal.khan/context-mode", "Install method": "git clone / manual", "npm latest": "1.0.169" } }, "4. better-sqlite3 Native Module": { "checks": [ { "pass": true, "label": "better-sqlite3 .node binary exists" }, { "pass": true, "label": "require('better-sqlite3') succeeds" } ] } } }Exact prompt that triggered the bug
Any prompt that causes the agent to use
ctx_executewithlanguage: "shell". For example:Full error output
Not a crash — the tool executes successfully. The bug is in the TUI rendering: the collapsed
renderResultdisplays only the code fence opening (triple-backtick + shell) from the echo preamble instead of a meaningful summary line.Steps to reproduce
ctx_executewithlanguage: "shell"(e.g. "Use ctx_execute to run: echo hello")Expected behavior
The collapsed view should show the first meaningful line of actual output (e.g.
helloforecho hello), not the markdown code fence opening.Related issues
piwithTool output: expanded#1088 — [Feature]: show tool input in pi with Tool output: expanded (related — user reports tool input not visible)