mirror of
https://github.com/block/goose.git
synced 2026-04-28 03:29:36 +00:00
fix: Allow starting a new session in a project after creating one (#8766)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3fbe01d3b6
commit
18127f1ff0
2 changed files with 52 additions and 3 deletions
|
|
@ -76,4 +76,49 @@ describe("findExistingDraft", () => {
|
|||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("does not reuse the active empty draft without content", () => {
|
||||
const draft = makeSession("alpha-draft", {
|
||||
projectId: "alpha",
|
||||
providerId: "goose",
|
||||
});
|
||||
|
||||
expect(
|
||||
findExistingDraft({
|
||||
sessions: [draft],
|
||||
activeSessionId: "alpha-draft",
|
||||
draftsBySession: {},
|
||||
messagesBySession: {},
|
||||
request: {
|
||||
title: "New Chat",
|
||||
projectId: "alpha",
|
||||
},
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("does not reuse a session with local messages even if messageCount is 0", () => {
|
||||
const session = makeSession("alpha-session", {
|
||||
projectId: "alpha",
|
||||
providerId: "goose",
|
||||
messageCount: 0,
|
||||
});
|
||||
|
||||
expect(
|
||||
findExistingDraft({
|
||||
sessions: [session],
|
||||
activeSessionId: "alpha-session",
|
||||
draftsBySession: {},
|
||||
messagesBySession: {
|
||||
"alpha-session": [
|
||||
{ id: "msg-1", role: "user", content: "hello" } as any,
|
||||
],
|
||||
},
|
||||
request: {
|
||||
title: "New Chat",
|
||||
projectId: "alpha",
|
||||
},
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -24,9 +24,13 @@ function isMatchingContext(
|
|||
|
||||
function isReusableDraft(
|
||||
session: ChatSession,
|
||||
_localMessages: Message[] | undefined,
|
||||
localMessages: Message[] | undefined,
|
||||
): boolean {
|
||||
return !session.archivedAt && session.messageCount === 0;
|
||||
return (
|
||||
!session.archivedAt &&
|
||||
session.messageCount === 0 &&
|
||||
(localMessages?.length ?? 0) === 0
|
||||
);
|
||||
}
|
||||
|
||||
export function findExistingDraft({
|
||||
|
|
@ -60,5 +64,5 @@ export function findExistingDraft({
|
|||
);
|
||||
}
|
||||
|
||||
return candidates.find((session) => session.id === activeSessionId);
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue