fix(codex-link): isolate model transfers and widen local connection capacity
Server CI and Windows package / verify (push) Successful in 2m3s
Server CI and Windows package / windows-package (push) Successful in 6m58s

This commit is contained in:
yilsem committed 2026-10-13 00:35:08 +03:00
1 parent 2718b460ed
commit 369f6c2ca8
16 files changed
+790 -40

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ export const CODEX_LINK_REFRESH_URL = `${CODEX_LINK_ORIGIN}/aiturk/codex-baglama
export const CODEX_LINK_MARKER = '# AITURK IDE Codex Baglama'
// Must equal SURUM in assets/codex-bridge/bridge.py; a running bridge that reports
// another version is restarted so an updated IDE never keeps an old bridge alive.
export const CODEX_BRIDGE_VERSION = '10'
export const CODEX_BRIDGE_VERSION = '11'
export const CODEX_LINK_LINE = `openai_base_url = "${CODEX_LINK_ORIGIN}/backend-api/codex" ${CODEX_LINK_MARKER}`
export const CODEX_LINK_RUN_KEY = 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'
+24
View File
@@ -39,6 +39,7 @@ interface World {
probesUntilUp: number
autostart: null | string
regFails: boolean
configWriteFails: boolean
/** Every observable effect, in order. */
events: string[]
clock: number
@@ -59,6 +60,7 @@ function createWorld(patch: Partial<World> & { files?: Map<string, string> } = {
staleVersion: null,
probesUntilUp: 0,
regFails: false,
configWriteFails: false,
spawnWorks: true,
...patch
}
@@ -71,6 +73,7 @@ function createWorld(patch: Partial<World> & { files?: Map<string, string> } = {
exists: file => world.files.has(file),
readText: file => world.files.get(file) ?? null,
writeTextAtomic: (file, text) => {
if (file === PATHS.codexConfig && world.configWriteFails) throw new Error('config locked')
world.events.push(`write ${file}`)
world.files.set(file, text)
},
@@ -332,6 +335,27 @@ describe('applyCodexLink', () => {
expect(world.listening).toBe(false)
})
it('keeps the bridge and login item if disconnect cannot restore the config', async () => {
const { link, world } = createWorld({ listening: true })
await link.apply()
const linkedConfig = world.files.get(PATHS.codexConfig)
const autostart = world.autostart
world.events.length = 0
world.configWriteFails = true
expect(await link.apply({ enabled: false })).toMatchObject({
bridgeRunning: true, lastError: 'config-write-failed'
})
expect(world.files.get(PATHS.codexConfig)).toBe(linkedConfig)
expect(world.autostart).toBe(autostart)
expect(world.events).not.toContain('stop')
expect(world.events).not.toContain('autostart clear')
world.configWriteFails = false
expect(await link.apply({ enabled: false })).toMatchObject({ bridgeRunning: false, lastError: null })
expect(world.files.get(PATHS.codexConfig)).toBe(USER_CONFIG)
})
it('stays off across applies and comes back when turned on', async () => {
const { link, world } = createWorld()
world.files.set(PATHS.settingsFile, '{"enabled": false, "kapsam": "ide", "not": "ours"}')
+5 -3
View File
@@ -218,10 +218,12 @@ export function createCodexLink(deps: CodexLinkDeps): CodexLink {
}
}
// Off: take back everything we put there. Each step is independent — a
// failure in one must not leave the others in place.
// Remove the owned URL before stopping its server. A failed config write
// must leave the working bridge alive so Codex is not stranded offline.
const tearDown = async (config: ReturnType<typeof readCodexConfig>): Promise<BridgeProbe> => {
removeOurLine(config.text)
if (!removeOurLine(config.text)) {
return probe()
}
try {
await deps.clearAutostart()