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
80 changes: 80 additions & 0 deletions apps/desktop/e2e/composer-session-reference.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { ensureSidebarExpanded, expect, test, COMPOSER_INPUT } from './fixtures';

test('references another Session from @, including a trailing-space browse', async ({
window: page,
}, testInfo) => {
const composer = page.locator(COMPOSER_INPUT);
const sourceName = 'Reference source';
const sourcePrompt = 'source transcript marker';

await composer.fill(sourcePrompt);
await composer.press('Enter');
await expect(page.getByText(`Fake backend received: ${sourcePrompt}`)).toBeVisible();
await expect(page.getByRole('button', { name: '重新生成' })).toHaveCount(1, {
timeout: 20_000,
});

await page.evaluate(async (name) => {
const source = (await window.maka.sessions.list())[0];
if (!source) throw new Error('the source Session was not created');
await window.maka.sessions.rename(source.id, name);
}, sourceName);

await ensureSidebarExpanded(page);
const sidebar = page.getByRole('navigation', { name: '任务列表' });
await sidebar.getByRole('button', { name: '新任务', exact: true }).click();
await expect(composer).toHaveText('');

await composer.click();
await composer.pressSequentially('@');
const menu = page.getByRole('listbox', { name: '工作区文件和会话' });
await expect(menu).toBeVisible();

const sourceOption = menu.getByRole('option', { name: sourceName, exact: true });
await expect(sourceOption).toBeVisible();
await expect(sourceOption.locator('svg.lucide-messages-square')).toHaveCount(1);

await composer.press('Space');
await expect(menu).toBeVisible();
await expect(sourceOption).toBeVisible();

await composer.fill('@reference');
await expect(sourceOption).toBeVisible();
await sourceOption.click();
await expect(menu).not.toBeVisible();

const chip = page.locator('.maka-composer-session-token');
await expect(chip).toContainText(sourceName);
await expect(chip.locator('svg.lucide-messages-square')).toHaveCount(1);
await page.screenshot({ path: testInfo.outputPath('session-reference-staged.png') });

const followUp = 'continue from the referenced session';
await composer.fill(followUp);
await composer.press('Enter');
const sent = page.getByLabel('你发送的消息').last();
await expect(sent).toContainText(followUp);
await expect(sent).toContainText(sourceName);
await expect(chip).toHaveCount(0);
await expect(page.getByRole('button', { name: '重新生成' })).toHaveCount(1, {
timeout: 20_000,
});
});
36 changes: 9 additions & 27 deletions apps/desktop/renderer-architecture.json
Original file line number Diff line number Diff line change
Expand Up @@ -979,25 +979,21 @@
"react": 1
},
"importSpecifiers": 180,
"nonTriviaTokens": 15620
"nonTriviaTokens": 15619
},
"src/renderer/use-app-shell-composer-quotes.ts": {
"importDeclarations": 3,
"importDeclarations": 1,
"bridgePaths": {},
"environmentCapabilities": {},
"hookCalls": {
"useState": 1
},
"hookCalls": {},
"lifecycleMethods": {},
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./pending-items.js": 1,
"@maka/core/events": 1,
"react": 1
"./features/conversation/index.js": 1
},
"importSpecifiers": 7,
"nonTriviaTokens": 360
"importSpecifiers": 1,
"nonTriviaTokens": 24
},
"src/renderer/use-app-shell-session-list.ts": {
"importDeclarations": 11,
Expand Down Expand Up @@ -1383,28 +1379,14 @@
}
},
"src/renderer/composer-mentions.tsx": {
"bridgePaths": {
"window.maka.mcp.subscribeChanges": 1,
"window.maka.newTasks.listInvocableSkills": 1,
"window.maka.newTasks.searchFiles": 1,
"window.maka.newTasks.subscribeChanges": 1,
"window.maka.sessions.subscribeChanges": 1,
"window.maka.skills.listInvocable": 1,
"window.maka.workspace.searchFiles": 1
},
"bridgePaths": {},
"environmentCapabilities": {},
"hookCalls": {
"useEffect": 1,
"useState": 1
},
"hookCalls": {},
"lifecycleMethods": {},
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"../preload/bridge-contract.js": 1,
"@maka/core/settings": 1,
"@maka/runtime/skill-invocation": 1,
"react": 1
"./features/conversation/index.js": 1
}
},
"src/renderer/conversation-markdown.ts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import assert from 'node:assert/strict';
import test from 'node:test';
import type { MakaBridge } from '../../preload/bridge-contract.js';
import { createDesktopConversationServices } from '../../renderer/platform/desktop/create-conversation-services.js';

