Skip to content

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.

fix(codex): die tote zweite Rechnung des Arbeitsordners geloescht

purple99dcee4e4ffc
diff --git a/src/lib/__tests__/codex-workdir.test.ts b/src/lib/__tests__/codex-workdir.test.ts
index b35a68ca..b92f5683 100644
--- a/src/lib/__tests__/codex-workdir.test.ts
+++ b/src/lib/__tests__/codex-workdir.test.ts
@@ -2,73 +2,24 @@
* The two verdicts A8 turned out to need, pulled out of the hook and the two
* views so they can be tested at all (review S6, S3).
*
- * The precedence used to be a three-line boolean chain inside a 2000-line
- * send, and "is a run in flight" was written out by hand on each surface, once
- * per surface, differently. That is how the first cut of the fix ended up
- * overwriting a deliberate per-chat workspace and locking the folder picker
- * whenever an unrelated Chat tab was streaming.
+ * "Is a run in flight" was written out by hand on each surface, once per
+ * surface, differently. That is how the first cut of the fix ended up locking
+ * the folder picker whenever an unrelated Chat tab was streaming.
+ *
+ * Die Rangfolge des Arbeitsordners stand bis 3.0.0 ebenfalls hier, als zweite
+ * Rechnung ohne Aufrufer. Sechs Faelle massen sie, und keiner davon fasste die
+ * ausgelieferte Rechnung an. Beides ist weg; gemessen wird die lebende Stelle
+ * in `src/hooks/codex/__tests__/ein-lauf.test.ts` (R2-42).
*
* Run: npx vitest run src/lib/__tests__/codex-workdir.test.ts
*/
import { describe, it, expect } from 'vitest'
import {
- CODEX_SANDBOX,
CODEX_WORKDIR_LOCK_TITLE,
codexBusyReason,
codexFallbackLabel,
- resolveCodexWorkDir,
} from '../codex-workdir'
-const WINDOWS_PATH = 'C:\\Users\\helpslowlydying\\Documents\\My Projects'
-
-describe('where the Coding Agent works', () => {
- it('the thread wins, it carries what the picker last said', () => {
- expect(resolveCodexWorkDir({
- threadDir: '/thread', workspacePath: '/workspace', storeDir: '/store',
- })).toBe('/thread')
- })
-
- it("a thread holding the bare '.' is not a pick, so the workspace wins", () => {
- expect(resolveCodexWorkDir({
- threadDir: CODEX_SANDBOX, workspacePath: '/workspace', storeDir: '',
- })).toBe('/workspace')
- // Negative control: a real path in the same slot does win.
- expect(resolveCodexWorkDir({
- threadDir: '/thread', workspacePath: '/workspace', storeDir: '',
- })).toBe('/thread')
- })
-
- it('an empty thread hands it to the per-chat workspace or the default one', () => {
- expect(resolveCodexWorkDir({
- threadDir: '', workspacePath: '/workspace', storeDir: '',
- })).toBe('/workspace')
- })
-
- it('nothing anywhere means the per-chat sandbox', () => {
- expect(resolveCodexWorkDir({
- threadDir: '', workspacePath: null, storeDir: '',
- })).toBe(CODEX_SANDBOX)
- // Negative control against null and undefined leaking through as a path.
- expect(resolveCodexWorkDir({
- threadDir: undefined, workspacePath: undefined, storeDir: undefined,
- })).toBe(CODEX_SANDBOX)
- })
-
- it('the picker still catches a thread that has not been synced yet', () => {
- expect(resolveCodexWorkDir({
- threadDir: '', workspacePath: null, storeDir: WINDOWS_PATH,
- })).toBe(WINDOWS_PATH)
- })
-
- it('a Windows path passes through untouched', () => {
- const out = resolveCodexWorkDir({
- threadDir: WINDOWS_PATH, workspacePath: null, storeDir: '',
- })
- expect(out).toBe(WINDOWS_PATH)
- expect(out).not.toContain('/')
- })
-})
-
describe('what the empty state is allowed to promise', () => {
it('names the workspace that actually wins over an empty picker', () => {
expect(codexFallbackLabel('/home/dave/default-repo')).toBe('/home/dave/default-repo')
diff --git a/src/lib/codex-workdir.ts b/src/lib/codex-workdir.ts
index 67a468b4..745c7b0b 100644
--- a/src/lib/codex-workdir.ts
+++ b/src/lib/codex-workdir.ts
@@ -1,44 +1,18 @@
/**
- * Where the Coding Agent actually works, and when that may be changed.
+ * When the Coding Agent's working directory may be changed, and what the empty
+ * state is allowed to promise.
*
- * Both halves used to live inline in useCodex and in the two views, which is
- * how A8 (2.6.8) got as far as it did: the precedence was a three-line boolean
- * chain nobody could test, and "is a run in flight" was a different expression
- * on every surface. They are pure functions here, with the tests next to them.
- */
-import { isActiveCodexStatus, type CodexThreadStatus } from '../types/codex'
-
-export interface CodexWorkDirInput {
- /** The folder pinned on this conversation's thread. */
- threadDir: string | null | undefined
- /** Per-chat agent workspace, or settings.defaultWorkspace, when folder-kind. */
- workspacePath: string | null | undefined
- /** The folder the Code tab's picker currently shows. */
- storeDir: string | null | undefined
-}
-
-/** The bridge's per-chat sandbox under ~/agent-workspace. */
-export const CODEX_SANDBOX = '.'
-
-/**
- * Precedence, unchanged from the inline version it replaces:
- * 1. the thread's own folder (the picker value, synced at every send)
- * 2. the resolved agent workspace, when it names a real folder
- * 3. the picker value again, for a thread that has not been synced yet
- * 4. the per-chat sandbox
+ * "Is a run in flight" used to be a different expression on every surface,
+ * which is how A8 (2.6.8) got as far as it did. It is a pure function here,
+ * with the tests next to it.
*
- * A thread carrying the literal '.' does NOT count as a pick. It is what
- * `initThread` writes when there is no folder, and treating it as one used to
- * hide a per-chat workspace behind a placeholder.
+ * WO der Agent arbeitet, steht NICHT hier, sondern in
+ * `hooks/codex/workspace-precedence.ts`, wo `useCodex` es auch liest. Bis 3.0.0
+ * lag daneben eine zweite Rechnung derselben Rangfolge, die kein Aufrufer je
+ * gelesen hat, waehrend sechs Tests sie massen und damit die ausgelieferte
+ * Rechnung gruen aussehen liessen, ohne sie anzufassen (R2-42).
*/
-export function resolveCodexWorkDir({
- threadDir,
- workspacePath,
- storeDir,
-}: CodexWorkDirInput): string {
- const fromThread = threadDir && threadDir !== CODEX_SANDBOX ? threadDir : null
- return fromThread || workspacePath || storeDir || CODEX_SANDBOX
-}
+import { isActiveCodexStatus, type CodexThreadStatus } from '../types/codex'
/**
* What the agent falls back to when the picker is empty, in the words the user