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
7 changes: 4 additions & 3 deletions packages/desktop/src/common/adapter/apiModelMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ export type CreateConversationBodyInput = {
* agent types carry model info via `extra`.
*/
export function buildCreateConversationBody(p: CreateConversationBodyInput): Record<string, unknown> {
const hasAssistant = p.assistant !== undefined && p.assistant !== null;
// aioncore >= v0.1.72 rejects create bodies without top-level `type` and
// `extra` ("Invalid JSON request body"), so both must always be present.
const body: Record<string, unknown> = {
type: hasAssistant ? undefined : p.type,
type: p.type,
id: p.id,
name: p.name,
assistant: p.assistant,
extra: p.extra,
extra: p.extra ?? {},
};
const model = p.type === 'acp' ? undefined : toApiModelOptional(p.model);
if (model) body.model = model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export const useGuidSend = (deps: GuidSendDeps): GuidSendResult => {
}
try {
const conversation = await ipcBridge.conversation.create.invoke({
type: 'aionrs',
name: input,
model: current_model,
assistant: {
Expand Down Expand Up @@ -232,6 +233,7 @@ export const useGuidSend = (deps: GuidSendDeps): GuidSendResult => {

try {
const conversation = await ipcBridge.conversation.create.invoke({
type: 'acp',
name: input,
assistant: {
id: assistantConversationId,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/common-adapter/apiModelMapper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ describe('apiModelMapper', () => {
expect('model' in body).toBe(false);
});

it('strips legacy type when assistant identity is present', () => {
it('passes type through when assistant identity is present', () => {
const body = buildCreateConversationBody({
type: 'acp',
name: 'hello',
assistant: { id: 'bare:claude' },
extra: {},
});

expect(body.type).toBeUndefined();
expect(body.type).toBe('acp');
});

it('omits the top-level model for ACP creates that pass an empty placeholder', () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/renderer/useGuidSend.dom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('useGuidSend', () => {

expect(createConversationInvokeMock).toHaveBeenCalledTimes(1);
const payload = createConversationInvokeMock.mock.calls[0][0];
expect(payload.type).toBeUndefined();
expect(payload.type).toBe('acp');
expect('model' in payload).toBe(false);
expect(payload.assistant?.conversation_overrides?.permission).toBe('bypassPermissions');
expect(payload.assistant?.conversation_overrides?.model).toBe('claude-opus');
Expand Down Expand Up @@ -200,7 +200,7 @@ describe('useGuidSend', () => {
});

const payload = createConversationInvokeMock.mock.calls[0][0];
expect(payload.type).toBeUndefined();
expect(payload.type).toBe('aionrs');
expect(payload.model).toBe(deps.current_model);
expect(payload.assistant?.id).toBe('bare:aionrs');
expect(payload.assistant?.conversation_overrides?.skill_ids).toEqual(['pdf-reader']);
Expand Down Expand Up @@ -239,7 +239,7 @@ describe('useGuidSend', () => {

const payload = createConversationInvokeMock.mock.calls[0][0];
expect(payload.assistant?.id).toBe('bare:claude');
expect(payload.type).toBeUndefined();
expect(payload.type).toBe('acp');
expect('model' in payload).toBe(false);
expect(payload.extra.preset_assistant_id).toBeUndefined();
expect(payload.extra.backend).toBeUndefined();
Expand Down
Loading