Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (codex): keep an external TUI run's cwd pinned to its spawn repo

[._.]/ Adam Eivyc8a1e8674c55
diff --git a/server/services/shell.js b/server/services/shell.js
index de22d668df..117dd09933 100644
--- a/server/services/shell.js
+++ b/server/services/shell.js
@@ -602,8 +602,13 @@ export function changeSessionDirectory(sessionId, dirPath) {
// come from the managed-apps list, so they exist. Asking the PTY for its REAL cwd
// would need a per-platform probe plus a round-trip, which is not worth it for a
// label; a rejected path just leaves the label wrong until the next cd.
- session.cwd = dirPath;
- broadcastSessionList();
+ // …but only for an interactive shell. An external (TUI-run) session has no shell
+ // reading that line — the bytes land in the agent as typed text — and its `cwd` is
+ // the repo the RUN was spawned in, which is what workspaceContext groups runs by.
+ if (!session.external) {
+ session.cwd = dirPath;
+ broadcastSessionList();
+ }
return true;
}
diff --git a/server/services/shell.test.js b/server/services/shell.test.js
index 0ce05e7cdc..6d85a4e5b5 100644
--- a/server/services/shell.test.js
+++ b/server/services/shell.test.js
@@ -412,6 +412,17 @@ describe('changeSessionDirectory', () => {
shell.unsubscribeSessionList(observer);
});
+ it('leaves an external TUI run cwd pinned to the repo it was spawned in', () => {
+ // A cd typed at an agent TUI is text the agent reads, not a shell directory
+ // change — and workspaceContext groups runs by the repo they were spawned in.
+ const sock = makeSocket('sock-ext');
+ const pty = makeFakePty();
+ shell.registerExternalSession('run-1', pty, { cwd: '/home/user/example', label: 'Claude Code TUI' });
+
+ expect(shell.changeSessionDirectory('run-1', '/home/user/example-app')).toBe(true);
+ expect(shell.listAllSessions(sock).find(s => s.sessionId === 'run-1').cwd).toBe('/home/user/example');
+ });
+
it('leaves cwd untouched when the session is gone', () => {
const sock = makeSocket('sock-cd-gone');
const id = shell.createShellSession(sock, { shell: '/bin/zsh', cwd: '/home/user/example' });