Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,10 @@ async function startTurn(
// the private bot workspace. A legacy task with an existing provider
// session deliberately pins to null (the old home-folder behavior),
// because moving a live session would break resume.
// A cloud run happens on the box, where a host folder means nothing:
// pin the task to the default so the header chip never shows the
// bot's folder for a task that runs elsewhere.
if (opts?.runOn === "cloud") store.pinTaskCwd(bot.id, threadId, undefined, { none: true });
const pinnedCwd =
privateWorkspace && opts?.runOn !== "cloud"
? store.pinTaskCwd(bot.id, threadId, privateWorkspace)
Expand Down
15 changes: 15 additions & 0 deletions server/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,18 @@ describe("Store task working folder", () => {
expect(store.pinTaskCwd(bot.id, bot.threadId)).toBeNull();
});
});

describe("Store task working folder — cloud runs", () => {
beforeEach(() => {
rmSync(DATA_DIR, { recursive: true, force: true });
});
it("a cloud run pins the default so the bot's host folder never shows for that task", () => {
const store = new Store(selection);
const bot = store.createBot();
store.patchBot(bot.id, { cwd: "/tmp/project-a" });
expect(store.pinTaskCwd(bot.id, bot.threadId, undefined, { none: true })).toBeNull();
expect(store.taskByThread(bot.id, bot.threadId)?.cwd).toBeNull();
// and it stays pinned even if a host run follows
expect(store.pinTaskCwd(bot.id, bot.threadId)).toBeNull();
});
});
6 changes: 4 additions & 2 deletions server/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,12 +701,14 @@ export class Store {
* current folder — unless the task already has a session (a thread from
* before folders existed), which pins to the default so the folder can't
* move under it. Returns the pinned value: a path, or null for default. */
pinTaskCwd(botId: string, threadId: string, fallbackCwd?: string): string | null {
pinTaskCwd(botId: string, threadId: string, fallbackCwd?: string, opts: { none?: boolean } = {}): string | null {
const bot = this.bot(botId);
const task = bot ? this.taskByThread(botId, threadId) : undefined;
if (!bot || !task) return null;
if (task.cwd === undefined) {
task.cwd = Object.keys(task.resumeCursors).length === 0 ? (bot.cwd ?? fallbackCwd ?? null) : null;
// a cloud run has no host folder at all — pin the default so the UI
// never shows the bot's folder for a task that runs elsewhere
task.cwd = opts.none ? null : Object.keys(task.resumeCursors).length === 0 ? (bot.cwd ?? fallbackCwd ?? null) : null;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
this.saveBots();
}
return task.cwd;
Expand Down
3 changes: 2 additions & 1 deletion src/components/SettingsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ function WorkingFolder({ bot }: { bot: Bot }) {
className="mt-3 flex items-center gap-2"
onSubmit={(e) => {
e.preventDefault();
void save(draft ?? bot.cwd ?? "");
// an emptied field clears the folder — the server wants null
void save((draft ?? bot.cwd ?? "").trim() || null);
}}
>
<input
Expand Down
Loading