Skip to content
Merged
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
38 changes: 10 additions & 28 deletions apps/desktop/renderer-architecture.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"src/renderer/app-shell-chrome-actions.tsx",
"src/renderer/app-shell-command-actions.ts",
"src/renderer/app-shell-copy.ts",
"src/renderer/app-shell-detail-panel.tsx",
"src/renderer/app-shell-e2e-fixture.ts",
"src/renderer/app-shell-effects.ts",
"src/renderer/app-shell-overlays.tsx",
Expand Down Expand Up @@ -571,18 +570,6 @@
"importSpecifiers": 1,
"nonTriviaTokens": 249
},
"src/renderer/app-shell-detail-panel.tsx": {
"importDeclarations": 0,
"bridgePaths": {},
"environmentCapabilities": {},
"hookCalls": {},
"lifecycleMethods": {},
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {},
"importSpecifiers": 0,
"nonTriviaTokens": 87
},
"src/renderer/app-shell-e2e-fixture.ts": {
"importDeclarations": 1,
"bridgePaths": {
Expand Down Expand Up @@ -660,7 +647,7 @@
"nonTriviaTokens": 858
},
"src/renderer/app-shell.tsx": {
"importDeclarations": 42,
"importDeclarations": 40,
"bridgePaths": {},
"environmentCapabilities": {
"window.requestAnimationFrame": 3
Expand All @@ -675,7 +662,6 @@
"useAppShellSessionUiReads": 1,
"useAppShellSessionWorkspace": 1,
"useAppShellTurnPresentation": 1,
"useEffect": 1,
"useLayoutEffect": 1,
"useRef": 4,
"useSessionNavigationReads": 1,
Expand All @@ -698,7 +684,6 @@
"dependencyPaths": {
"./agent-graph-panel": 1,
"./app-shell-chrome-actions": 1,
"./app-shell-detail-panel": 1,
"./app-shell-e2e-fixture": 1,
"./app-shell-effects": 1,
"./app-shell-overlays": 1,
Expand Down Expand Up @@ -738,8 +723,8 @@
"./platform/desktop/default-runtime-host-operation.js": 1,
"./scroll-motion-policy": 1,
"./settings/provider-brand-marks": 1,
"./settings/provider-display": 1,
"./settings/runtime-host-ssh-terminal-dialog.js": 1,
"./shell/detail-panel": 1,
"./shell/frame-style": 1,
"./use-app-shell-session-ui-reads": 1,
"./use-app-shell-session-workspace": 1,
Expand All @@ -761,8 +746,8 @@
"@maka/ui": 1,
"react": 1
},
"importSpecifiers": 60,
"nonTriviaTokens": 8009
"importSpecifiers": 57,
"nonTriviaTokens": 7852
},
"src/renderer/use-app-shell-session-list.ts": {
"importDeclarations": 4,
Expand Down Expand Up @@ -3336,16 +3321,14 @@
"bridgePaths": {
"window.maka.app.sessionProjectInfo": 1,
"window.maka.projects.getDefaultContext": 1,
"window.maka.projects.getLocalSnapshot": 1,
"window.maka.projects.getSnapshot": 1,
"window.maka.projects.subscribeChanges": 2,
"window.maka.projects.subscribeLocalChanges": 1
"window.maka.projects.subscribeChanges": 2
},
"environmentCapabilities": {},
"hookCalls": {
"useEffect": 4,
"useEffect": 3,
"useRef": 1,
"useState": 7
"useState": 6
},
"lifecycleMethods": {},
"unresolvedDependencies": 0,
Expand Down Expand Up @@ -3725,8 +3708,7 @@
"capability": "shell-root-and-frame",
"targetZone": "shell",
"legacyPaths": [
"src/renderer/app-shell-chrome-actions.tsx",
"src/renderer/app-shell-detail-panel.tsx"
"src/renderer/app-shell-chrome-actions.tsx"
]
},
{
Expand Down Expand Up @@ -3756,14 +3738,14 @@
"targetZone": "features/overlays",
"legacyPaths": [
"src/renderer/app-shell-command-actions.ts",
"src/renderer/app-shell-copy.ts",
"src/renderer/app-shell-overlays.tsx"
]
},
{
"capability": "mixed-bootstrap-and-conversation-effects",
"capability": "root-lifecycle-effects",
"targetZone": "split-by-capability",
"legacyPaths": [
"src/renderer/app-shell-copy.ts",
"src/renderer/app-shell-effects.ts"
]
},
Expand Down
41 changes: 41 additions & 0 deletions apps/desktop/src/main/__tests__/app-shell-retired-props.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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 { ComponentProps } from 'react';
import type { ChatView } from '@maka/ui';
import type {
SessionNavigationPorts,
SessionNavigationProvider,
} from '../../renderer/features/session-navigation/index.js';

// The root stopped threading these: ChatView never read them, the rail derives
// its WorkHub entry from `workHubActive`, and no rail action activates a Session.
type Declares<T, K extends PropertyKey> = Extract<keyof T, K> extends never ? false : true;
const retired = {
chatViewModelProps: false as Declares<ComponentProps<typeof ChatView>,
'activeConnectionLabel' | 'activeModel' | 'activeModelLabel' | 'activeProviderType'
| 'renderProviderMark' | 'modelChoices' | 'onModelChange'>,
railWorkHubEntry: false as Declares<ComponentProps<typeof SessionNavigationProvider>, 'workHubEntry'>,
portActivateSession: false as Declares<SessionNavigationPorts, 'activateSession'>,
} satisfies Record<string, false>;

test('the root no longer threads props their readers never use', () => {
assert.deepEqual(Object.values(retired), [false, false, false]);
});
30 changes: 30 additions & 0 deletions apps/desktop/src/main/__tests__/onboarding-authority.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import {
createOnboardingSnapshotPoller,
getOnboardingActivationCandidate,
OnboardingAuthorityProvider,
OnboardingConnectionSeed,
type OnboardingAuthority,
type OnboardingProjection,
OnboardingProjectionRoot,
onboardingSnapshotProjectionEqual,
type OnboardingShellProjection,
Expand Down Expand Up @@ -126,6 +129,33 @@ describe('createOnboardingAuthority', () => {
assert.equal(fake.calls.at(-1), 'unsubscribe', 'the root is the subscriber that keeps the reads alive');
});

it('seeds the default Host connections from each new snapshot, and refreshes them when reads fail', async () => {
let projection: OnboardingProjection = { snapshot: null, failed: false };
const listeners = new Set<() => void>();
const authority: OnboardingAuthority = {
getProjection: () => projection,
subscribe(listener) { listeners.add(listener); return () => listeners.delete(listener); },
refresh: () => {},
skipInitialOnboarding: async () => {},
};
const publish = (next: OnboardingProjection) => act(() => { projection = next; listeners.forEach((listener) => listener()); });
const calls: unknown[] = [];
const { root } = installReactRenderer();
await act(async () => root.render(createElement(OnboardingAuthorityProvider, { value: authority,
children: createElement(OnboardingConnectionSeed, {
seed: (snapshot) => calls.push(snapshot),
refresh: () => calls.push('refresh'),
}) })));
assert.deepEqual(calls, [], 'nothing to seed before the first read');
const withConnections = { ...READY_SNAPSHOT, defaultSlug: 'openai' };
publish({ snapshot: withConnections, failed: false });
publish({ snapshot: withConnections, failed: false });
assert.deepEqual(calls.splice(0), [{ connections: [], defaultConnection: 'openai', chatModelChoices: [] }]);
publish({ snapshot: null, failed: true });
assert.deepEqual(calls.splice(0), ['refresh']);
await act(async () => root.unmount());
});

it('fails without its provider instead of holding the first-run gate closed', () => {
const { root } = installReactRenderer();
assert.throws(() => act(() => root.render(createElement(OnboardingProjectionRoot, { children: () => null }))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ function ports(
return {
sessionsRef: { current: sessions },
acquireAutomaticQueryBlock: () => ({ release: () => undefined }),
activateSession: (sessionId) => calls.push(`activate:${sessionId ?? 'none'}`),
clearSessionRendererState: (sessionId) => calls.push(`clear:${sessionId}`),
refreshSessions: async () => sessions,
toastApi: {
Expand Down Expand Up @@ -205,7 +204,7 @@ function navigationTree(
shell: {
activeSessionId: string;
workHubActive: boolean;
workHubEntry?: { active: boolean; label: string; onSelect(): void };
onOpenWorkHub?(): void;
},
sibling: ReactNode,
child: ReactNode,
Expand Down Expand Up @@ -674,7 +673,7 @@ describe('SessionNavigationProvider selection', () => {
await act(async () => root.render(navigationTree(catalog, {
activeSessionId: 'root',
workHubActive: false,
workHubEntry: { active: false, label: 'WorkHub', onSelect: () => opened.push('workhub') },
onOpenWorkHub: () => opened.push('workhub'),
}, null, createElement(ChromeProbe), undefined, { workHub: enablement })));
const workHubEntry = () => chrome?.workHubEntry;
assert.equal(workHubEntry(), undefined);
Expand Down
17 changes: 6 additions & 11 deletions apps/desktop/src/main/__tests__/use-project-context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,17 @@ test('discards a pending Project projection after the default Host changes', asy
return pendingContext.promise;
},
subscribeChanges: () => () => {},
getLocalSnapshot: async () => ({
projects: [],
capabilities: NO_PROJECT_CAPABILITIES,
}),
subscribeLocalChanges: () => () => {},
},
};
let projects: ProjectRecord[] = [];
let selectedProjectId: string | null | undefined;
let projectInfo: unknown;
let currentProjectId: string | null | undefined;

function Probe() {
const context = projectContext.useAppShellProjectContext({
rendererMountedRef: { current: true },
});
projects = context.projects;
selectedProjectId = context.selectedProjectId;
projectInfo = context.projectInfo;
currentProjectId = context.currentProjectId;
return null;
}

Expand All @@ -110,8 +105,8 @@ test('discards a pending Project projection after the default Host changes', asy
await commitGuardChecked.promise;
});

assert.deepEqual(projects, []);
assert.equal(selectedProjectId, undefined);
assert.equal(projectInfo, null);
assert.equal(currentProjectId, undefined);
});

afterEach(() => {
Expand Down
Loading