Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 16 additions & 0 deletions server/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,19 @@ 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)).toBe("/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();
});
});
9 changes: 8 additions & 1 deletion server/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,17 @@ 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 (opts.none) {
if (task.cwd !== null) {
task.cwd = null;
this.saveBots();
}
return null;
}
if (task.cwd === undefined) {
task.cwd = Object.keys(task.resumeCursors).length === 0 ? (bot.cwd ?? fallbackCwd ?? null) : null;
this.saveBots();
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