Skip to content

Commit 627ab75

Browse files
fix(server): share SQLite for terminal-selected managed Codex homes
1 parent 289584b commit 627ab75

2 files changed

Lines changed: 34 additions & 24 deletions

File tree

‎apps/server/src/terminal/Manager.ts‎

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,27 @@ interface TerminalManagerOptions {
13641364
>;
13651365
}
13661366

1367+
const pathsReferToSameDirectory = Effect.fnUntraced(function* (left: string, right: string) {
1368+
if (left === right) return true;
1369+
const fs = yield* FileSystem.FileSystem;
1370+
// An unavailable unused home cannot add a launch gate. Unknown identity still inspects.
1371+
const [leftInfo, rightInfo] = yield* Effect.all([
1372+
fs.stat(left).pipe(Effect.option),
1373+
fs.stat(right).pipe(Effect.option),
1374+
]);
1375+
return (
1376+
Option.isSome(leftInfo) &&
1377+
Option.isSome(rightInfo) &&
1378+
leftInfo.value.type === "Directory" &&
1379+
rightInfo.value.type === "Directory" &&
1380+
Option.isSome(leftInfo.value.ino) &&
1381+
Option.isSome(rightInfo.value.ino) &&
1382+
leftInfo.value.ino.value > 0 &&
1383+
leftInfo.value.dev === rightInfo.value.dev &&
1384+
leftInfo.value.ino.value === rightInfo.value.ino.value
1385+
);
1386+
});
1387+
13671388
export const resolveProviderInstanceTerminalEnvironment = Effect.fn(
13681389
"terminal.resolveProviderInstanceTerminalEnvironment",
13691390
)(function* (input: {
@@ -1442,30 +1463,17 @@ export const resolveProviderInstanceTerminalEnvironment = Effect.fn(
14421463
: input.cwd + "/" + selected;
14431464
if (
14441465
recoveryLayout.mode === "authOverlay" &&
1445-
selectedPath === recoveryLayout.effectiveHomePath
1446-
)
1466+
recoveryLayout.effectiveHomePath &&
1467+
(yield* pathsReferToSameDirectory(selectedPath, recoveryLayout.effectiveHomePath))
1468+
) {
1469+
resolved = withCodexSqliteHome(recoveryLayout, resolved);
14471470
return;
1448-
if (layout.mode === "direct") {
1449-
if (selectedPath === layout.sharedHomePath) return;
1450-
const fs = yield* FileSystem.FileSystem;
1451-
// An unavailable unused shared home cannot add a launch gate. Unknown identity still inspects.
1452-
const [selectedInfo, sharedInfo] = yield* Effect.all([
1453-
fs.stat(selectedPath).pipe(Effect.option),
1454-
fs.stat(layout.sharedHomePath).pipe(Effect.option),
1455-
]);
1456-
if (
1457-
Option.isSome(selectedInfo) &&
1458-
Option.isSome(sharedInfo) &&
1459-
selectedInfo.value.type === "Directory" &&
1460-
sharedInfo.value.type === "Directory" &&
1461-
Option.isSome(selectedInfo.value.ino) &&
1462-
Option.isSome(sharedInfo.value.ino) &&
1463-
selectedInfo.value.ino.value > 0 &&
1464-
selectedInfo.value.dev === sharedInfo.value.dev &&
1465-
selectedInfo.value.ino.value === sharedInfo.value.ino.value
1466-
)
1467-
return;
14681471
}
1472+
if (
1473+
layout.mode === "direct" &&
1474+
(yield* pathsReferToSameDirectory(selectedPath, layout.sharedHomePath))
1475+
)
1476+
return;
14691477
yield* inspectCodexShadowSqlite({
14701478
...layout,
14711479
mode: "authOverlay",

‎docs/user/providers-codex.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ symlinks, including dangling or orphaned sidecar links, until you recover the
3737
data and manually remove those links.
3838

3939
For accounts connected through T3 Code, generated shadow homes normally live at
40-
`~/.t3/userdata/providers/codex/<provider-instance-id>/shadow`. On the environment's
41-
machine, list the account directories with:
40+
`~/.t3/userdata/providers/codex/<provider-instance-id>/shadow` on macOS and Linux,
41+
or `%USERPROFILE%\.t3\userdata\providers\codex\<provider-instance-id>\shadow` on
42+
Windows. On the environment's macOS or Linux machine, list the account directories
43+
with:
4244

4345
```bash
4446
ls -d ~/.t3/userdata/providers/codex/*/shadow

0 commit comments

Comments
 (0)