Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

perf(desktop): reduce repeated work during task navigation

DavidShen849315e54bc8
diff --git a/apps/desktop/src/main/localDb/__tests__/mapperMarkdownPreview.test.ts b/apps/desktop/src/main/localDb/__tests__/mapperMarkdownPreview.test.ts
index 1030fc8143..ed19e84027 100644
--- a/apps/desktop/src/main/localDb/__tests__/mapperMarkdownPreview.test.ts
+++ b/apps/desktop/src/main/localDb/__tests__/mapperMarkdownPreview.test.ts
@@ -1,9 +1,33 @@
-import { describe, expect, it } from 'vitest';
+import { describe, expect, it, vi } from 'vitest';
+import { markdownPreviewText } from '../../../shared/markdownPreviewText';
+
+vi.mock('../../../shared/markdownPreviewText', async (importOriginal) => {
+ const actual = await importOriginal<typeof import('../../../shared/markdownPreviewText')>();
+ return { ...actual, markdownPreviewText: vi.fn(actual.markdownPreviewText) };
+});
import { extractMessagePreview, finalizePlainPreview, sessionToCamel } from '../mapper';
import type { SessionRowWithCount } from '../mapper';
describe('sidebar Markdown preview', () => {
+ // Unit regression: repeated task-list reads must reuse the same pure preview
+ // without retaining stale text or mixing assistant citation handling with user text.
+ // Existing format tests do not cover repeat reads; two identical rows reproduce
+ // the redundant parse found by the Windows 569-task CPU profile.
+ it('reuses an unchanged preview and recomputes changes and role-specific output', () => {
+ const marker = '\uE200cite\uE202turn99search0\uE201';
+ const text = `**Cache regression** ${marker}`;
+ const row = { createdAt: 1, updatedAt: 1, totalCostUsd: 0,
+ listPreview: text, listPreviewRole: 'assistant' } as SessionRowWithCount;
+ const before = vi.mocked(markdownPreviewText).mock.calls.length;
+ expect(sessionToCamel(row).preview).toBe('Cache regression');
+ expect(sessionToCamel(row).preview).toBe('Cache regression');
+ expect(vi.mocked(markdownPreviewText).mock.calls.length - before).toBe(1);
+ expect(sessionToCamel({ ...row, listPreview: '**Changed preview**' }).preview).toBe('Changed preview');
+ expect(sessionToCamel({ ...row, listPreviewRole: 'user' }).preview).toBe(`Cache regression ${marker}`);
+ expect(sessionToCamel(row).preview).toBe('Cache regression');
+ });
+
const markdown =
'[PR #3943](https://github.com/makecindy/cindy/pull/3943) 已合并,CI 无失败、review 已通过。';
const plain = 'PR #3943 已合并,CI 无失败、review 已通过。';
diff --git a/apps/desktop/src/main/localDb/mapper.ts b/apps/desktop/src/main/localDb/mapper.ts
index 0161c111b6..d75c652a8a 100644
--- a/apps/desktop/src/main/localDb/mapper.ts
+++ b/apps/desktop/src/main/localDb/mapper.ts
@@ -140,6 +140,10 @@ export type SessionRowWithCount = SessionRow & {
const PREVIEW_MAX_CHARS = 140;
/** Bound serialized content before JSON.parse so oversized rows stay valid JSON. */
const PREVIEW_CONTENT_BOUND_CHARS = 4096;
+// Cache only this pure projection, never a session row. Exact text/role keys
+// keep edits visible; both entry count and input size bound retained memory.
+const PREVIEW_CACHE_ENTRIES = 1024;
+const plainPreviewCache = new Map<string, string | null>();
/**
* 从消息 content(DB 存的 JSON string)提炼 sidebar 卡片预览纯文本。
@@ -153,6 +157,26 @@ export function finalizePlainPreview(
role: string | null | undefined,
): string | null {
if (!text) return null;
+ const key = text.length <= PREVIEW_CONTENT_BOUND_CHARS
+ ? `${role === 'assistant' ? 'assistant' : 'plain'}:${text}`
+ : null;
+ if (key !== null && plainPreviewCache.has(key)) {
+ const cached = plainPreviewCache.get(key)!;
+ plainPreviewCache.delete(key);
+ plainPreviewCache.set(key, cached);
+ return cached;
+ }
+ const preview = computePlainPreview(text, role);
+ if (key !== null) {
+ plainPreviewCache.set(key, preview);
+ if (plainPreviewCache.size > PREVIEW_CACHE_ENTRIES) {
+ plainPreviewCache.delete(plainPreviewCache.keys().next().value!);
+ }
+ }
+ return preview;
+}
+
+function computePlainPreview(text: string, role: string | null | undefined): string | null {
let next = text;
// 合成 UI 指令行(隐藏续跑 / 图片按钮)不进 sidebar 预览(review P2):它是
// role='user' 的正常落库行,但对用户不可见 —— 预览显示隐藏英文指令会暴露
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index b08e97688e..f076f14c09 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -606,7 +606,7 @@ import {
activeCindyBuiltInAgentSkills,
builtInSkillDescriptors,
} from '../maker-host/built-in-skills.js';
-import { isCindySkillEnabled } from '../skillhub/activationPreferences.js';
+import { isCindySkillEnabled, readDisabledSkillPaths, skillActivationKey } from '../skillhub/activationPreferences.js';
import {
parseDirectLearnInvocation,
canGrantUnqualifiedClaudeLearnInvocation,
@@ -8161,13 +8161,17 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
await desktopClaudeAuthAdapter.ensureSharedGlobalSkills();
}
const result = await maker.listAgentSkills(kind, skillParams);
+ // Verify integrity once per request, then reuse that synchronous snapshot
+ // when resolving activation aliases instead of rehashing every Skill.
+ const descriptors = builtInSkillDescriptors(app.getPath('userData'), app.getPath('appData'));
+ const disabled = new Set(readDisabledSkillPaths(descriptors));
return {
success: true,
...result,
skills: activeCindyBuiltInAgentSkills(
result.skills,
- builtInSkillDescriptors(app.getPath('userData'), app.getPath('appData')),
- isCindySkillEnabled,
+ descriptors,
+ (source) => !disabled.has(skillActivationKey(source)),
),
};
} catch (err) {
diff --git a/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.ts b/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.ts
index b1a73e53b2..5b98418e93 100644
--- a/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.ts
+++ b/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.ts
@@ -22,6 +22,27 @@ beforeAll(async () => {
afterAll(() => fs.rmSync(root, { recursive: true, force: true }));
describe('Skill activation preferences', () => {
+ // Unit regression: a listing already verifies its descriptor snapshot. Reading
+ // activation intent must preserve live toggles/aliases without hashing that same
+ // bundle again for each item. Existing tests only cover standalone readers.
+ it('uses a verified listing snapshot while still reading current activation preferences', async () => {
+ const prefs = await import('../activationPreferences');
+ const descriptors = (await import('../../maker-host/built-in-skills')).builtInSkillDescriptors(root, root);
+ const learn = descriptors.find((descriptor) => descriptor.name === 'learn')!;
+ await prefs.setCindySkillEnabled(learn.absolutePath, false);
+ const read = vi.spyOn(fs, 'readFileSync');
+ try {
+ expect(prefs.readDisabledSkillPaths(descriptors)).toContain(prefs.skillActivationKey(learn.absolutePath));
+ expect(read.mock.calls.filter(([file]) => typeof file === 'string' && path.basename(file) === 'SKILL.md'))
+ .toHaveLength(0);
+ await prefs.setCindySkillEnabled(learn.absolutePath, true);
+ expect(prefs.readDisabledSkillPaths(descriptors)).not.toContain(prefs.skillActivationKey(learn.absolutePath));
+ } finally {
+ read.mockRestore();
+ await prefs.setCindySkillEnabled(learn.absolutePath, true);
+ }
+ });
+
it('clears only captured disabled intent, preserving later toggles and unrelated paths', async () => {
const prefs = await import('../activationPreferences');
const source = path.join(root, 'intent-source');
diff --git a/apps/desktop/src/main/skillhub/activationPreferences.ts b/apps/desktop/src/main/skillhub/activationPreferences.ts
index e70ae30c77..7bfb5d370f 100644
--- a/apps/desktop/src/main/skillhub/activationPreferences.ts
+++ b/apps/desktop/src/main/skillhub/activationPreferences.ts
@@ -9,6 +9,7 @@ import {
BUILT_IN_LEARN_SKILL_NAME,
builtInSkillDescriptors,
canonicalBuiltInSkillActivationPath,
+ type BuiltInSkillDescriptor,
} from '../maker-host/built-in-skills';
/** Device/profile-local user intent; independent of cloud installs and account changes. */
@@ -52,7 +53,8 @@ const store = createOverrideSettingsFile<SkillActivationPreferences>({
preserveUnreadableFile: true,
});
-export function readDisabledSkillPaths(): readonly string[] {
+/** An already verified snapshot may be reused within the same synchronous read. */
+export function readDisabledSkillPaths(descriptors?: readonly BuiltInSkillDescriptor[]): readonly string[] {
store.invalidateIfChanged();
const value = store.read();
const paths = value.disabledPaths.flatMap((source) => [source,
@@ -64,7 +66,7 @@ export function readDisabledSkillPaths(): readonly string[] {
// Cindy's bundled copy normally wins through ~/.agents/skills. Claude uses an
// isolated config directory in Desktop dev, so mirror the same user preference
// to that runtime projection. Codex's own /skill-creator remains independent.
- for (const descriptor of builtInSkillDescriptors(
+ for (const descriptor of descriptors ?? builtInSkillDescriptors(
app.getPath('userData'),
app.getPath('appData'),
)) {
diff --git a/apps/desktop/src/renderer/__tests__/slashCommandsDeviceId.test.ts b/apps/desktop/src/renderer/__tests__/slashCommandsDeviceId.test.ts
index ea725abe66..edcfa5793f 100644
--- a/apps/desktop/src/renderer/__tests__/slashCommandsDeviceId.test.ts
+++ b/apps/desktop/src/renderer/__tests__/slashCommandsDeviceId.test.ts
@@ -58,6 +58,67 @@ function stubElectron() {
}
describe('loadAllCommands deviceId', () => {
+ // Unit: task view and composer can ask for the same roster before either
+ // request finishes. Existing routing tests only make sequential calls.
+ // A refresh must still return a fresh roster, and a later read must see edits.
+ it('shares in-flight skill reads while a forced refresh supersedes the older flight', async () => {
+ const s = stubElectron();
+ let finishOld!: (value: Awaited<ReturnType<typeof s.listAgentSkills>>) => void;
+ let finishFresh!: typeof finishOld;
+ s.listAgentSkills.mockImplementationOnce(() => new Promise((resolve) => { finishOld = resolve; }))
+ .mockImplementationOnce(() => new Promise((resolve) => { finishFresh = resolve; }));
+ const first = loadAllCommands('claude-code', '/w', { sessionId: 'shared-read' });
+ const second = loadAllCommands('claude-code', '/w', { sessionId: 'shared-read' });
+ expect(s.listAgentSkills).toHaveBeenCalledTimes(1);
+ const refresh = loadAllCommands('claude-code', '/w', { sessionId: 'shared-read', forceReload: true });
+ expect(s.listAgentSkills).toHaveBeenCalledTimes(2);
+ finishOld({ success: true, skills: [c('old', 'agent-skill')] });
+ expect((await first).some((x) => x.name === 'old')).toBe(true);
+ expect((await second).some((x) => x.name === 'old')).toBe(true);
+ const duringRefresh = loadAllCommands('claude-code', '/w', { sessionId: 'shared-read' });
+ expect(s.listAgentSkills).toHaveBeenCalledTimes(2);
+ finishFresh({ success: true, skills: [c('fresh', 'agent-skill')] });
+ for (const result of await Promise.all([refresh, duringRefresh])) {
+ expect(result.some((x) => x.name === 'fresh')).toBe(true);
+ expect(result.some((x) => x.name === 'old')).toBe(false);
+ }
+ expect((await loadAllCommands('claude-code', '/w', { sessionId: 'shared-read' }))
+ .some((x) => x.name === 'localskill')).toBe(true);
+ expect(s.listAgentSkills).toHaveBeenCalledTimes(3);
+ });
+
+ it('does not share skill reads across a task, folder, agent or device boundary', async () => {
+ const s = stubElectron();
+ const results = await Promise.all([
+ loadAllCommands('claude-code', '/w', { sessionId: 'one' }),
+ loadAllCommands('claude-code', '/w', { sessionId: 'two' }),
+ loadAllCommands('claude-code', '/other', { sessionId: 'one' }),
+ loadAllCommands('codex', '/w', { sessionId: 'one' }),
+ loadAllCommands('claude-code', '/w', { sessionId: 'one' }, 'remote-one'),
+ loadAllCommands('claude-code', '/w', { sessionId: 'one' }, 'remote-two'),
+ ]);
+ expect(s.listAgentSkills).toHaveBeenCalledTimes(4);
+ expect(s.invoke.mock.calls.filter((call) => call[1] === 'maker:list-agent-skills')).toHaveLength(2);
+ expect(results.slice(0, 4).every((commands) => commands.some((x) => x.name === 'localskill'))).toBe(true);
+ expect(results.slice(4).every((commands) => commands.some((x) => x.name === 'host-skill'))).toBe(true);
+ });
+
+ // Unit: a rejected shared IPC must not poison subsequent reads after recovery.
+ it('retries after a shared skill read fails', async () => {
+ const s = stubElectron();
+ s.listAgentSkills.mockRejectedValueOnce(new Error('temporarily disconnected'));
+ const results = await Promise.all([
+ loadAllCommands('claude-code', '/w', { sessionId: 'retry-read' }),
+ loadAllCommands('claude-code', '/w', { sessionId: 'retry-read' }),
+ ]);
+ expect(s.listAgentSkills).toHaveBeenCalledTimes(1);
+ expect(results.every((commands) => commands.some((x) => x.name === 'help'))).toBe(true);
+ expect(results.every((commands) => !commands.some((x) => x.name === 'localskill'))).toBe(true);
+ expect((await loadAllCommands('claude-code', '/w', { sessionId: 'retry-read' }))
+ .some((x) => x.name === 'localskill')).toBe(true);
+ expect(s.listAgentSkills).toHaveBeenCalledTimes(2);
+ });
+
it('本地会话(无 deviceId):三源全本地,不碰隧道', async () => {
const s = stubElectron();
const cmds = await loadAllCommands('claude-code', '/w', { sessionId: 'local-session' });
diff --git a/apps/desktop/src/renderer/components/layout/MainEntryRedirect.tsx b/apps/desktop/src/renderer/components/layout/MainEntryRedirect.tsx
index 82abe8eaf9..e4dbd6bd77 100644
--- a/apps/desktop/src/renderer/components/layout/MainEntryRedirect.tsx
+++ b/apps/desktop/src/renderer/components/layout/MainEntryRedirect.tsx
@@ -2,7 +2,7 @@ import { useContext, useEffect } from 'react';
import { Navigate, useLocation } from 'react-router-dom';
import { useAuth } from '@/contexts/AuthContext';
import { MainViewHistoryContext } from '@/contexts/MainViewHistoryContext';
-import { readMainEntryRoute, rememberMainEntry } from '@/lib/mainEntryPreference';
+import { mainEntryRouteForPath, readMainEntryRoute, rememberMainEntry } from '@/lib/mainEntryPreference';
/** Only the unqualified home route restores; explicit routes always win. */
export function MainEntryRedirect() {
@@ -14,10 +14,14 @@ export function useRememberMainEntry(): void {
const { dataOwnerId } = useAuth();
const location = useLocation();
const history = useContext(MainViewHistoryContext);
+ const entryRoute = mainEntryRouteForPath(location.pathname);
+ const ignoredLocation = history?.current.ignoredLocationKey === location.key;
useEffect(() => {
// The singleton router can retain the previous account's route while the
// new protected tree mounts. It must not seed this account's preference.
- if (history?.current.ignoredLocationKey === location.key) return;
- rememberMainEntry(dataOwnerId, location.pathname);
- }, [dataOwnerId, history, location.key, location.pathname]);
+ if (ignoredLocation || !entryRoute) return;
+ // Only the area is persisted. Changing tasks within it must not synchronously
+ // ask Main for owner authority and rewrite the same preference on every click.
+ rememberMainEntry(dataOwnerId, entryRoute);
+ }, [dataOwnerId, entryRoute, ignoredLocation]);
}
diff --git a/apps/desktop/src/renderer/components/layout/MainLayout.tsx b/apps/desktop/src/renderer/components/layout/MainLayout.tsx
index 80922f3072..b96fa63f1a 100644
--- a/apps/desktop/src/renderer/components/layout/MainLayout.tsx
+++ b/apps/desktop/src/renderer/components/layout/MainLayout.tsx
@@ -1662,6 +1662,21 @@ export function MainLayout() {
{ stopImmediate: true },
);
+ // Session/tool-pane declarations update Shell state during navigation. Keep
+ // unrelated updates from invalidating the entire routed conversation again.
+ const outletContext = useMemo(() => ({
+ sidebarWidth,
+ rightSidebarCollapsed: rsbDetached || isRightSidebarCollapsed,
+ onToggleRightSidebar: handleOpenRightSidebar,
+ rightSidebarSide,
+ setRightSidebarAvailable,
+ setRightSidebarSessionId: declareRightSidebarSessionId,
+ setRightSidebarWorkdir,
+ }), [
+ sidebarWidth, rsbDetached, isRightSidebarCollapsed, handleOpenRightSidebar,
+ rightSidebarSide, declareRightSidebarSessionId, setRightSidebarWorkdir,
+ ]);
+
return (
// Shell wraps its entire subtree (Sidebar + <Outlet /> inside <main>) in
// the feature-sidebar slot provider. Any Feature Layout rendered through
@@ -1834,20 +1849,7 @@ export function MainLayout() {
</div>
)}
<FadeSwitcher key={location.pathname.split('/')[1] || 'root'}>
- <Outlet
- context={{
- sidebarWidth,
- // detached 时主窗口没有内嵌侧栏,始终按折叠态布局;子窗口开闭
- // 不改变主窗口浮动控件的占位语义。
- rightSidebarCollapsed: rsbDetached || isRightSidebarCollapsed,
- onToggleRightSidebar: handleOpenRightSidebar,
- // B2b:面板所在侧,聊天视图据此决定展开入口落左上还是右上。
- rightSidebarSide,
- setRightSidebarAvailable,
- setRightSidebarSessionId: declareRightSidebarSessionId,
- setRightSidebarWorkdir,
- }}
- />
+ <Outlet context={outletContext} />
</FadeSwitcher>
</ContentHeaderSlot>
</main>
diff --git a/apps/desktop/src/renderer/components/layout/__tests__/MainEntryRedirect.test.tsx b/apps/desktop/src/renderer/components/layout/__tests__/MainEntryRedirect.test.tsx
index 8b795fcc8b..5196d4b3b3 100644
--- a/apps/desktop/src/renderer/components/layout/__tests__/MainEntryRedirect.test.tsx
+++ b/apps/desktop/src/renderer/components/layout/__tests__/MainEntryRedirect.test.tsx
@@ -46,6 +46,31 @@ beforeEach(() => {
afterEach(() => { cleanup(); vi.unstubAllGlobals(); });
describe('main entry startup', () => {
+ // Unit regression: changing tasks must retain the Tasks startup choice without
+ // rewriting it (and synchronously asking Main for its owner) on every route.
+ // Existing restoration tests only check the final value, not repeated writes.
+ it('persists area changes without rewriting the same area for each task', async () => {
+ const writes = vi.spyOn(Storage.prototype, 'setItem');
+ try {
+ const app = launch('/cc-agent/one');
+ const key = 'cindy.mainEntry.v1.owner.account-a';
+ const count = () => writes.mock.calls.filter(([name]) => name === key).length;
+ const initial = count();
+ expect(localStorage.getItem(key)).toBe('tasks');
+ await act(() => app.router.navigate('/cc-agent/two'));
+ expect(screen.getByTestId('route').textContent).toBe('/cc-agent/two');
+ expect(count()).toBe(initial);
+ await act(() => app.router.navigate('/bots/one'));
+ expect(localStorage.getItem(key)).toBe('bots');
+ expect(count()).toBe(initial + 1);
+ await act(() => app.router.navigate('/bots/two'));
+ expect(count()).toBe(initial + 1);
+ await act(() => app.router.navigate('/cc-agent/three'));
+ expect(localStorage.getItem(key)).toBe('tasks');
+ expect(count()).toBe(initial + 2);
+ } finally { writes.mockRestore(); }
+ });
+
it('reopens the teammate entry after closing a partner chat, without restoring its id', async () => {
const app = launch();
await act(() => app.router.navigate('/bots/private-bot/session/private-task'));
diff --git a/apps/desktop/src/renderer/lib/mainEntryPreference.ts b/apps/desktop/src/renderer/lib/mainEntryPreference.ts
index 9712331ce6..77daa2bde4 100644
--- a/apps/desktop/src/renderer/lib/mainEntryPreference.ts
+++ b/apps/desktop/src/renderer/lib/mainEntryPreference.ts
@@ -11,11 +11,15 @@ export function readMainEntryRoute(ownerId: string | null): '/bots' | '/cc-agent
return readSidebarOwnerStorage(KEY, ownerId) === 'bots' ? '/bots' : '/cc-agent';
}
-export function rememberMainEntry(ownerId: string | null, pathname: string): void {
- const entry = pathname === '/bots' || pathname.startsWith('/bots/')
- ? 'bots'
+export function mainEntryRouteForPath(pathname: string): '/bots' | '/cc-agent' | null {
+ return pathname === '/bots' || pathname.startsWith('/bots/')
+ ? '/bots'
: pathname === '/cc-agent' || pathname.startsWith('/cc-agent/')
- ? 'tasks'
+ ? '/cc-agent'
: null;
- if (entry) writeSidebarOwnerStorage(KEY, ownerId, entry);
+}
+
+export function rememberMainEntry(ownerId: string | null, pathname: string): void {
+ const route = mainEntryRouteForPath(pathname);
+ if (route) writeSidebarOwnerStorage(KEY, ownerId, route === '/bots' ? 'bots' : 'tasks');
}
diff --git a/apps/desktop/src/renderer/lib/slashCommands.ts b/apps/desktop/src/renderer/lib/slashCommands.ts
index 8679de1996..4d7330e1a2 100644
--- a/apps/desktop/src/renderer/lib/slashCommands.ts
+++ b/apps/desktop/src/renderer/lib/slashCommands.ts
@@ -352,6 +352,33 @@ export function filterSlashCommands(
return filtered.length > limit ? filtered.slice(0, limit) : filtered;
}
+type SkillListResult = { success: boolean; skills?: unknown[] };
+const pendingSkillLists = new WeakMap<object, Map<string, Promise<SkillListResult>>>();
+
+/** Share only outstanding reads; edits and activation changes remain live. */
+function loadPendingSkills(
+ key: string | null,
+ forceReload: boolean,
+ load: () => Promise<SkillListResult>,
+): Promise<SkillListResult> {
+ const owner = window.electronAPI;
+ let pending = pendingSkillLists.get(owner);
+ if (!pending) {
+ pending = new Map();
+ pendingSkillLists.set(owner, pending);
+ }
+ if (key !== null && !forceReload) {
+ const existing = pending.get(key);
+ if (existing) return existing;
+ }
+ const request = load().catch(() => ({ success: false })).finally(() => {
+ // An older request must not evict an in-flight forced refresh.
+ if (key !== null && pending.get(key) === request) pending.delete(key);
+ });
+ if (key !== null) pending.set(key, request);
+ return request;
+}
+
/**
* 拉三路 IPC, 合并成 UnifiedCommand[]。
*
@@ -379,7 +406,6 @@ export async function loadAllCommands(
commands?: unknown[];
runtimeStatus?: PiPackageCommandRuntimeStatus;
};
- type SkillRes = { success: boolean; skills?: unknown[] };
// device-link「以被控端为准」:agent-builtin / agent-skill 是被控端**该会话**的能力,远程时经隧道
// 从被控端读(channel 已 allowlist,workingDir 是被控端路径,扫描在被控端跑正确)。
@@ -415,15 +441,17 @@ export async function loadAllCommands(
...(opts?.forceReload !== undefined ? { forceReload: opts.forceReload } : {}),
...(opts?.sessionId ? { sessionId: opts.sessionId } : {}),
};
- const skillP: Promise<SkillRes> = shouldLoadSkills
- ? (
- deviceId
+ const skillP: Promise<SkillListResult> = shouldLoadSkills
+ ? loadPendingSkills(
+ opts?.sessionId ? JSON.stringify([agentKind, deviceId || null, workingDir || null, opts.sessionId]) : null,
+ opts?.forceReload === true,
+ () => deviceId
? (window.electronAPI.deviceLink.invoke(deviceId, 'maker:list-agent-skills', [
agentKind,
skillParams,
- ]) as Promise<SkillRes>)
- : api.listAgentSkills(agentKind, skillParams)
- ).catch(() => ({ success: false }))
+ ]) as Promise<SkillListResult>)
+ : api.listAgentSkills(agentKind, skillParams),
+ )
: Promise.resolve({ success: true, skills: [] });
const [desktopRes, builtinRes, skillRes] = await Promise.all([desktopP, builtinP, skillP]);