fix(desktop): start a chat with no extensions when the user selects none (#11908)
Signed-off-by: Seydi Charyyev <seydi.charyev@gmail.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import { UserInput } from '../types/message';
|
||||
type ChatInputCapture = {
|
||||
draftRef?: { current: string };
|
||||
handleSubmit: (input: UserInput) => void;
|
||||
onNextChatExtensionDraftChange?: (draft: { selectedNames: Set<string> }) => void;
|
||||
};
|
||||
|
||||
type Session = Awaited<ReturnType<typeof createSession>>;
|
||||
@@ -82,6 +83,29 @@ describe('Hub', () => {
|
||||
captured.chatInput = null;
|
||||
});
|
||||
|
||||
it('starts a chat with no extensions when the user cleared the picker', async () => {
|
||||
vi.mocked(createSession).mockResolvedValue({ id: 'session-1' } as Session);
|
||||
renderHub({ current: '' });
|
||||
|
||||
// Touching the picker is what turns "not specified" into a real choice, and
|
||||
// clearing it is the case the composer already promises in a toast.
|
||||
await act(async () => {
|
||||
captured.chatInput?.onNextChatExtensionDraftChange?.({ selectedNames: new Set() });
|
||||
});
|
||||
await submit();
|
||||
|
||||
expect(createSession).toHaveBeenCalledWith('/tmp/goose', { extensionConfigs: [] });
|
||||
});
|
||||
|
||||
it('leaves the set unspecified when the picker was never touched', async () => {
|
||||
vi.mocked(createSession).mockResolvedValue({ id: 'session-1' } as Session);
|
||||
renderHub({ current: '' });
|
||||
|
||||
await submit();
|
||||
|
||||
expect(createSession).toHaveBeenCalledWith('/tmp/goose', { allExtensions: [] });
|
||||
});
|
||||
|
||||
it('hands the draft to the input', () => {
|
||||
const draftRef = { current: DRAFT };
|
||||
renderHub(draftRef);
|
||||
|
||||
@@ -111,13 +111,13 @@ export default function Hub({
|
||||
setIsCreatingSession(true);
|
||||
|
||||
try {
|
||||
const selectedExtensions = nextChatExtensionDraft
|
||||
? selectNextChatExtensions(extensionsList, nextChatExtensionDraft)
|
||||
: [];
|
||||
const sessionOptions =
|
||||
selectedExtensions.length > 0
|
||||
? { extensionConfigs: selectedExtensions }
|
||||
: { allExtensions: extensionsList };
|
||||
// A draft exists only once the user has opened the picker, so its absence is
|
||||
// "not specified" while an empty draft is "start with no extensions".
|
||||
const sessionOptions = nextChatExtensionDraft
|
||||
? {
|
||||
extensionConfigs: selectNextChatExtensions(extensionsList, nextChatExtensionDraft),
|
||||
}
|
||||
: { allExtensions: extensionsList };
|
||||
|
||||
// Resolve the effective directory at submit time: the IPC lookup may still
|
||||
// be pending when the user submits, and an explicit pick must win.
|
||||
|
||||
@@ -73,7 +73,8 @@ export default function StandaloneAppView() {
|
||||
}
|
||||
|
||||
try {
|
||||
const { sessionId: sid } = await acpNewSession(workingDir, []);
|
||||
// This view names no extension set, so the backend uses the configured one.
|
||||
const { sessionId: sid } = await acpNewSession(workingDir, undefined);
|
||||
setSessionId(sid);
|
||||
setLoading(false);
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user