The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
feat(code): move the shell approval into the transcript
purple725efedc3519
diff --git a/src/components/chat/CodexConfirmDialog.tsx b/src/components/chat/CodexConfirmDialog.tsxnew file mode 100644index 00000000..20a4dc34--- /dev/null+++ b/src/components/chat/CodexConfirmDialog.tsx@@ -0,0 +1,75 @@+// The coding agent's shell/code approval, inline in the transcript.+//+// Two rewrites got it here. It started as `window.confirm`, an OS dialog with+// system chrome and the app origin in its title bar, which David called exactly+// what it looked like. The first replacement was a centred modal, which was+// small and tidy but still covered the conversation you were reading. This one+// sits in the stream under the tool call it belongs to, so the pending command+// reads as one more step of the run rather than an interruption of it.+//+// "Don't ask again" both allows the current command AND clears the setting that+// caused the prompt. Clearing without allowing would leave the task blocked on+// a question that will not be asked again, which is not what the phrase means.++import { Terminal } from 'lucide-react'+import { useCodexConfirmStore } from '../../stores/codexConfirmStore'+import { useSettingsStore } from '../../stores/settingsStore'++export function CodexConfirmDialog() {+ const pending = useCodexConfirmStore((s) => s.pending)+ const answer = useCodexConfirmStore((s) => s.answer)+ const updateSettings = useSettingsStore((s) => s.updateSettings)++ if (!pending) return null++ const stopAsking = () => {+ // Clear whichever arm is asking. When the cloud arm is the reason, the+ // general confirm is already off, so clearing that one would change nothing+ // and the prompt would return on the very next command.+ if (pending.cloudReason) updateSettings({ codexCloudConfirmShell: false })+ else updateSettings({ codexConfirmShell: false })+ answer(true)+ }++ return (+ <div className="px-1 py-0.5" data-codex-confirm>+ <div className="rounded-lg border border-purple-500/20 bg-purple-500/[0.04] px-2 py-1.5">+ <div className="flex items-center gap-1.5 text-[0.65rem] text-gray-700 dark:text-gray-300">+ <Terminal size={10} className="text-purple-400 shrink-0" />+ <span className="font-mono">{pending.toolName}</span>+ <span className="text-gray-500">needs your ok</span>+ </div>++ <pre className="mt-1 max-h-20 overflow-auto rounded bg-black/5 dark:bg-black/30 px-1.5 py-1 text-[0.63rem] font-mono text-gray-800 dark:text-gray-200 whitespace-pre-wrap break-all">+ {pending.command || '(no command preview)'}+ </pre>++ <div className="mt-1.5 flex items-center gap-1.5">+ <button+ onClick={() => answer(true)}+ autoFocus+ className="px-2 py-0.5 rounded text-[0.62rem] font-medium bg-emerald-500/15 text-emerald-700 dark:text-emerald-300 hover:bg-emerald-500/25 transition-colors"+ >+ Run+ </button>+ <button+ onClick={() => answer(false)}+ className="px-2 py-0.5 rounded text-[0.62rem] text-gray-600 dark:text-gray-400 hover:bg-gray-200/60 dark:hover:bg-white/5 transition-colors"+ >+ No+ </button>+ <div className="flex-1" />+ {pending.cloudReason && (+ <span className="text-[0.55rem] text-gray-500">cloud model</span>+ )}+ <button+ onClick={stopAsking}+ className="text-[0.58rem] text-gray-500 hover:text-gray-800 dark:hover:text-gray-200 transition-colors"+ >+ Don't ask again+ </button>+ </div>+ </div>+ </div>+ )+}diff --git a/src/components/chat/CodexView.tsx b/src/components/chat/CodexView.tsxindex d0badae9..69f99e7f 100644--- a/src/components/chat/CodexView.tsx+++ b/src/components/chat/CodexView.tsx@@ -21,6 +21,7 @@ import { User, Code, Eye, GitBranch, Download, RefreshCw, RotateCcw, Folder, X }import { useEffect, useRef, useState } from 'react'import { checkGitInstalled, openExternal, type GitStatus } from '../../api/backend'import { extractToolCallsWithRanges, stripRanges } from '../../lib/tool-call-repair'+import { CodexConfirmDialog } from './CodexConfirmDialog'function stripChannelTags(text: string): string {let t = text@@ -498,6 +499,11 @@ export function CodexView() {the per-conversation flag so switching to another (idle) chatdoesn't show its dots — David 2026-06-12 ("die drei ladepunktekommen in vorherigen chats auch"). */}+ {/* Shell/code approval, inline in the stream so it reads as the+ next step of the run instead of covering it (David 2026-07-24:+ "ich hätte das gerne im chat, wie ein tool call"). Renders+ nothing while no request is pending. */}+ <CodexConfirmDialog />{codexGenerating && (<TypingIndicator />)}diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.tsindex b96b4326..65572739 100644--- a/src/hooks/useCodex.ts+++ b/src/hooks/useCodex.ts@@ -46,6 +46,7 @@ import { getModelContextCached } from '../api/ollama'import { useMemoryStore } from '../stores/memoryStore'import { extractMemoriesFromPair } from './useMemory'import type { OllamaChatMessage } from '../types/agent-mode'+import { useCodexConfirmStore } from '../stores/codexConfirmStore'// No-op diagnostic hook. Kept as a call site so future debugging can swap// this for a file logger without re-editing every iter-point in the loop.@@ -1342,22 +1343,14 @@ export function useCodex() {? async (req) => {if (!CODEX_CONFIRM_TOOLS.has(req.toolName)) return trueconst a = req.args || {}- const preview = String(a.command ?? a.code ?? a.script ?? '').slice(0, 800)- // Name the reason when the CLOUD arm is what is asking. Without- // it the user has the confirm setting off and still gets a- // prompt, which is exactly what read as broken before 2.5.9.- const cloudReason =- !settings.codexConfirmShell && providerId === 'lu-cloud'- ? `\n\nCloud models confirm commands by default. Turn that off in Settings under Coding.`- : ''- const msg =- `Coding agent wants to run "${req.toolName}":\n\n` +- `${preview || '(no command preview)'}\n\n` +- `Allow it to run?${cloudReason}`- if (typeof window !== 'undefined' && typeof window.confirm === 'function') {- return window.confirm(msg)- }- return true+ // In-app popup, not window.confirm. The native dialog carried OS+ // chrome and the app origin in its title bar, could not be+ // styled, and had no way to say "stop asking" (David 2026-07-24).+ return useCodexConfirmStore.getState().ask({+ toolName: req.toolName,+ command: String(a.command ?? a.code ?? a.script ?? '').slice(0, 800),+ cloudReason: !settings.codexConfirmShell && providerId === 'lu-cloud',+ })}: undefined,recordAudit: (entry) => {diff --git a/src/stores/__tests__/codexConfirmStore.test.ts b/src/stores/__tests__/codexConfirmStore.test.tsnew file mode 100644index 00000000..f7f9369a--- /dev/null+++ b/src/stores/__tests__/codexConfirmStore.test.ts@@ -0,0 +1,58 @@+import { describe, it, expect, beforeEach } from 'vitest'+import { useCodexConfirmStore } from '../codexConfirmStore'++// The gate used to be window.confirm, which blocks the whole webview and cannot+// be styled or dismissed with "stop asking". This store is the bridge that lets+// an in-app popup answer the same awaited boolean.++const req = (command: string, cloudReason = false) => ({+ toolName: 'shell_execute',+ command,+ cloudReason,+})++beforeEach(() => {+ useCodexConfirmStore.setState({ pending: null, resolve: null })+})++describe('codexConfirmStore', () => {+ it('parks the request and resolves true on Run', async () => {+ const p = useCodexConfirmStore.getState().ask(req('ls -la'))+ expect(useCodexConfirmStore.getState().pending?.command).toBe('ls -la')+ useCodexConfirmStore.getState().answer(true)+ await expect(p).resolves.toBe(true)+ })++ it('resolves false on No', async () => {+ const p = useCodexConfirmStore.getState().ask(req('rm -rf /'))+ useCodexConfirmStore.getState().answer(false)+ await expect(p).resolves.toBe(false)+ })++ it('clears the pending request once answered, so the popup closes', () => {+ void useCodexConfirmStore.getState().ask(req('echo hi'))+ useCodexConfirmStore.getState().answer(true)+ expect(useCodexConfirmStore.getState().pending).toBeNull()+ expect(useCodexConfirmStore.getState().resolve).toBeNull()+ })++ it('never strands a resolver when a second request arrives', async () => {+ // Two tools racing would otherwise leave the first awaiting forever, and+ // that tool call hangs with no visible cause. Deny the older one.+ const first = useCodexConfirmStore.getState().ask(req('first'))+ const second = useCodexConfirmStore.getState().ask(req('second'))+ await expect(first).resolves.toBe(false)+ expect(useCodexConfirmStore.getState().pending?.command).toBe('second')+ useCodexConfirmStore.getState().answer(true)+ await expect(second).resolves.toBe(true)+ })++ it('carries the cloud reason through, since it picks which setting to clear', () => {+ void useCodexConfirmStore.getState().ask(req('whoami', true))+ expect(useCodexConfirmStore.getState().pending?.cloudReason).toBe(true)+ })++ it('answering with nothing pending does not throw', () => {+ expect(() => useCodexConfirmStore.getState().answer(true)).not.toThrow()+ })+})diff --git a/src/stores/codexConfirmStore.ts b/src/stores/codexConfirmStore.tsnew file mode 100644index 00000000..6477fb0b--- /dev/null+++ b/src/stores/codexConfirmStore.ts@@ -0,0 +1,50 @@+// The coding agent's "may I run this" gate, as app UI instead of window.confirm.+//+// It used to be a raw `window.confirm`, which in the Tauri webview renders as an+// OS dialog: system chrome, the app origin in the title bar, the whole prompt as+// one wall of text, and no way to say "stop asking". David, 2026-07-24, on+// seeing it fire for the first time: "der dialog ist ja hässlich wie sau".+//+// A promise-bridge is what lets the same awaitApproval contract keep working:+// useCodex still awaits a boolean, the store parks the resolver, the dialog+// resolves it on click.++import { create } from 'zustand'++export interface CodexConfirmRequest {+ /** shell_execute / code_execute / shell_execute_background */+ toolName: string+ /** The command itself, already trimmed for display. */+ command: string+ /** True when the CLOUD arm is the only reason we are asking, which changes+ * both the hint we show and which setting "don't ask again" turns off. */+ cloudReason: boolean+}++interface CodexConfirmState {+ pending: CodexConfirmRequest | null+ /** Resolver for the awaited approval. Null when nothing is pending. */+ resolve: ((allow: boolean) => void) | null+ ask: (req: CodexConfirmRequest) => Promise<boolean>+ answer: (allow: boolean) => void+}++export const useCodexConfirmStore = create<CodexConfirmState>((set, get) => ({+ pending: null,+ resolve: null,++ ask: (req) =>+ new Promise<boolean>((resolve) => {+ // A second request while one is open would strand the first resolver and+ // hang that tool call forever. Deny the older one and take the new.+ const prev = get().resolve+ if (prev) prev(false)+ set({ pending: req, resolve })+ }),++ answer: (allow) => {+ const { resolve } = get()+ set({ pending: null, resolve: null })+ resolve?.(allow)+ },+}))