test('Desktop conversation adapter keeps snapshot reads and catalog access on the bridge', async () => {
const calls: string[] = [];
const bridge = {
sessions: {
list: async () => [],
subscribeChanges: () => () => undefined,
readSnapshot: async (sessionId: string) => {
calls.push(`snapshot:${sessionId}`);
return {};
},
},
skills: { listInvocable: async () => [] },
workspace: { searchFiles: async () => ({ ok: false as const, reason: 'no_project' as const }) },
newTasks: {
subscribeChanges: () => () => undefined,
listInvocableSkills: async () => [],
searchFiles: async () => ({ ok: false as const, reason: 'no_project' as const }),
},
mcp: { subscribeChanges: () => () => undefined },
} as unknown as MakaBridge;
const services = createDesktopConversationServices(bridge);

await services.sessions.readSnapshot('source');
assert.deepEqual(await services.sessions.list(), []);
assert.deepEqual(calls, ['snapshot:source']);
});
17 changes: 17 additions & 0 deletions apps/desktop/src/main/__tests__/new-task-staged-content.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,23 @@ test('a Session keeps its own staged quotes, and the new-task bucket keeps its o
['quoted for the Session'],
);

await act(() => probe.latest().addQuote({
text: 'bounded session context',
label: 'Session: Research',
sourceSessionId: 'source-session',
sourceSessionName: 'Research',
sourceCapturedAt: 123,
sourceTruncated: true,
}));
assert.deepEqual(probe.latest().pendingQuotes.at(-1), {
text: 'bounded session context',
label: 'Session: Research',
sourceSessionId: 'source-session',
sourceSessionName: 'Research',
sourceCapturedAt: 123,
sourceTruncated: true,
});

await probe.render(NEW_TASK_PENDING_KEY);
assert.deepEqual(
probe.latest().pendingQuotes.map((quote) => quote.text),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,16 @@ describe('permission response IPC boundary', () => {
],
turnOrchestration: { mode: 'swarm', source: 'slash_command', ignored: true },
quotes: [
{ text: 'the excerpt', label: ' Assistant ', sourceTurnId: 'turn-9', extra: true },
{
text: 'the excerpt',
label: ' Assistant ',
sourceTurnId: 'turn-9',
sourceSessionId: 'source-session',
sourceSessionName: 'Research',
sourceCapturedAt: 123,
sourceTruncated: false,
extra: true,
},
],
workspaceFileReferences: [
{
Expand Down Expand Up @@ -223,7 +232,15 @@ describe('permission response IPC boundary', () => {
},
],
turnOrchestration: { mode: 'swarm', source: 'slash_command' },
quotes: [{ text: 'the excerpt', label: 'Assistant', sourceTurnId: 'turn-9' }],
quotes: [{
text: 'the excerpt',
label: 'Assistant',
sourceTurnId: 'turn-9',
sourceSessionId: 'source-session',
sourceSessionName: 'Research',
sourceCapturedAt: 123,
sourceTruncated: false,
}],
workspaceFileReferences: [
{
value: '@packages/ui/src/chat turn.tsx',
Expand Down Expand Up @@ -253,6 +270,7 @@ describe('permission response IPC boundary', () => {
{ type: 'send', text: 'hello', quotes: Array(17).fill({ text: 'x' }) },
{ type: 'send', text: 'hello', quotes: [{ text: '' }] },
{ type: 'send', text: 'hello', quotes: [{ text: 'x', sourceTurnId: 1 }] },
{ type: 'send', text: 'hello', quotes: [{ text: 'x', sourceSessionId: 'source-session' }] },
{ type: 'send', text: 'hello', workspaceFileReferences: {} },
{
type: 'send',
Expand Down
Loading