Skip to content
Open
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
28 changes: 25 additions & 3 deletions apps/web/src/components/Sidebar.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe("resolveSidebarNewThreadEnvMode", () => {
});

describe("resolveSidebarNewThreadSeedContext", () => {
it("prefers the default worktree mode over active thread context", () => {
it("preserves active draft context over the default worktree mode", () => {
expect(
resolveSidebarNewThreadSeedContext({
projectId: "project-1",
Expand All @@ -280,15 +280,18 @@ describe("resolveSidebarNewThreadSeedContext", () => {
},
}),
).toEqual({
branch: "feature/draft",
worktreePath: "/repo/.t3/worktrees/draft",
envMode: "worktree",
startFromOrigin: true,
});
});

it("inherits the active server thread context when creating a new thread in the same project", () => {
it("preserves the active branch over the default worktree mode", () => {
expect(
resolveSidebarNewThreadSeedContext({
projectId: "project-1",
defaultEnvMode: "local",
defaultEnvMode: "worktree",
activeThread: {
projectId: "project-1",
branch: "effect-atom",
Expand All @@ -303,6 +306,25 @@ describe("resolveSidebarNewThreadSeedContext", () => {
});
});

it("preserves the active worktree over the default worktree mode", () => {
expect(
resolveSidebarNewThreadSeedContext({
projectId: "project-1",
defaultEnvMode: "worktree",
activeThread: {
projectId: "project-1",
branch: "feature/existing",
worktreePath: "/repo/.t3/worktrees/existing",
},
activeDraftThread: null,
}),
).toEqual({
branch: "feature/existing",
worktreePath: "/repo/.t3/worktrees/existing",
envMode: "worktree",
});
});

it("prefers the active draft thread context when it matches the target project", () => {
expect(
resolveSidebarNewThreadSeedContext({
Expand Down
6 changes: 0 additions & 6 deletions apps/web/src/components/Sidebar.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,6 @@ export function resolveSidebarNewThreadSeedContext(input: {
envMode: SidebarNewThreadEnvMode;
startFromOrigin?: boolean;
} {
if (input.defaultEnvMode === "worktree") {
return {
envMode: "worktree",
};
}

if (input.activeDraftThread?.projectId === input.projectId) {
return {
branch: input.activeDraftThread.branch,
Expand Down
Loading