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
270 changes: 29 additions & 241 deletions apps/desktop/renderer-architecture.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { MAX_ATTACHMENT_COUNT } from '@maka/core/attachments';
import { strict as assert } from 'node:assert';
import { test } from 'node:test';
import type { PendingAttachment } from '@maka/ui/composer-attachments';
import { createAppShellChatActions } from '../../renderer/app-shell-chat-actions.js';
import { createChatActions } from '../../renderer/features/conversation/testing.js';
import { getShellCopy } from '../../renderer/locales/shell-copy.js';
import {
createActionsDeps,
Expand Down Expand Up @@ -54,7 +54,7 @@ test('a nine-attachment new-task send shows the count reason, creates no session
try {
for (const locale of ['zh-CN', 'en'] as const) {
toasts.length = 0;
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
uiLocale: locale,
toastApi: {
Expand Down Expand Up @@ -104,7 +104,7 @@ test('a main-side attachment rejection refuses the send instead of leaving it un
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
uiLocale: 'zh-CN',
toastApi: {
Expand Down Expand Up @@ -132,7 +132,7 @@ test('unsupported executor attachments preserve the pending draft before any Ses
const pending = [fileAttachment(10, 0)];
const errors: string[] = [];
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
executorSelection: { executorId: 'external', configuration: { model: 'chosen' } },
executorEntry: { readiness: 'ready', supportsAttachments: false },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';

import type { TransientUserMessageProjection } from '@maka/ui';
import { createAppShellChatActions } from '../../renderer/app-shell-chat-actions.js';
import { createChatActions } from '../../renderer/features/conversation/testing.js';
import { mergeTransientMessageProjection } from '../../renderer/application/contracts/transient-message-projection.js';
import { getShellCopy } from '../../renderer/locales/shell-copy.js';

Expand All @@ -49,7 +49,7 @@ describe('busy-raced send settlement', () => {
},
} });
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(), activeIdRef: { current: 'session-a' },
getRunningTurnId: () => { throw new Error('Message intent must not depend on observation'); },
});
Expand All @@ -71,7 +71,7 @@ describe('busy-raced send settlement', () => {
},
} });
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(), activeIdRef: { current: 'session-a' },
addTransientMessage: (_sessionId, message) => transient.set(message.id, message),
});
Expand All @@ -89,7 +89,7 @@ describe('busy-raced send settlement', () => {
},
} });
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(), activeIdRef: { current: 'session-a' },
getRunningTurnId: () => 'running-turn',
addTransientMessage: (_sessionId, message) => transient.set(message.id, message),
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('busy-raced send settlement', () => {
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
activeIdRef,
addTransientMessage: (_sessionId, message) => transient.set(message.id, message),
Expand Down Expand Up @@ -165,7 +165,7 @@ describe('busy-raced send settlement', () => {
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
activeIdRef: { current: 'session-a' },
addTransientMessage: (_sessionId, message) => transient.set(message.id, message),
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('busy-raced send settlement', () => {
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
activeIdRef: { current: 'session-a' },
addTransientMessage: (_sessionId, message) => transient.set(message.id, message),
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('busy-raced send settlement', () => {
}),
} });
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
activeIdRef: { current: 'session-a' },
toastApi: {
Expand Down Expand Up @@ -262,7 +262,7 @@ describe('busy-raced send settlement', () => {
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
activeIdRef: { current: 'session-a' },
});
Expand All @@ -285,7 +285,7 @@ describe('busy-raced send settlement', () => {
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
activeIdRef: { current: 'session-a' },
});
Expand Down Expand Up @@ -331,7 +331,7 @@ describe('busy-raced send settlement', () => {
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
activeIdRef: { current: 'session-a' },
addTransientMessage: (_sessionId, message) => transient.set(message.id, message),
Expand Down Expand Up @@ -389,7 +389,7 @@ describe('busy-raced send settlement', () => {
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
activeIdRef,
addTransientMessage: (_sessionId, message) => transient.set(message.id, message),
Expand Down Expand Up @@ -435,7 +435,7 @@ describe('busy-raced send settlement', () => {
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
activeIdRef,
...transientState.deps,
Expand Down Expand Up @@ -470,7 +470,7 @@ describe('busy-raced send settlement', () => {
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(), activeIdRef,
activateSessionForFirstSend: async (session) => { activeIdRef.current = session.id; },
addTransientMessage: (_sessionId, message) => {
Expand Down Expand Up @@ -511,7 +511,7 @@ describe('busy-raced send settlement', () => {
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
activeIdRef,
activateSessionForFirstSend: async (session) => {
Expand Down Expand Up @@ -552,7 +552,7 @@ describe('busy-raced send settlement', () => {
},
});
try {
const actions = createAppShellChatActions({
const actions = createChatActions({
...createActionsDeps(),
activeIdRef,
activateSessionForFirstSend: async (session) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
*/

/**
* Shared scaffolding for the `createAppShellChatActions` suites. The dependency
* Shared scaffolding for the Composer submission action suites. The dependency
* surface is wide and the suites only ever vary a handful of entries, so a
* second copy of it drifts silently and has to be edited twice whenever the
* actions gain a dependency.
*/

import type { TransientUserMessageProjection } from '@maka/ui';
import {
createDesktopComposerSubmissionServices,
type DesktopComposerSubmissionBridge,
} from '../../renderer/platform/desktop/create-composer-submission-services.js';

/** Installs a `window.maka` bridge double; the returned function restores it. */
export function installWindow(maka: unknown): () => void {
Expand All @@ -49,6 +53,19 @@ export function installWindow(maka: unknown): () => void {
};
}

/**
* The production Desktop adapter over whichever `window.maka` double is
* installed when a call runs, so the suites keep stubbing the bridge they
* always stubbed and the adapter's mapping is exercised along the way.
*/
export function windowSubmissionServices() {
const installed = () => (globalThis as unknown as { window: { maka: DesktopComposerSubmissionBridge } }).window.maka;
return createDesktopComposerSubmissionServices({
get sessions() { return installed().sessions; },
get newTasks() { return installed().newTasks; },
});
}

/**
* The transient arm as a real map. Transient rows are not `StoredMessage`s —
* they have no Turn to belong to yet — so they are held apart from the
Expand All @@ -75,6 +92,7 @@ export function createTransientState() {
export function createActionsDeps() {
const activeIdRef = { current: undefined as string | undefined };
return {
services: windowSubmissionServices(),
onFollowLatest: (_sessionId: string) => true,
uiLocale: 'en' as const,
activeIdRef,
Expand Down
Loading