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
feat: coding-CLI integration polish — workspace sync, cwd-change session reset, prompt template split, picker card
wyte6d91ee2e487
diff --git a/src/main/features/group_chat/bus.ts b/src/main/features/group_chat/bus.tsindex 4ddf600c..ccb37e10 100644--- a/src/main/features/group_chat/bus.ts+++ b/src/main/features/group_chat/bus.ts@@ -926,15 +926,19 @@ async function runTurn(state: CidState, w: WorkerState, item: QueueItem): Promis// dir mid-conversation. We also defensively check the directory// exists and is a real dir — if it vanished between picker and// dispatch we fall back rather than failing the run.- const agentsFeat = await import('../agents');let cliWorkingDir = wsRoot;if (agentsFeat.cliIsCodingAgent(cliAgent.runtime?.kind === 'cli' ? cliAgent.runtime.cli : '')) {+ // Default + workspace-sync: on the first coding-agent turn the+ // user shouldn't have to pick a directory just to start; default+ // to their effective workspace. On later turns, follow workspace+ // changes silently — unless the user has explicitly picked+ // something different through the input-form (sticky).+ await _syncCodingProjectDirWithWorkspace(uid, cid, wsRoot);const st = await import('./state');const stateFile = await st.readState(uid, cid);const projDir = stateFile.coding_project_dir;if (projDir) {try {- const fs = await import('node:fs');if (fs.statSync(projDir).isDirectory()) cliWorkingDir = projDir;} catch { /* missing → fall through to wsRoot */ }}@@ -1907,6 +1911,46 @@ planExecutor.bindBusHooks({const CLI_PROMPT_MAX_BYTES = 200 * 1024;+/** Default + workspace-sync for the coding-agent project directory.+ *+ * Two cases the user expects to "just work":+ * 1. First dispatch in a fresh conv: we shouldn't pop a directory+ * picker just to start — the user already chose a workspace,+ * use that.+ * 2. User switches the workspace mid-conversation (chip in the+ * chat surface): the next coding-agent turn should follow.+ *+ * Either case = "auto-set" with `explicit=false`. Once the user+ * picks a different directory through the input-form picker+ * (form-submit hook flips `explicit=true`), workspace switches no+ * longer override their choice. Caller must already have established+ * this is a coding agent (the explicit flag is meaningless for+ * non-coding CLIs that don't honour `coding_project_dir`). */+async function _syncCodingProjectDirWithWorkspace(+ uid: string, cid: string, wsPath: string,+): Promise<void> {+ const cur = await readState(uid, cid);+ if (cur.coding_project_dir_explicit) return; // sticky+ if (cur.coding_project_dir === wsPath) return; // already in sync+ const oldDir = cur.coding_project_dir || '';+ const { setCodingProjectDir } = await import('./state');+ await setCodingProjectDir(uid, cid, wsPath, { explicit: false });+ if (oldDir && oldDir !== wsPath) {+ // CLI session bindings reference the OLD cwd. claude code keys+ // sessions by cwd (`~/.claude/projects/<encoded-cwd>/<id>.jsonl`),+ // so resuming a stale id at the new cwd fails with+ // "No conversation found". Drop bindings preemptively so the+ // next dispatch goes through the full-slice replay path —+ // user-visible conversation continues seamlessly because+ // `_buildCliPrompt` includes the slice when `resuming=false`.+ const cliSessions = await import('../local_agents/sessions');+ await cliSessions.clearForConversation(uid, cid);+ log.info(`coding cwd changed cid=${cid} ${oldDir} → ${wsPath} — cleared cli sessions`);+ } else {+ log.info(`coding project_dir auto-set cid=${cid} → ${wsPath}`);+ }+}+/** Build an `<agent-input-form>` block listing the agent's required* inputs that are still unfulfilled, or return `null` when nothing is* missing. Currently the only auto-injected input is `project_dir`@@ -2101,27 +2145,38 @@ async function _buildCliPrompt(slice: GroupMessage[],/** When true, the CLI is resuming a prior session and already has* the conversation history in its own memory — we skip the slice- * block entirely and just send "head + new task". Drops massive- * redundancy on long convs. */+ * block entirely and just send the static frame + new task. Drops+ * massive redundancy on long convs. */resuming: boolean,): Promise<string> {- // Build head + tail separately so truncation can throw away the- // middle of the conversation slice (oldest entries) while preserving- // the agent identity preamble + the actual task. The naive "trim- // from the head of the byte buffer" approach we used first dropped- // the role preamble — leaving the CLI without context about who it- // is or what it owns.- const headLines: string[] = [];- headLines.push(`You are "${agent.name || agent.agent_id}".`);- const desc = (agent.description_en || agent.description_zh || '').trim();- if (desc) headLines.push(desc);- headLines.push('');-- // Attachments come from the dispatched message AND from prior slice- // messages — the agent might be expected to "look at the report you- // uploaded last turn", so we collect across the whole visibility- // slice. De-duplicate by absolute path; preserve oldest-first order.+ // Layout = `chat_cli_agent.md` (static frame) + `chat_cli_coding_protocol.md`+ // (coding-only). The static-first / runtime-last split keeps the+ // CLI's prompt cache stable across turns: identity + protocol stay+ // byte-identical, attachments / slice / task body all change.+ const { prompts } = await import('../../prompts/loader');const { chatAttachmentDir } = await import('../../paths');++ // ── Output protocol — coding agents only ────────────────────────+ // Non-coding CLIs (openclaw / opencode / hermes) get an empty block+ // and never see the project-dir-switching rules — the host doesn't+ // route their cwd through `coding_project_dir` and the form+ // wouldn't fire on their submissions anyway.+ const cli = agent.runtime?.kind === 'cli' ? agent.runtime.cli : '';+ let outputProtocolBlock = '';+ if (agentsFeat.cliIsCodingAgent(cli)) {+ const inputs = Array.isArray(agent.inputs) ? agent.inputs : [];+ const projectDirInput = inputs.find((f: any) => f.id === agentsFeat.PROJECT_DIR_INPUT_ID);+ const projectDirLabel = (projectDirInput && typeof projectDirInput.label === 'string' && projectDirInput.label.trim())+ ? projectDirInput.label+ : 'Project directory';+ outputProtocolBlock = prompts.load('chat_cli_coding_protocol', {+ agent_id: agent.agent_id,+ project_dir_label: projectDirLabel,+ }).trim();+ }++ // ── Attachments — collected across the whole slice + this dispatch+ // De-duplicate by absolute path; preserve oldest-first order.const attDir = chatAttachmentDir(uid, cid);const allAtts: string[] = [];const seenAtts = new Set<string>();@@ -2134,28 +2189,21 @@ async function _buildCliPrompt(};for (const m of slice) collect(m.attachments);collect(item.attachments);- if (allAtts.length) {- headLines.push('## Attachments');- for (const abs of allAtts) headLines.push(`- ${abs}`);- headLines.push('');- }+ const attachmentsBlock = allAtts.length+ ? `## Attachments\n${allAtts.map(a => `- ${a}`).join('\n')}`+ : '';- const tailLines: string[] = [];- tailLines.push('## Your task');- // When the dispatched item is just a form submission (the user- // confirmed the input form, not a fresh ask), the task body is- // metadata — a `- project_dir: …` style summary + an- // `<agent-input-submission>`- // XML tag — with the original user request now sitting upstream in- // the slice. A coding CLI handed only that metadata has nothing- // actionable: claude / codex sit idle until killed (observed:- // 2+ min "processing" with 0 bytes of output). Walk the slice+ // ── Task body — submission unwrap if the dispatch was a form-submit.+ // When the user confirmed the input form, the dispatched payload is+ // metadata (`<agent-input-submission>` + a values summary) — handing+ // that to a coding CLI gives it nothing actionable. Walk the slice// backward to recover the most recent user message that ISN'T// another submission and use it as the real task; append the- // confirmed values as extra context. The cwd is already routed- // via `state.coding_project_dir`, so we don't need to re-state- // `project_dir` to the CLI.+ // confirmed values as extra context. cwd is already routed via+ // `state.coding_project_dir`, so we strip `project_dir` from the+ // confirmed-parameters block.const submission = decodeSubmission(item.llmPayload);+ let taskBody: string;if (submission) {let originalTask = '';for (let i = slice.length - 1; i >= 0; i--) {@@ -2166,28 +2214,32 @@ async function _buildCliPrompt(originalTask = txt;break;}- tailLines.push(originalTask || item.llmPayload);+ const lines: string[] = [originalTask || item.llmPayload];const extraValues = Object.entries(submission.values).filter(([k]) => k !== 'project_dir').map(([k, v]) => `- ${k}: ${typeof v === 'string' ? v : JSON.stringify(v)}`);if (extraValues.length) {- tailLines.push('');- tailLines.push('## Confirmed parameters');- tailLines.push(...extraValues);+ lines.push('', '## Confirmed parameters', ...extraValues);}+ taskBody = lines.join('\n');} else {- tailLines.push(item.llmPayload);+ taskBody = item.llmPayload;}- const head = headLines.join('\n');- const tail = tailLines.join('\n');+ // Render the template with a candidate conversation block. The+ // truncation pass below sizes the block against the byte cap.+ const render = (conversationBlock: string) => prompts.load('chat_cli_agent', {+ agent_name: agent.name || agent.agent_id,+ agent_description: (agent.description_en || agent.description_zh || '').trim(),+ output_protocol_block: outputProtocolBlock,+ attachments_block: attachmentsBlock,+ conversation_block: conversationBlock,+ task_body: taskBody,+ });- // Resuming a CLI-side session: the CLI already remembers the prior- // turns. Skip the slice block entirely and let the model rely on- // its own session memory. Preamble + new task is enough.- if (resuming) {- return `${head}\n${tail}`;- }+ // Resuming → CLI already has the slice in its own memory; skip+ // replay entirely. Static frame + new task is enough.+ if (resuming) return render('');// Conversation slice, oldest → newest. Empty-text rows skipped.const sliceLines: string[] = [];@@ -2198,17 +2250,18 @@ async function _buildCliPrompt(sliceLines.push(`[${m.from} → ${to}] ${text}`);}- // Reserve the head + tail bytes; what's left is the conversation- // budget. If even head+tail exceed the cap, fall back to a minimal- // prompt without history (better than truncating the task body).- const reserveBytes = Buffer.byteLength(head, 'utf8') + Buffer.byteLength(tail, 'utf8') + 64; // 64 = headers + newlines slack- if (reserveBytes >= CLI_PROMPT_MAX_BYTES) {- log.warn(`cli prompt: head+tail exceed cap; sending minimal prompt cid=${cid} agent=${agent.agent_id}`);- return `${head}\n${tail}`;+ // Size the slice against the byte cap by rendering once with an+ // empty block — gives an exact base size including the protocol /+ // attachments / task. If even the base exceeds the cap, fall back+ // to a no-history prompt rather than truncating the task body.+ const baseBytes = Buffer.byteLength(render(''), 'utf8');+ if (baseBytes >= CLI_PROMPT_MAX_BYTES) {+ log.warn(`cli prompt: base exceeds cap; sending minimal prompt cid=${cid} agent=${agent.agent_id}`);+ return render('');}- const sliceBudget = CLI_PROMPT_MAX_BYTES - reserveBytes;- // Walk the slice from newest backward; keep messages while we have- // budget. If the oldest messages don't fit, drop them.+ const sliceBudget = CLI_PROMPT_MAX_BYTES - baseBytes;+ // Walk newest-backward, keep lines while we have budget. Oldest+ // lines that don't fit are dropped.const kept: string[] = [];let used = 0;for (let i = sliceLines.length - 1; i >= 0; i--) {@@ -2221,8 +2274,8 @@ async function _buildCliPrompt(if (truncated) {log.warn(`cli prompt: trimmed ${sliceLines.length - kept.length}/${sliceLines.length} oldest slice rows cid=${cid} agent=${agent.agent_id}`);}- const sliceBlock = kept.length- ? `## Conversation so far${truncated ? ' (truncated)' : ''}\n${kept.join('\n')}\n`+ const conversationBlock = kept.length+ ? `## Conversation so far${truncated ? ' (truncated)' : ''}\n${kept.join('\n')}`: '';- return `${head}\n${sliceBlock}\n${tail}`;+ return render(conversationBlock);}diff --git a/src/main/features/group_chat/index.ts b/src/main/features/group_chat/index.tsindex cfc2c52a..509d9000 100644--- a/src/main/features/group_chat/index.ts+++ b/src/main/features/group_chat/index.ts@@ -272,8 +272,21 @@ export async function markFormSubmittedAndDispatch(const ag = await agentsFeat.getAgent(agentId);const cli = ag?.runtime?.kind === 'cli' ? ag.runtime.cli : '';if (agentsFeat.cliIsCodingAgent(cli)) {- await setCodingProjectDir(userId, cid, projDir);- log.info(`coding project_dir set user=${userId} cid=${cid} agent=${agentId} dir=${projDir}`);+ const { readState: rs } = await import('./state');+ const prev = await rs(userId, cid);+ const oldDir = prev.coding_project_dir || '';+ await setCodingProjectDir(userId, cid, projDir, { explicit: true });+ if (oldDir && oldDir !== projDir) {+ // cwd is about to change — claude code's sessions are cwd-keyed,+ // so the existing binding would fail with "No conversation+ // found" on resume. Drop it; next dispatch replays the full+ // slice so the user-visible conversation continues seamlessly.+ const cliSessions = await import('../local_agents/sessions');+ await cliSessions.clearForConversation(userId, cid);+ log.info(`coding cwd changed (form) user=${userId} cid=${cid} ${oldDir} → ${projDir} — cleared cli sessions`);+ } else {+ log.info(`coding project_dir set (explicit) user=${userId} cid=${cid} agent=${agentId} dir=${projDir}`);+ }}}} catch (err) {diff --git a/src/main/features/group_chat/state.ts b/src/main/features/group_chat/state.tsindex 9af49493..7ff20a9f 100644--- a/src/main/features/group_chat/state.ts+++ b/src/main/features/group_chat/state.ts@@ -65,12 +65,24 @@ export interface StateFile {* slug rules and the placeholder fallback. */workspace_dir?: string;/** Project directory for coding-agent (claude / codex) dispatches in- * this conversation. User-set via the project-dir chip in the chat- * surface; absolute path. Missing / empty → coding agents fall back- * to the conv's workspace root (matches the prior behaviour). The- * field is per-conversation, NOT per-agent: one project for the- * whole conversation across however many coding agents it has. */+ * this conversation. Auto-set on the first coding-agent turn to the+ * user's effective workspace path (so the user doesn't have to pick+ * manually for the common case), and re-synced to follow workspace+ * switches as long as `coding_project_dir_explicit` is false. Once+ * the user picks a different directory through the input-form+ * (`coding_project_dir_explicit=true`), workspace changes no longer+ * override their choice. Absolute path. Missing / empty → coding+ * agents fall back to the conv's workspace root. The field is+ * per-conversation, NOT per-agent: one project for the whole+ * conversation across however many coding agents it has. */coding_project_dir?: string;+ /** True when the user picked `coding_project_dir` explicitly via the+ * `<agent-input-form>` directory picker (form-submit hook in+ * `group_chat/index.ts`). False / missing means the dir was+ * auto-set by the workspace-sync path in `bus.ts` and is allowed to+ * follow future workspace switches. Cleared whenever+ * `coding_project_dir` is cleared. */+ coding_project_dir_explicit?: boolean;}export const COMMANDER_ID = 'commander';@@ -225,6 +237,9 @@ export async function readState(uid: string, cid: string): Promise<StateFile> {...(typeof data.coding_project_dir === 'string' && data.coding_project_dir? { coding_project_dir: data.coding_project_dir }: {}),+ ...(typeof data.coding_project_dir_explicit === 'boolean'+ ? { coding_project_dir_explicit: data.coding_project_dir_explicit }+ : {}),};}} catch (err) {@@ -326,13 +341,29 @@ export async function setWorkspaceDirOnce(uid: string, cid: string, dir: string)/** Set / clear the per-conversation coding-agent project directory.* Pass `''` (or missing) to clear; an absolute path otherwise.* Caller is responsible for absolute-path validation — we only do- * string handling here. Returns the resulting state. */-export async function setCodingProjectDir(uid: string, cid: string, dir: string): Promise<StateFile> {+ * string handling here. Returns the resulting state.+ *+ * `opts.explicit` records whether the user actively chose this+ * directory through the `<agent-input-form>` picker. The flag is+ * consulted by the workspace-sync path in `bus.ts`: explicit picks+ * are sticky (workspace switches don't override them), auto-set+ * values track the workspace. Clearing `dir` also clears the flag+ * so the next auto-set doesn't accidentally inherit a stale `true`. */+export async function setCodingProjectDir(+ uid: string, cid: string, dir: string,+ opts: { explicit: boolean },+): Promise<StateFile> {return _stateLock(uid, cid).runExclusive(async () => {const s = await readState(uid, cid);const trimmed = String(dir || '').trim();- if (trimmed) s.coding_project_dir = trimmed;- else delete s.coding_project_dir;+ if (trimmed) {+ s.coding_project_dir = trimmed;+ if (opts.explicit) s.coding_project_dir_explicit = true;+ else delete s.coding_project_dir_explicit;+ } else {+ delete s.coding_project_dir;+ delete s.coding_project_dir_explicit;+ }s.last_active_at = nowIso();await writeStateRaw(uid, cid, s);return s;diff --git a/src/main/prompts/chat_cli_agent.md b/src/main/prompts/chat_cli_agent.mdnew file mode 100644index 00000000..dccbd27d--- /dev/null+++ b/src/main/prompts/chat_cli_agent.md@@ -0,0 +1,17 @@+You are "$agent_name".++$agent_description++$output_protocol_block++---++## Runtime injection++$attachments_block++$conversation_block++## Your task++$task_bodydiff --git a/src/main/prompts/chat_cli_coding_protocol.md b/src/main/prompts/chat_cli_coding_protocol.mdnew file mode 100644index 00000000..5198507f--- /dev/null+++ b/src/main/prompts/chat_cli_coding_protocol.md@@ -0,0 +1,26 @@+## Output protocol — switching project directory++Your default behaviour is to **work in the directory the host gave you**.+Do NOT emit the directory-picker form just because the directory looks+empty, looks unfamiliar, or because the user said hello — those are not+signals that a switch is needed.++Emit ONLY when:+- the user has clearly asked to switch / pick / change project directory+ (any phrasing — trust your judgement on intent), OR+- a task they gave you genuinely cannot proceed in the current directory+ AND they haven't already pointed you at a different path++When you decide to emit, end your reply with this XML block exactly,+on its own line, no code fence, nothing after it:++<agent-input-form>+{"agent_id":"$agent_id","fields":[{"id":"project_dir","type":"directory","label":"$project_dir_label","required":true,"default":""}]}+</agent-input-form>++The host owns the working directory: `cd` / `mv` won't change it.+Once the user submits, the next dispatch lands inside the new directory+and the original task is re-sent — continue from there.++If you're not sure whether the user wants to switch, ask in plain text+first; emit the block only after they have agreed.diff --git a/src/renderer/modules/chat-input-form.js b/src/renderer/modules/chat-input-form.jsindex 709e2e1e..2ac73134 100644--- a/src/renderer/modules/chat-input-form.js+++ b/src/renderer/modules/chat-input-form.js@@ -166,39 +166,62 @@read = fileWidget.read;isReady = fileWidget.isReady;} else if (field.type === 'directory') {- // Directory picker: native dialog through `common.pickDirectory`.- // The widget shows the picked absolute path; the value submitted is- // the path string (or empty when nothing picked). Used by external- // coding agents (claude / codex) to collect their cwd via the- // standard input-form pipeline.- const dirWrap = document.createElement('div');- dirWrap.className = 'form-field-dir';+ // Card-style directory picker: a single clickable surface with a+ // folder icon + path / hint + a "Change" pill in the filled+ // state. Whole card is the affordance — Enter / Space activate+ // the native `common.pickDirectory` dialog the same as a click.+ // No "Clear" control: the field is `required` in practice (the+ // only consumer is the coding-agent `project_dir` schema), and+ // re-picking is one click vs clear-then-pick = two clicks.+ const card = document.createElement('div');+ card.className = 'form-field-dir-card';+ card.setAttribute('role', 'button');+ card.tabIndex = disabled ? -1 : 0;++ // Inline SVG folder icon — no dependency on a sprite or icon font.+ const SVG_NS = 'http://www.w3.org/2000/svg';+ const icon = document.createElementNS(SVG_NS, 'svg');+ icon.setAttribute('class', 'form-field-dir-icon');+ icon.setAttribute('viewBox', '0 0 24 24');+ icon.setAttribute('fill', 'none');+ icon.setAttribute('stroke', 'currentColor');+ icon.setAttribute('stroke-width', '1.5');+ icon.setAttribute('stroke-linejoin', 'round');+ const iconPath = document.createElementNS(SVG_NS, 'path');+ iconPath.setAttribute('d', 'M3 7.5a2 2 0 012-2h3.586a1 1 0 01.707.293l1.414 1.414a1 1 0 00.707.293H19a2 2 0 012 2V18a2 2 0 01-2 2H5a2 2 0 01-2-2V7.5z');+ icon.appendChild(iconPath);+ card.appendChild(icon);+const pathLabel = document.createElement('span');pathLabel.className = 'form-field-dir-path';+ card.appendChild(pathLabel);++ const changePill = document.createElement('span');+ changePill.className = 'form-field-dir-change';+ changePill.textContent = t('input.dir.change') || 'Change';+ card.appendChild(changePill);+let value = (typeof initial === 'string' && initial) ? initial : '';const renderPath = () => {if (value) {pathLabel.textContent = value;pathLabel.title = value;pathLabel.classList.remove('is-empty');+ changePill.style.display = '';+ card.classList.remove('is-empty');} else {- pathLabel.textContent = t('input.dir.none') || '(none selected)';+ pathLabel.textContent = t('input.dir.pick') || 'Click to choose a directory';pathLabel.removeAttribute('title');pathLabel.classList.add('is-empty');+ changePill.style.display = 'none';+ card.classList.add('is-empty');}};renderPath();- const pickBtn = document.createElement('button');- pickBtn.type = 'button';- pickBtn.className = 'btn btn-sm form-field-dir-pick';- pickBtn.textContent = t('input.dir.pick') || 'Choose directory…';- const clearBtn = document.createElement('button');- clearBtn.type = 'button';- clearBtn.className = 'btn btn-sm form-field-dir-clear';- clearBtn.textContent = t('input.dir.clear') || 'Clear';- pickBtn.disabled = disabled;- clearBtn.disabled = disabled;- pickBtn.addEventListener('click', async () => {+ if (disabled) card.classList.add('is-disabled');++ const pick = async () => {+ if (disabled) return;try {const res = await window.orkas.invoke('common.pickDirectory', {title: field.label || 'Choose a directory',@@ -206,31 +229,27 @@if (res && !res.cancelled && res.path) {value = String(res.path);renderPath();- pickBtn.textContent = t('input.dir.change') || 'Change…';- // Notify the form so the submit button re-evaluates `isReady`- // — without this the button stays disabled (and shows the- // "please wait for upload to finish" hint) even after the user picks a dir.+ // Re-evaluate `isReady` so the submit button enables / the+ // "please wait" hint clears immediately after a pick.if (ctx && typeof ctx.onChange === 'function') ctx.onChange();}} catch (_) { /* user cancelled or no permission */ }+ };+ card.addEventListener('click', pick);+ card.addEventListener('keydown', (e) => {+ if (e.key === 'Enter' || e.key === ' ') {+ e.preventDefault();+ pick();+ }});- clearBtn.addEventListener('click', () => {- value = '';- renderPath();- pickBtn.textContent = t('input.dir.pick') || 'Choose directory…';- if (ctx && typeof ctx.onChange === 'function') ctx.onChange();- });- if (value) pickBtn.textContent = t('input.dir.change') || 'Change…';- dirWrap.appendChild(pickBtn);- dirWrap.appendChild(clearBtn);- dirWrap.appendChild(pathLabel);- ctrlWrap.appendChild(dirWrap);++ ctrlWrap.appendChild(card);read = () => value;// No `isReady` override: `isReady` is reserved for "in-flight"// states (e.g. file upload still going) which gate the submit- // button + show the "please wait for upload to finish" hint. Required-empty for a- // directory is reported by `_validate` on submit click, matching- // text / number / select.+ // button + show the "please wait for upload to finish" hint.+ // Required-empty for a directory is reported by `_validate` on+ // submit click, matching text / number / select.} else {// Unknown type — shouldn't happen (main validated) but degrade gracefully.const note = document.createElement('div');diff --git a/src/renderer/modules/conversation.js b/src/renderer/modules/conversation.jsindex 30ba7dd7..9d45da59 100644--- a/src/renderer/modules/conversation.js+++ b/src/renderer/modules/conversation.js@@ -1660,21 +1660,24 @@ function appendChatMessage(message, autoScroll = true, opts = {}) {_mountChatInputForm(formHost, msgDiv, message, opts);}}- // Archive button + persisted-process block only make sense for finalised- // assistant replies (raw markdown, not an HTML placeholder like "thinking...").- if (role === 'assistant' && !isHtmlSnippet) {- if (archive) _attachBubbleArchiveBtn(msgDiv, () => rawContent);- if (Array.isArray(message.process) && message.process.length) {- // Auto-expand when the body is just an abort placeholder: the process- // trail IS the content the user already saw, hiding it behind a fold- // makes refresh look like "everything I watched stream is gone".- const bodyText = String(displayContent || '').trim();- // Match both possible forms — jsonl history can carry either depending- // on the UI language at the time of write (i18n key `model.aborted` →- // '(stopped)' in en, '(已中断)' in zh).- const isAbortStub = bodyText === '(已中断)' || bodyText === '(stopped)' || bodyText === '';- _renderPersistedProcess(msgDiv, message.process, { expanded: isAbortStub });- }+ // Archive button is only for finalised assistant replies (raw markdown,+ // not an HTML placeholder / status stub).+ if (role === 'assistant' && !isHtmlSnippet && archive) {+ _attachBubbleArchiveBtn(msgDiv, () => rawContent);+ }+ // Persisted-process trail is independent of body type — it must render+ // for HTML-stub bodies too (e.g. CLI errors like `<span>⚠️ ...</span>`),+ // otherwise after a refresh the only visible signal of a failed run is+ // the red error line and "what happened" is gone. Auto-expand for any+ // empty / abort-stub / HTML-stub body so the rail IS the content.+ if (role === 'assistant' && Array.isArray(message.process) && message.process.length) {+ const bodyText = String(displayContent || '').trim();+ // Match both possible forms — jsonl history can carry either depending+ // on the UI language at the time of write (i18n key `model.aborted` →+ // '(stopped)' in en, '(已中断)' in zh).+ const isAbortStub = bodyText === '(已中断)' || bodyText === '(stopped)' || bodyText === '';+ const expanded = isAbortStub || isHtmlSnippet;+ _renderPersistedProcess(msgDiv, message.process, { expanded });}if (autoScroll) {diff --git a/src/renderer/style.css b/src/renderer/style.cssindex 78a6e7f0..6f15ab41 100644--- a/src/renderer/style.css+++ b/src/renderer/style.css@@ -1887,6 +1887,8 @@ body.model-not-configured .main-content { flex-direction: column; }height: 100%;background: #f8fafc;position: relative;+ /* Used by `.chat-input-form { width: 40cqw }`. */+ container-type: inline-size;}@@ -2580,6 +2582,10 @@ body.model-not-configured .main-content { flex-direction: column; }.chat-input-form {margin-top: 10px;padding: 10px 12px;+ /* Stable 40% of chat pane, not bubble width. */+ width: 40cqw;+ max-width: 100%;+ min-width: 280px;background: rgba(14, 165, 233, 0.06);border: 1px solid rgba(14, 165, 233, 0.25);border-radius: 10px;@@ -2659,26 +2665,79 @@ body.model-not-configured .main-content { flex-direction: column; }flex-direction: column;gap: 6px;}-.chat-input-form .form-field-dir {+/* Card-style directory picker — single clickable surface that+ replaces the old "[Choose…] [Clear] /path" three-button row.+ See chat-input-form.js `field.type === 'directory'` for the DOM+ it builds: card → icon + path/hint + change pill. */+.chat-input-form .form-field-dir-card {display: flex;align-items: center;- gap: 8px;- flex-wrap: wrap;+ gap: 10px;+ padding: 10px 12px;+ border: 1px dashed var(--border);+ border-radius: 8px;+ background: rgba(255, 255, 255, 0.6);+ cursor: pointer;+ transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;+ min-width: 0;+}+.chat-input-form .form-field-dir-card:not(.is-empty) {+ /* Filled state: solid border + opaque background to read as+ "value held" rather than "drop zone". */+ border-style: solid;+ background: rgba(255, 255, 255, 0.85);+}+.chat-input-form .form-field-dir-card:hover:not(.is-disabled) {+ border-color: var(--primary);+ background: rgba(14, 165, 233, 0.04);+}+.chat-input-form .form-field-dir-card:focus-visible {+ outline: none;+ border-color: var(--primary);+ box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.15);+}+.chat-input-form .form-field-dir-card.is-disabled {+ cursor: default;+ border-style: solid;+}+.chat-input-form .form-field-dir-icon {+ flex-shrink: 0;+ width: 18px;+ height: 18px;+ color: var(--muted);+}+.chat-input-form .form-field-dir-card:not(.is-empty) .form-field-dir-icon,+.chat-input-form .form-field-dir-card:hover:not(.is-disabled) .form-field-dir-icon {+ color: var(--primary);}.chat-input-form .form-field-dir-path {- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;- font-size: 12px;- color: var(--text);flex: 1 1 auto;min-width: 0;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;+ font-size: 12px;+ color: var(--text);}.chat-input-form .form-field-dir-path.is-empty {font-family: inherit;+ font-size: 13px;color: var(--muted);}+.chat-input-form .form-field-dir-change {+ flex-shrink: 0;+ font-size: 11px;+ padding: 2px 8px;+ border-radius: 999px;+ background: rgba(14, 165, 233, 0.1);+ color: var(--primary);+ font-weight: 500;+}+.chat-input-form.is-submitted .form-field-dir-card {+ cursor: default;+ border-style: solid;+}.chat-input-form .form-field-file-chips {display: flex;flex-wrap: wrap;