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
86 changes: 12 additions & 74 deletions apps/desktop/renderer-architecture.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"src/renderer/app-shell-e2e-fixture.ts",
"src/renderer/app-shell-effects.ts",
"src/renderer/app-shell-overlays.tsx",
"src/renderer/app-shell-project-actions.ts",
"src/renderer/app-shell.tsx",
"src/renderer/app.tsx",
"src/renderer/astryx-theme-mode.ts",
Expand Down Expand Up @@ -82,7 +81,6 @@
"src/renderer/remote-project-directory-dialog.tsx",
"src/renderer/scroll-motion-policy.ts",
"src/renderer/session-read-state.ts",
"src/renderer/session-workspace-errors.ts",
"src/renderer/settings/about-settings-page.tsx",
"src/renderer/settings/about-update-status.ts",
"src/renderer/settings/action-guard.ts",
Expand Down Expand Up @@ -380,6 +378,7 @@
"src/renderer/features/diagnostics/index.ts": {
"appShell": [
"DiagnosticReportToastProvider",
"ManualDiagnosticReportConsumer",
"PreviousMainProcessInterruptionNotice"
],
"composition": [
Expand Down Expand Up @@ -532,14 +531,7 @@
},
"src/renderer/app-shell-command-actions.ts": {
"importDeclarations": 5,
"bridgePaths": {
"window.maka.connections.setDefault": 1,
"window.maka.connections.test": 1,
"window.maka.diagnostics.copyReport": 1,
"window.maka.memory.openFile": 1,
"window.maka.sessions.saveConversationToFile": 1,
"window.maka.settings.testNetworkProxy": 1
},
"bridgePaths": {},
"environmentCapabilities": {
"navigator.clipboard.writeText": 1
},
Expand All @@ -560,7 +552,7 @@
"react": 1
},
"importSpecifiers": 8,
"nonTriviaTokens": 2188
"nonTriviaTokens": 2172
},
"src/renderer/app-shell-copy.ts": {
"importDeclarations": 1,
Expand All @@ -576,7 +568,7 @@
"@maka/core/redaction": 1
},
"importSpecifiers": 1,
"nonTriviaTokens": 311
"nonTriviaTokens": 249
},
"src/renderer/app-shell-detail-panel.tsx": {
"importDeclarations": 0,
Expand Down Expand Up @@ -634,7 +626,7 @@
"react": 1
},
"importSpecifiers": 7,
"nonTriviaTokens": 886
"nonTriviaTokens": 856
},
"src/renderer/app-shell-overlays.tsx": {
"importDeclarations": 5,
Expand Down Expand Up @@ -666,36 +658,6 @@
"importSpecifiers": 8,
"nonTriviaTokens": 858
},
"src/renderer/app-shell-project-actions.ts": {
"importDeclarations": 4,
"bridgePaths": {
"window.maka.app.openPath": 3,
"window.maka.app.resolveProjectGitInfo": 1,
"window.maka.projects.add": 1,
"window.maka.projects.archive": 1,
"window.maka.projects.getDefaultContext": 1,
"window.maka.projects.relink": 1,
"window.maka.projects.rename": 1,
"window.maka.projects.restore": 1,
"window.maka.projects.select": 3
},
"environmentCapabilities": {},
"hookCalls": {},
"lifecycleMethods": {},
"unresolvedDependencies": 0,
"actionFactories": [
"createAppShellProjectActions"
],
"dependencyPaths": {
"./app-shell-copy": 1,
"./locales/shell-copy.js": 1,
"./open-path": 1,
"./platform/desktop/default-runtime-host-operation.js": 1,
"./session-workspace-errors": 1
},
"importSpecifiers": 7,
"nonTriviaTokens": 2157
},
"src/renderer/app-shell.tsx": {
"importDeclarations": 42,
"bridgePaths": {},
Expand Down Expand Up @@ -799,7 +761,7 @@
"react": 1
},
"importSpecifiers": 60,
"nonTriviaTokens": 8037
"nonTriviaTokens": 8017
},
"src/renderer/use-app-shell-session-list.ts": {
"importDeclarations": 4,
Expand Down Expand Up @@ -1139,10 +1101,7 @@
}
},
"src/renderer/error-boundary.tsx": {
"bridgePaths": {
"window.maka.diagnostics": 3,
"window.maka.diagnostics.copyReport": 1
},
"bridgePaths": {},
"environmentCapabilities": {
"navigator": 1,
"navigator.clipboard.writeText": 1,
Expand All @@ -1163,6 +1122,7 @@
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./features/diagnostics/index.js": 1,
"./locales/shell-copy.js": 1,
"@maka/core/diagnostic-log": 1,
"@maka/ui": 1,
Expand Down Expand Up @@ -1667,22 +1627,9 @@
"actionFactories": [],
"dependencyPaths": {}
},
"src/renderer/session-workspace-errors.ts": {
"bridgePaths": {},
"environmentCapabilities": {},
"hookCalls": {},
"lifecycleMethods": {},
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./application/contracts/session-workspace-errors.js": 1,
"./locales/shell-copy.js": 1
}
},
"src/renderer/settings/about-settings-page.tsx": {
"bridgePaths": {
"window.maka.app.info": 1,
"window.maka.diagnostics.copyReport": 1
"window.maka.app.info": 1
},
"environmentCapabilities": {},
"hookCalls": {
Expand All @@ -1698,6 +1645,7 @@
"actionFactories": [],
"dependencyPaths": {
"../features/app-update/index.js": 1,
"../features/diagnostics/index.js": 1,
"../locales/settings-preferences-copy.js": 1,
"../platform/desktop/default-runtime-host-operation.js": 1,
"./about-update-status.js": 1,
Expand Down Expand Up @@ -3395,17 +3343,14 @@
"environmentCapabilities": {},
"hookCalls": {
"useEffect": 4,
"useRef": 3,
"useStableActions": 1,
"useState": 8
"useRef": 1,
"useState": 7
},
"lifecycleMethods": {},
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"./app-shell-project-actions": 1,
"./platform/desktop/default-runtime-host-operation.js": 1,
"./use-stable-actions.js": 1,
"react": 1
}
},
Expand Down Expand Up @@ -3805,13 +3750,6 @@
"src/renderer/use-app-shell-session-workspace.ts"
]
},
{
"capability": "workspace-projection",
"targetZone": "application/workspace",
"legacyPaths": [
"src/renderer/app-shell-project-actions.ts"
]
},
{
"capability": "commands-and-overlays",
"targetZone": "features/overlays",
Expand Down
92 changes: 85 additions & 7 deletions apps/desktop/src/main/__tests__/about-settings-page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,100 @@
*/

import assert from 'node:assert/strict';
import { test } from 'node:test';
import { createElement } from 'react';
import { afterEach, test } from 'node:test';
import { act, createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { AstryxLocaleProvider, LocaleProvider, ToastProvider } from '@maka/ui';
import {
DiagnosticsServicesProvider,
createFakeDiagnosticsServices,
type DiagnosticsServices,
type ManualDiagnosticTarget,
} from '../../renderer/features/diagnostics/testing.js';
import { getSettingsPreferencesCopy } from '../../renderer/locales/settings-preferences-copy.js';
import { AboutSettingsPage } from '../../renderer/settings/about-settings-page.js';
import { cleanupFakeDom, installReactRenderer } from './fake-dom.js';

test('keeps manual diagnostics available while About metadata is pending', () => {
type TreeNode = { readonly childNodes?: readonly TreeNode[]; readonly tagName?: string; readonly textContent: string };

afterEach(() => {
cleanupFakeDom();
});

function aboutPage(services: DiagnosticsServices) {
const page = createElement(AboutSettingsPage, {});
const withToasts = createElement(ToastProvider, { children: page });
const withAstryxLocale = createElement(AstryxLocaleProvider, { children: withToasts });
const markup = renderToStaticMarkup(
createElement(LocaleProvider, { locale: 'en', children: withAstryxLocale }),
);
const withDiagnostics = createElement(DiagnosticsServicesProvider, { services, children: withToasts });
const withAstryxLocale = createElement(AstryxLocaleProvider, { children: withDiagnostics });
return createElement(LocaleProvider, { locale: 'en', children: withAstryxLocale });
}

async function clickCopyDiagnostics(root: TreeNode, label: string): Promise<void> {
const buttons: TreeNode[] = [];
const visit = (node: TreeNode) => {
if (node.tagName === 'BUTTON') buttons.push(node);
for (const child of node.childNodes ?? []) visit(child);
};
visit(root);
const key = (button: TreeNode) => Object.keys(button).find((candidate) => candidate.startsWith('__reactProps$'));
const props = (button: TreeNode) =>
(button as unknown as Record<string, { 'aria-label'?: string; onClick?(event: unknown): void }>)[key(button) ?? ''];
const button = buttons.find((candidate) => props(candidate)?.['aria-label'] === label);
assert.ok(button, `missing button ${label}`);
await act(async () => props(button)?.onClick?.({ preventDefault() {}, stopPropagation() {} }));
await act(async () => {});
}

function mountWithPendingInfo() {
const mounted = installReactRenderer();
// About's metadata never arrives here: the copy row must not depend on it.
(globalThis.window as unknown as { maka: unknown }).maka = {
runtimeHostProfiles: { getDefaultHost: () => new Promise(() => {}) },
};
return mounted;
}

test('keeps manual diagnostics available while About metadata is pending', () => {
const markup = renderToStaticMarkup(aboutPage(createFakeDiagnosticsServices()));

// The row LABEL also reads "Copy diagnostics", so match the control itself:
// its accessible name is the aria-label, not the verb on its face.
assert.match(markup, /<button[^>]*aria-label="Copy diagnostics"/);
assert.match(markup, /role="status"[^>]*aria-busy="true"/);
});

test('copies the manual report through the diagnostics feature, without a target', async () => {
const { root, container } = mountWithPendingInfo();
const calls: Array<ManualDiagnosticTarget | undefined>[] = [];
const services = createFakeDiagnosticsServices({
copyManualReport: async (...args) => {
calls.push(args);
},
});
const copy = getSettingsPreferencesCopy('en').about;
await act(async () => root.render(aboutPage(services)));

await clickCopyDiagnostics(container, copy.copyDiagnostics);

assert.deepEqual(calls, [[]]);
assert.ok(container.textContent.includes(copy.copied));
});

test('reports a failed manual copy with About\'s own words', async () => {
const { root, container } = mountWithPendingInfo();
let attempts = 0;
const services = createFakeDiagnosticsServices({
copyManualReport: async () => {
attempts += 1;
throw new Error('denied');
},
});
const copy = getSettingsPreferencesCopy('en').about;
await act(async () => root.render(aboutPage(services)));

await clickCopyDiagnostics(container, copy.copyDiagnostics);

assert.equal(attempts, 1);
assert.ok(container.textContent.includes(copy.copyFailed));
assert.ok(container.textContent.includes(copy.clipboardUnavailable));
});
Loading