Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
feat: implement TTY raw mode watchdog and scope workspace-specific LLM context and navigation commands
Salman Qureshi87f05201a0d4
diff --git a/src/channels/cli.ts b/src/channels/cli.tsindex dd0746de..88df4d65 100644--- a/src/channels/cli.ts+++ b/src/channels/cli.ts@@ -65,6 +65,7 @@ export class CLIChannel extends BaseChannel {private stepStartTime = 0;private state: TuiState = { ...defaultState };private spotifyClient: any = null;+ private rawModeWatchdog: NodeJS.Timeout | null = null;constructor(agentName: string = 'Mercury') {super();@@ -83,11 +84,52 @@ export class CLIChannel extends BaseChannel {}async stop(): Promise<void> {+ this.stopRawModeWatchdog();this.inkInstance?.unmount();this.inkInstance = null;+ this.releaseRawMode();this.ready = false;}+ private ensureRawMode(): void {+ if (!process.stdin.isTTY) return;+ const stdin = process.stdin as NodeJS.ReadStream;+ if (typeof stdin.setRawMode !== 'function') return;+ try {+ stdin.setRawMode(true);+ stdin.resume();+ } catch {+ // Ignore transient raw mode failures.+ }+ }++ private releaseRawMode(): void {+ if (!process.stdin.isTTY) return;+ const stdin = process.stdin as NodeJS.ReadStream;+ if (typeof stdin.setRawMode !== 'function') return;+ try {+ stdin.setRawMode(false);+ } catch {+ // Ignore teardown failures.+ }+ }++ private startRawModeWatchdog(): void {+ this.stopRawModeWatchdog();+ this.ensureRawMode();+ this.rawModeWatchdog = setInterval(() => {+ if (!this.inkInstance) return;+ this.ensureRawMode();+ }, 250);+ }++ private stopRawModeWatchdog(): void {+ if (this.rawModeWatchdog) {+ clearInterval(this.rawModeWatchdog);+ this.rawModeWatchdog = null;+ }+ }+private update(partial: Partial<TuiState>): void {this.state = { ...this.state, ...partial };this.rerender();@@ -107,8 +149,10 @@ export class CLIChannel extends BaseChannel {this.update({ permissionPrompt: null });},onExit: () => {+ this.stopRawModeWatchdog();this.inkInstance?.unmount();this.inkInstance = null;+ this.releaseRawMode();this.exitHandler?.();},spotifyClient: this.spotifyClient,@@ -197,14 +241,18 @@ export class CLIChannel extends BaseChannel {this.update({ permissionPrompt: null });},onExit: () => {+ this.stopRawModeWatchdog();this.inkInstance?.unmount();this.inkInstance = null;+ this.releaseRawMode();this.exitHandler?.();},spotifyClient: this.spotifyClient,}),{ exitOnCtrlC: false, patchConsole: false },);++ this.startRawModeWatchdog();}async send(content: string, _targetId?: string, _elapsedMs?: number): Promise<void> {@@ -341,6 +389,7 @@ export class CLIChannel extends BaseChannel {if (this.menuDepth === 0) {this.menuAbortController = null;}+ this.ensureRawMode();}}diff --git a/src/core/agent.ts b/src/core/agent.tsindex 10fe5163..094aa0ee 100644--- a/src/core/agent.ts+++ b/src/core/agent.ts@@ -246,6 +246,7 @@ class ToolCallLoopDetector {}const MAX_STEPS = 10;+const MAX_RESPONSE_TOKENS = 1600;export class Agent {readonly lifecycle: Lifecycle;@@ -772,6 +773,10 @@ export class Agent {const systemPrompt = this.buildSystemPrompt();const recentMemory = this.shortTerm.getRecent(msg.channelId, 10);+ const cliChannel = msg.channelType === 'cli' ? this.channels.get('cli') : null;+ const workspace = cliChannel && cliChannel instanceof CLIChannel ? cliChannel.getWorkspace() : null;+ const isWorkspaceScoped = Boolean(workspace?.active);+ const workspacePath = workspace?.rootPath || this.capabilities.getCwd();const messages: any[] = [];@@ -816,7 +821,7 @@ export class Agent {messages.push({ role: 'assistant', content: 'Acknowledged. I will stop repeating and respond differently, or clearly state if the task cannot be completed.' });}- if (this.userMemory) {+ if (!isWorkspaceScoped && this.userMemory) {const memoryContext = this.userMemory.retrieveRelevant(msg.content, { maxRecords: 5, maxChars: 900 });if (memoryContext.context) {messages.push({@@ -825,7 +830,7 @@ export class Agent {});messages.push({ role: 'assistant', content: 'Noted. I\'ll keep this in mind.' });}- } else {+ } else if (!isWorkspaceScoped) {const relevantFacts = this.longTerm.search(msg.content, 3);if (relevantFacts.length > 0) {messages.push({@@ -836,7 +841,15 @@ export class Agent {}}- if (recentMemory.length > 0) {+ if (isWorkspaceScoped) {+ messages.push({+ role: 'user',+ content: `Workspace IDE mode is active for project: ${workspacePath}. Treat this as a coding-only session for this repository. Ignore unrelated personal/history context (music, casual chat, prior non-code tasks). If the user asks a non-coding question, redirect briefly to repository-focused help.`,+ });+ messages.push({ role: 'assistant', content: 'Understood. I will stay scoped to this repository and coding tasks only.' });+ }++ if (!isWorkspaceScoped && recentMemory.length > 0) {for (const m of recentMemory) {messages.push({role: m.role === 'user' ? 'user' : 'assistant',@@ -890,6 +903,7 @@ export class Agent {system: systemPrompt,messages,tools: this.capabilities.getTools(),+ maxOutputTokens: MAX_RESPONSE_TOKENS,stopWhen: stepCountIs(MAX_STEPS),abortSignal: loopAbortController.signal,...(deepseekProviderOptions ? { providerOptions: deepseekProviderOptions } : {}),@@ -1055,6 +1069,7 @@ export class Agent {system: systemPrompt,messages,tools: this.capabilities.getTools(),+ maxOutputTokens: MAX_RESPONSE_TOKENS,stopWhen: stepCountIs(MAX_STEPS),abortSignal: loopAbortController.signal,...(deepseekProviderOptions ? { providerOptions: deepseekProviderOptions } : {}),@@ -2506,13 +2521,12 @@ Always specify owner and repo parameters on GitHub tools. The user's GitHub userconst channel = this.channels.get(channelType as any);if (!channel || channelType !== 'cli' || !(channel instanceof CLIChannel)) return false;- const lower = content.toLowerCase();- if (!lower.includes('workspace')) return false;- if (!(lower.includes('open') || lower.includes('use') || lower.includes('enter'))) return false;+ const trimmed = content.trim();+ const commandMatch = trimmed.match(/^(?:open|use|enter)\s+workspace(?:\s+(.+))?$/i);+ if (!commandMatch) return false;- const pathMatch = content.match(/(?:open|use|workspace)\s+(?:at\s+|in\s+)?([^,.;]+)$/i);- const targetRaw = (pathMatch?.[1] || '').trim();- const target = targetRaw && !targetRaw.startsWith('workspace') ? targetRaw : this.capabilities.getCwd();+ const targetRaw = (commandMatch[1] || '').trim();+ const target = targetRaw || this.capabilities.getCwd();const opened = channel.openWorkspace(target);if (!opened.ok) {await channel.send(opened.message, channelId);diff --git a/src/ui/App.tsx b/src/ui/App.tsxindex c74f554e..ca01b167 100644--- a/src/ui/App.tsx+++ b/src/ui/App.tsx@@ -77,8 +77,6 @@ export function TuiApp({ state, onInput, onPermissionResolve, onExit, spotifyCliconst [workspacePane, setWorkspacePane] = React.useState<'files' | 'details' | 'git'>('files');const [detailCursor, setDetailCursor] = React.useState(0);const [gitCursor, setGitCursor] = React.useState(0);- const [workspaceLeaderActive, setWorkspaceLeaderActive] = React.useState(false);- const workspaceLeaderTimeoutRef = React.useRef<NodeJS.Timeout | null>(null);const slashCommands = React.useMemo(() => ['/help',@@ -172,6 +170,11 @@ export function TuiApp({ state, onInput, onPermissionResolve, onExit, spotifyCliuseInput((ch, key) => {const keyChar = (ch || (key as any)?.name || '').toLowerCase();+ if (ch === '\u0003' || (key.ctrl && ((key as any).name === 'c' || ch?.toLowerCase?.() === 'c'))) {+ onExit();+ return;+ }+if (state.mode === 'splash') {if (ch === 'd' || ch === 'D') {setShowStartupDetails((v) => !v);@@ -262,67 +265,54 @@ export function TuiApp({ state, onInput, onPermissionResolve, onExit, spotifyClireturn;}- if (state.mode === 'workspace') {- if (!key.ctrl && !key.meta && ch === ';' && input.length === 0) {- setWorkspaceLeaderActive(true);- if (workspaceLeaderTimeoutRef.current) clearTimeout(workspaceLeaderTimeoutRef.current);- workspaceLeaderTimeoutRef.current = setTimeout(() => {- setWorkspaceLeaderActive(false);- workspaceLeaderTimeoutRef.current = null;- }, 1600);+ if (key.return) {+ const trimmed = input.trim();+ if (trimmed) {+ onInput(trimmed);+ setInputHistory((prev) => {+ if (prev[prev.length - 1] === trimmed) return prev;+ return [...prev.slice(-99), trimmed];+ });+ setHistoryIndex(-1);+ setHistoryDraft('');+ setInput('');return;}+ }- if (workspaceLeaderActive) {- if (workspaceLeaderTimeoutRef.current) {- clearTimeout(workspaceLeaderTimeoutRef.current);- workspaceLeaderTimeoutRef.current = null;- }- setWorkspaceLeaderActive(false);-- if (keyChar === 'f') {- setWorkspacePane('files');- return;- }- if (keyChar === 'd') {- setWorkspacePane('details');- return;- }- if (keyChar === 'g') {- setWorkspacePane('git');- return;- }- if (keyChar === 'c') {- onInput('/ws close-file');- return;- }-- if (key.escape) {- return;- }+ if (state.mode === 'workspace') {+ if (key.ctrl && (ch === 'e' || ch === 'E')) {+ setWorkspacePane('files');+ return;}+ if (key.ctrl && (ch === 'g' || ch === 'G')) {+ setWorkspacePane('git');+ return;+ }++ const navMode = input.trim().length === 0;- if (key.upArrow) {+ if (navMode && key.upArrow) {if (workspacePane === 'files') onInput('/ws up');else if (workspacePane === 'details') setDetailCursor((i) => Math.max(0, i - 1));else setGitCursor((i) => Math.max(0, i - 1));return;}- if (key.downArrow) {+ if (navMode && key.downArrow) {if (workspacePane === 'files') onInput('/ws down');else if (workspacePane === 'details') setDetailCursor((i) => Math.min(3, i + 1));else setGitCursor((i) => Math.min((state.workspace?.gitFiles.length || 1) - 1, i + 1));return;}- if (key.leftArrow) {+ if (navMode && key.leftArrow) {if (workspacePane === 'files') onInput('/ws collapse');return;}- if (key.rightArrow) {+ if (navMode && key.rightArrow) {if (workspacePane === 'files') onInput('/ws expand');return;}- if (key.return && !input.trim()) {+ if (navMode && key.return) {if (workspacePane === 'files') onInput('/ws open-selected');else if (workspacePane === 'git') {const picked = state.workspace?.gitFiles[gitCursor];@@ -351,20 +341,7 @@ export function TuiApp({ state, onInput, onPermissionResolve, onExit, spotifyClireturn;}- if (key.return) {- const trimmed = input.trim();- if (trimmed) {- onInput(trimmed);- setInputHistory((prev) => {- if (prev[prev.length - 1] === trimmed) return prev;- return [...prev.slice(-99), trimmed];- });- setHistoryIndex(-1);- setHistoryDraft('');- setInput('');- }- return;- }+ if (key.return) return;if (key.tab) {if (input.startsWith('/') && slashSuggestions.length > 0) {@@ -477,7 +454,7 @@ export function TuiApp({ state, onInput, onPermissionResolve, onExit, spotifyCli{state.mode === 'spotify' ? <SpotifyBody activeIdx={spotifyIdx} nowPlaying={spotifyNow} /> : null}{state.mode === 'menu' ? <MenuBody menuIdx={menuIdx} /> : null}{state.mode === 'coding' ? <CodingBody state={state} /> : null}- {state.mode === 'workspace' ? <WorkspaceBody state={state} workspacePane={workspacePane} detailCursor={detailCursor} gitCursor={gitCursor} workspaceLeaderActive={workspaceLeaderActive} /> : null}+ {state.mode === 'workspace' ? <WorkspaceBody state={state} workspacePane={workspacePane} detailCursor={detailCursor} gitCursor={gitCursor} /> : null}{state.mode === 'chat' ? (<ChatBody state={state} />) : null}@@ -485,7 +462,12 @@ export function TuiApp({ state, onInput, onPermissionResolve, onExit, spotifyCli<PermPromptView prompt={state.permissionPrompt} activeIdx={permIdx} />)}{showInput && (- <InputBox input={input} agentName={state.agentName} />+ <InputBox+ input={input}+ mode={state.mode}+ programmingMode={state.programmingMode}+ projectContext={state.projectContext}+ />)}{showInput && slashSuggestions.length > 0 && (<Box flexDirection="column" paddingX={1}>@@ -582,7 +564,7 @@ function ChatBody({ state }: { state: TuiState }) {<Box flexDirection="column" flexGrow={1}><ChatMessagesView messages={state.chatMessages} agentName={state.agentName} />{state.toolSteps.length > 0 && <ToolStepsView steps={state.toolSteps} viewMode={state.viewMode} />}- {state.isThinking && <Box marginTop={1} marginLeft={2}><Text dimColor>{state.agentName} is thinking...</Text></Box>}+ {state.isThinking && <ThinkingIndicator agentName={state.agentName} steps={state.toolSteps} />}{state.subAgents.length > 0 && <AgentPanelView agents={state.subAgents} />}</Box></Box>@@ -621,13 +603,13 @@ function CodingBody({ state }: { state: TuiState }) {<Box flexDirection="column" flexGrow={1}><ChatMessagesView messages={state.chatMessages} agentName={state.agentName} />{state.toolSteps.length > 0 && <ToolStepsView steps={state.toolSteps} viewMode={state.viewMode} />}- {state.isThinking && <Box marginTop={1} marginLeft={2}><Text dimColor>{state.agentName} is thinking...</Text></Box>}+ {state.isThinking && <ThinkingIndicator agentName={state.agentName} steps={state.toolSteps} />}</Box></Box>);}-function WorkspaceBody({ state, workspacePane, detailCursor, gitCursor, workspaceLeaderActive }: { state: TuiState; workspacePane: 'files' | 'details' | 'git'; detailCursor: number; gitCursor: number; workspaceLeaderActive: boolean }) {+function WorkspaceBody({ state, workspacePane, detailCursor, gitCursor }: { state: TuiState; workspacePane: 'files' | 'details' | 'git'; detailCursor: number; gitCursor: number }) {const ws = state.workspace;if (!ws?.active) {return (@@ -640,6 +622,12 @@ function WorkspaceBody({ state, workspacePane, detailCursor, gitCursor, workspacconst selectedNode = ws.nodes[ws.selectedIndex];const selectedRel = selectedNode ? selectedNode.path.replace(ws.rootPath + '/', '') : '';+ const explorerWindow = 12;+ const explorerStart = Math.max(0, Math.min(ws.selectedIndex - Math.floor(explorerWindow / 2), Math.max(0, ws.nodes.length - explorerWindow)));+ const visibleExplorerNodes = ws.nodes.slice(explorerStart, explorerStart + explorerWindow);+ const gitWindow = 12;+ const gitStart = Math.max(0, Math.min(gitCursor - Math.floor(gitWindow / 2), Math.max(0, ws.gitFiles.length - gitWindow)));+ const visibleGitFiles = ws.gitFiles.slice(gitStart, gitStart + gitWindow);return (<Box flexDirection="column" flexGrow={1}>@@ -647,16 +635,17 @@ function WorkspaceBody({ state, workspacePane, detailCursor, gitCursor, workspac<Text color="gray">Workspace: </Text><Text color="cyan">{ws.rootPath}</Text><Text color="gray"> | Branch: </Text><Text color="magenta">{ws.branch}</Text><Text color="gray"> | Pane: </Text><Text color="white">{workspacePane.toUpperCase()}</Text>- {workspaceLeaderActive ? <Text color="yellow"> [;] pending: F/D/G/C</Text> : null}+ <Text color="gray"> | </Text><Text color="green" bold>CODING IDE</Text></Box><Box paddingX={1}><Text color="gray">{'═'.repeat(118)}</Text></Box>- <Box flexDirection="row" flexGrow={1}>- <Box flexDirection="column" width={40} paddingX={1}>+ <Box flexDirection="row" height={16}>+ <Box flexDirection="column" width={36} paddingX={1}><Text bold color={workspacePane === 'files' ? 'white' : 'cyan'}>EXPLORER {workspacePane === 'files' ? '●' : '○'}</Text>- <Text color="gray">{'─'.repeat(36)}</Text>- {ws.nodes.slice(0, 300).map((node, idx) => {+ <Text color="gray">{'─'.repeat(34)}</Text>+ {visibleExplorerNodes.map((node, localIdx) => {+ const idx = explorerStart + localIdx;const isSelected = idx === ws.selectedIndex;- const prefix = node.isDir ? (node.expanded ? '▾' : '▸') : ' ';+ const prefix = node.isDir ? (node.expanded ? '▾' : '▸') : ' ';const indent = ' '.repeat(Math.max(0, node.depth * 2));return (<Text key={node.id} color={isSelected ? 'white' : 'gray'}>@@ -664,47 +653,70 @@ function WorkspaceBody({ state, workspacePane, detailCursor, gitCursor, workspac</Text>);})}+ <Text dimColor>{ws.nodes.length > explorerWindow ? `Showing ${explorerStart + 1}-${Math.min(ws.nodes.length, explorerStart + explorerWindow)} of ${ws.nodes.length}` : `${ws.nodes.length} items`}</Text></Box><Box><Text color="gray">│</Text></Box>- <Box flexDirection="column" flexGrow={1} paddingX={1}>- <Text bold color={workspacePane === 'details' ? 'white' : 'cyan'}>EDITOR {workspacePane === 'details' ? '●' : '○'}</Text>- <Text color="gray">{'─'.repeat(40)}</Text>- <Text color={detailCursor === 0 ? 'white' : undefined}>Selected: <Text color="yellow">{selectedRel || ws.rootPath}</Text></Text>- <Text color={detailCursor === 1 ? 'white' : undefined}>Mode: <Text color={state.programmingMode === 'execute' ? 'green' : 'yellow'}>{state.programmingMode.toUpperCase()}</Text></Text>- <Text color={detailCursor === 2 ? 'white' : undefined}>Prompt lane: Mercury chat input is active below.</Text>- {ws.lastAction ? <Text dimColor>Last: {ws.lastAction}</Text> : null}- <Text color="gray">{'─'.repeat(40)}</Text>- <Text bold color="cyan">File Preview</Text>- {ws.openedFilePath ? <Text color="yellow">{ws.openedFilePath}</Text> : <Text dimColor>No open file. Select in Files and press Enter.</Text>}- {ws.openedFilePreview.slice(0, 24).map((line, i) => (- <Text key={`${i}:${line.slice(0, 10)}`} dimColor>{String(i + 1).padStart(3, ' ')} {line}</Text>- ))}- {state.toolSteps.length > 0 && <ToolStepsView steps={state.toolSteps} viewMode={state.viewMode} />}- {state.subAgents.length > 0 ? <AgentPanelView agents={state.subAgents} /> : <Text dimColor>No sub-agents active. Mercury shows active prompts/tools here.</Text>}- <Box marginTop={1}><Text dimColor>Focus: F Files · D Details · G Git · C close file</Text></Box>+ <Box flexDirection="column" width={52} paddingX={1}>+ {workspacePane === 'files' ? (+ <>+ <Text bold color="cyan">PREVIEW</Text>+ <Text color="gray">{'─'.repeat(50)}</Text>+ <Text>{selectedRel || ws.rootPath}</Text>+ {ws.openedFilePath ? (+ ws.openedFilePreview.slice(0, 10).map((line, i) => (+ <Text key={`${i}:${line.slice(0, 10)}`} dimColor>{String(i + 1).padStart(3, ' ')} {line}</Text>+ ))+ ) : (+ <Text dimColor>Select a file and press Enter</Text>+ )}+ </>+ ) : workspacePane === 'git' ? (+ <>+ <Text bold color="cyan">GIT INSPECTOR</Text>+ <Text color="gray">{'─'.repeat(50)}</Text>+ <Text>Staged: <Text color="green">{ws.stagedCount}</Text> · Unstaged: <Text color="yellow">{ws.unstagedCount}</Text></Text>+ {visibleGitFiles.length === 0 ? <Text dimColor>Clean working tree</Text> : visibleGitFiles.map((f, localIdx) => {+ const idx = gitStart + localIdx;+ return <Text key={f.path} color={idx === gitCursor ? 'white' : (f.staged ? 'green' : 'yellow')}>{idx === gitCursor ? '›' : ' '} {f.staged ? '●' : '○'} {f.status} {f.path}</Text>;+ })}+ <Text dimColor>{ws.gitFiles.length > gitWindow ? `Showing ${gitStart + 1}-${Math.min(ws.gitFiles.length, gitStart + gitWindow)} of ${ws.gitFiles.length}` : `${ws.gitFiles.length} files`}</Text>+ </>+ ) : (+ <>+ <Text bold color="cyan">DETAILS</Text>+ <Text color="gray">{'─'.repeat(50)}</Text>+ <Text>Selected: <Text color="yellow">{selectedRel || ws.rootPath}</Text></Text>+ <Text>Mode: <Text color={state.programmingMode === 'execute' ? 'green' : 'yellow'}>{state.programmingMode.toUpperCase()}</Text></Text>+ {state.subAgents.length > 0 && <AgentPanelView agents={state.subAgents} />}+ </>+ )}</Box><Box><Text color="gray">│</Text></Box>- <Box flexDirection="column" width={44} paddingX={1}>+ <Box flexDirection="column" flexGrow={1} paddingX={1}><Text bold color={workspacePane === 'git' ? 'white' : 'cyan'}>SOURCE CONTROL {workspacePane === 'git' ? '●' : '○'}</Text>- <Text color="gray">{'─'.repeat(40)}</Text>- <Text>Staged: <Text color="green">{ws.stagedCount}</Text> · Unstaged: <Text color="yellow">{ws.unstagedCount}</Text></Text>- <Text color="gray">{'─'.repeat(40)}</Text>- {ws.gitFiles.length === 0 ? <Text dimColor>Clean working tree</Text> : ws.gitFiles.slice(0, 40).map((f, i) => (- <Text key={f.path} color={i === gitCursor ? 'white' : (f.staged ? 'green' : 'yellow')}>{i === gitCursor ? '›' : ' '} {f.staged ? '●' : '○'} {f.status} {f.path}</Text>- ))}- <Box marginTop={1} flexDirection="column">- <Text dimColor>/ws stage all</Text>- <Text dimColor>/ws stage <file></Text>- <Text dimColor>/ws commit <message></Text>- <Text dimColor>/ws undo <file></Text>- <Text dimColor>/ws refresh</Text>- <Text dimColor>Enter in Git pane stages selected file</Text>- </Box>+ <Text color="gray">{'─'.repeat(26)}</Text>+ <Text>Branch: <Text color="magenta">{ws.branch}</Text></Text>+ <Text>Staged: <Text color="green">{ws.stagedCount}</Text></Text>+ <Text>Unstaged: <Text color="yellow">{ws.unstagedCount}</Text></Text>+ <Text color="gray">{'─'.repeat(26)}</Text>+ {visibleGitFiles.length === 0 ? <Text dimColor>Clean working tree</Text> : visibleGitFiles.map((f, localIdx) => {+ const idx = gitStart + localIdx;+ return <Text key={`side-${f.path}`} color={idx === gitCursor ? 'white' : (f.staged ? 'green' : 'yellow')}>{idx === gitCursor ? '›' : ' '} {f.status} {f.path}</Text>;+ })}+ <Text dimColor>Enter stages selected file</Text>+ <Text dimColor>/ws stage all · /ws commit <msg></Text></Box></Box><Box paddingX={1}><Text color="gray">{'═'.repeat(118)}</Text></Box>+ <Box flexDirection="column" flexGrow={1} paddingX={1}>+ <Text bold color="cyan">Chat · Workspace Coding Session</Text>+ <Text dimColor>Ask implementation questions, refactors, tests, and git actions for this project context.</Text>+ <ChatMessagesView messages={state.chatMessages} agentName={state.agentName} />+ {state.toolSteps.length > 0 && <ToolStepsView steps={state.toolSteps} viewMode={state.viewMode} />}+ {state.isThinking && <ThinkingIndicator agentName={state.agentName} steps={state.toolSteps} />}+ </Box><Box paddingX={1}>- <Text dimColor>Shortcuts: ; then F/D/G/C · Tree: ↑↓ navigate, ← collapse, → expand, Enter open · Git: Enter stage selected</Text>+ <Text dimColor>Ctrl+E Explorer · Ctrl+G Git · Empty input = IDE navigation · Type text = chat mode</Text></Box></Box>);@@ -781,7 +793,9 @@ function ChatMessagesView({ messages, agentName }: { messages: ChatMessage[]; ag<Text bold color={roleColor}>{prefix}:</Text></Box><Box marginLeft={2} flexDirection="column">- <Text>{rendered}</Text>+ {rendered.split('\n').map((line, idx) => (+ <Text key={`${msg.id}:${idx}`}>{line.length > 0 ? line : ' '}</Text>+ ))}</Box></Box>);@@ -814,6 +828,39 @@ function ToolStepsView({ steps, viewMode }: { steps: ToolStep[]; viewMode: 'bala);}+function ThinkingIndicator({ agentName, steps }: { agentName: string; steps: ToolStep[] }) {+ const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];+ const phases = ['indexing symbols', 'building plan', 'running checks', 'linking context'];+ const [frame, setFrame] = React.useState(0);++ React.useEffect(() => {+ const timer = setInterval(() => {+ setFrame((v) => (v + 1) % (frames.length * phases.length));+ }, 90);+ return () => clearInterval(timer);+ }, []);++ const spinner = frames[frame % frames.length];+ const phase = phases[Math.floor(frame / frames.length) % phases.length];+ const pulse = '.'.repeat((frame % 3) + 1);+ const runningStep = [...steps].reverse().find((s) => s.status === 'running');+ const livePhase = runningStep ? `running: ${runningStep.label}` : phase;++ return (+ <Box marginTop={1} marginLeft={2} flexDirection="column">+ <Box>+ <Text color="cyan">{spinner}</Text>+ <Text> </Text>+ <Text color="cyan" bold>{agentName}</Text>+ <Text dimColor> is thinking{pulse}</Text>+ </Box>+ <Box marginLeft={2}>+ <Text color="gray">↳ {livePhase}</Text>+ </Box>+ </Box>+ );+}+function AgentPanelView({ agents }: { agents: SubAgentInfo[] }) {if (agents.length === 0) return null;return (@@ -903,15 +950,43 @@ function PermPromptView({ prompt, activeIdx }: { prompt: PermissionPromptState;);}-function InputBox({ input, agentName }: { input: string; agentName: string }) {+function InputBox({+ input,+ mode,+ programmingMode,+ projectContext,+}: {+ input: string;+ mode: AppMode;+ programmingMode: ProgrammingModeState;+ projectContext: string | null;+}) {+ const inWorkspace = mode === 'workspace';+ const inCoding = mode === 'coding' || inWorkspace;+ const promptColor = inWorkspace ? 'cyan' : inCoding ? 'green' : 'yellow';+ const label = inWorkspace ? '[IDE CHAT]' : inCoding ? '[CODING]' : '[CHAT]';+ const contextLabel = projectContext && projectContext.length > 52+ ? `...${projectContext.slice(-49)}`+ : (projectContext || 'No project context');+return (<Box flexDirection="column"><Text color="dim">{'─'.repeat(60)}</Text><Box paddingX={1}>- <Text color="yellow" bold>{'>'} </Text>+ <Text color={promptColor} bold>{label}</Text>+ <Text dimColor> {contextLabel} </Text>+ <Text color={programmingMode === 'execute' ? 'green' : programmingMode === 'plan' ? 'yellow' : 'gray'}>+ mode={programmingMode.toUpperCase()}+ </Text>+ </Box>+ <Box paddingX={1}>+ <Text color={promptColor} bold>{'>'} </Text><Text>{input}</Text><Text dimColor>█</Text></Box>+ <Box paddingX={1}>+ <Text dimColor>{inWorkspace ? 'IDE chat active. Enter sends prompt; empty Enter navigates panel.' : 'Type a prompt, then Enter.'}</Text>+ </Box></Box>);}