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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
91 changes: 63 additions & 28 deletions apps/desktop/e2e/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import { tmpdir } from 'node:os';
import path from 'node:path';
import { promisify } from 'node:util';
import {
createConnectionStore,
createFileCredentialStore,
createProjectCatalog,
createSettingsStore,
} from '@maka/storage';
import { resolveStorageRoot } from '@maka/storage/root-authority';
import {
resolveStorageRoot,
tryAcquireInteractiveRootOwner,
} from '@maka/storage/root-authority';
import { openInteractiveRuntimePolicyStoresForWrite } from '@maka/storage/runtime-policy-stores';
import { buildFixtureEnv, isCiLinuxDisplay } from '../../../scripts/fixture-env.mjs';
import { closeElectronApplication } from '../../../scripts/electron-lifecycle.mjs';

Expand Down Expand Up @@ -55,31 +57,66 @@ export async function waitForInvocableSkills(
* backend (BackendRegistry override in main); this only satisfies the UI
* readiness gates. Kept in the fixture so test data stays out of production main.
*/
async function seedE2eConnection(
userDataDir: string,
extraConnectionCount = 0,
): Promise<void> {
async function seedE2eConnection(userDataDir: string): Promise<void> {
const workspaceRoot = path.join(userDataDir, 'workspaces', 'default');
const connections = createConnectionStore(workspaceRoot);
const credentials = createFileCredentialStore(workspaceRoot);
await connections.create({
slug: 'e2e',
name: 'E2E',
providerType: 'anthropic',
defaultModel: 'claude-sonnet-4-5-20250929',
});
await credentials.setSecret('e2e', 'api_key', 'e2e-placeholder');
for (let index = 0; index < extraConnectionCount; index += 1) {
const slug = `e2e-extra-${index + 1}`;
await connections.create({
slug,
name: `E2E Extra ${index + 1}`,
providerType: 'anthropic',
defaultModel: `claude-e2e-${index + 1}`,
const capability = await resolveStorageRoot({ path: workspaceRoot, kind: 'interactive' });
const owner = await tryAcquireInteractiveRootOwner(capability);
if (!owner) throw new Error('E2E fixture could not acquire its isolated Runtime Host root');
try {
const stores = await openInteractiveRuntimePolicyStoresForWrite(owner.lease);
const catalog = await stores.connectionCatalog.getSnapshot();
const created = await stores.connectionCatalog.create({
expectedCatalogRevision: catalog.revision,
connection: {
slug: 'e2e',
name: 'E2E',
providerType: 'anthropic',
enabled: true,
enabledModelIds: ['claude-sonnet-4-5-20250929'],
},
});
if (created.kind !== 'committed') {
throw new Error(`E2E connection seed was not committed: ${created.kind}`);
}
const connection = created.snapshot.connections.find(({ slug }) => slug === 'e2e');
if (!connection) throw new Error('E2E connection seed is missing from the committed catalog');
const credential = await stores.credentialVault.set({
locator: {
scope: 'connection',
connectionId: connection.connectionId,
kind: 'api_key',
},
expected: null,
secret: 'e2e-placeholder',
});
await credentials.setSecret(slug, 'api_key', 'e2e-placeholder');
if (credential.kind !== 'committed') {
throw new Error(`E2E credential seed was not committed: ${credential.kind}`);
}
const modelFetch = await stores.operations.beginModelFetch(connection.connectionId);
if (modelFetch.kind !== 'ready') {
throw new Error(`E2E model inventory seed could not start: ${modelFetch.kind}`);
}
const modelInventory = await stores.operations.completeModelFetch(modelFetch.ticket, {
models: [{ id: 'claude-sonnet-4-5-20250929' }],
source: 'fallback',
fetchedAt: 0,
});
if (modelInventory.kind !== 'committed') {
throw new Error(`E2E model inventory seed was not committed: ${modelInventory.kind}`);
}
const defaultTarget = await stores.connectionCatalog.setDefaultTarget({
expectedCatalogRevision: modelInventory.snapshot.revision,
target: {
connectionId: connection.connectionId,
modelId: 'claude-sonnet-4-5-20250929',
},
});
if (defaultTarget.kind !== 'committed') {
throw new Error(`E2E default target seed was not committed: ${defaultTarget.kind}`);
}
} finally {
await owner.close();
}
await connections.setDefault('e2e');
}

async function seedE2eLocale(userDataDir: string, locale: 'zh' | 'en'): Promise<void> {
Expand Down Expand Up @@ -211,7 +248,6 @@ async function withE2eWindow(
showWindow,
invocableSkills,
gitReviewExtraFiles,
extraConnectionCount,
}: {
seed: boolean;
readinessSelector: string;
Expand All @@ -223,7 +259,6 @@ async function withE2eWindow(
showWindow?: boolean;
invocableSkills?: boolean;
gitReviewExtraFiles?: number;
extraConnectionCount?: number;
},
use: (page: Page, context: { userDataDir: string }) => Promise<void>,
): Promise<void> {
Expand All @@ -236,7 +271,7 @@ async function withE2eWindow(
const mainLogs: string[] = [];
const rendererLogs: string[] = [];
try {
if (seed) await seedE2eConnection(userDataDir, extraConnectionCount);
if (seed) await seedE2eConnection(userDataDir);
if (invocableSkills) await seedE2eInvocableSkills(userDataDir);
if (gitReviewExtraFiles !== undefined) {
await seedE2eGitReviewProject(userDataDir, gitReviewExtraFiles);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { createReadOnlyPermissionProfile, createWorkspaceWritePermissionProfile } from '@maka/core';
import type { ExecutionBoundary, SessionEvent } from '@maka/core';
import { createReadOnlyPermissionProfile, createWorkspaceWritePermissionProfile } from '@maka/core/permission-profile';
import type { ExecutionBoundary } from '@maka/core/sandbox-boundary';

import type { SessionEvent } from '@maka/core/events';

import { createAppShellSessionEventHandlers } from '../../renderer/app-shell-session-events.js';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';

import type { SessionSummary } from '@maka/core';
import type { SessionSummary } from '@maka/core/session';
import type { LiveTurnProjection } from '@maka/ui';
import { createAppShellChatActions } from '../../renderer/app-shell-chat-actions.js';
import { createAppShellSessionUiStateController } from '../../renderer/app-shell-session-ui-state.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mkdir, mkdtemp } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { test } from 'node:test';
import type { ProjectRecord } from '@maka/core';
import type { ProjectRecord } from '@maka/core/project';
import { build } from 'esbuild';
import type * as ProjectActions from '../../renderer/app-shell-project-actions.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';
import type { SessionSummary } from '@maka/core';
import type { SessionSummary } from '@maka/core/session';
import { createAppShellSessionRowActions } from '../../renderer/app-shell-session-row-actions.js';

function summary(id: string, overrides: Partial<SessionSummary> = {}): SessionSummary {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';
import type { LlmConnection, SessionSummary } from '@maka/core';
import type { LlmConnection } from '@maka/core/llm-connections';
import type { SessionSummary } from '@maka/core/session';
import { createAppShellSessionSettingsActions } from '../../renderer/app-shell-session-settings-actions.js';

function deferred<T>() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import type { SandboxBoundaryRequestEvent, SessionEventStreamSnapshot, SessionSummary } from '@maka/core';
import type { SandboxBoundaryRequestEvent } from '@maka/core/events';
import type { SessionEventStreamSnapshot } from '@maka/core/session-event-health';
import type { SessionSummary } from '@maka/core/session';
import { armLiveTurn, confirmLiveTurn } from '@maka/ui';
import { settledSessionTransientIds } from '../../renderer/settled-session-transients.js';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
import type { SessionSummary } from '@maka/core';
import type { SessionSummary } from '@maka/core/session';
import { createAppShellTurnActions } from '../../renderer/app-shell-turn-actions.js';

test('preserves a Branch copy identity after an ambiguous failure and completes it on success', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';
import type { ArtifactBinaryReadResult } from '@maka/core';
import type { ArtifactBinaryReadResult } from '@maka/core/artifacts';
import {
ALLOWED_IMAGE_MIMES,
IMAGE_PAYLOAD_MAX_BASE64_LENGTH,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import type { ArtifactRecord, ArtifactSource } from '@maka/core';
import type { ArtifactRecord, ArtifactSource } from '@maka/core/artifacts';
import { filterUserVisibleArtifacts } from '../../renderer/artifact-visibility.js';

function artifact(source: ArtifactSource): ArtifactRecord {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';
import type { BotIncomingMessage, BotRegistry } from '@maka/runtime';
import type { BotIncomingMessage, BotRegistry } from '@maka/runtime/bots';
import { createBotIncomingMainService } from '../bot-incoming-main.js';

describe('bot incoming new-session cwd', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import { describe, test } from 'node:test';
import type { BotIncomingMessage, BotRegistry } from '@maka/runtime';
import type { BotIncomingMessage, BotRegistry } from '@maka/runtime/bots';
import { createBotIncomingMainService } from '../bot-incoming-main.js';
import { BotSessionUnavailableError } from '../bot-session-adapter.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { getEventListeners } from 'node:events';
import { test } from 'node:test';
import type { BotIncomingMessage, BotRegistry } from '@maka/runtime';
import type { BotIncomingMessage, BotRegistry } from '@maka/runtime/bots';
import { createBotIncomingMainService } from '../bot-incoming-main.js';

async function waitFor(predicate: () => boolean, message: string): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/main/__tests__/bot-onboarding-main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
mergeSettings,
type AppSettings,
type UpdateAppSettingsInput,
} from '@maka/core';
import type { BotRegistry } from '@maka/runtime';
} from '@maka/core/settings';
import type { BotRegistry } from '@maka/runtime/bots';
import type { SettingsStore } from '@maka/storage';
import {
BotOnboardingService,
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/main/__tests__/browser-tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { strict as assert } from 'node:assert';
import { afterEach, describe, it } from 'node:test';
import type { IPage } from '@jackwener/opencli/types';
import type { MakaTool, MakaToolContext } from '@maka/runtime';
import type { MakaTool, MakaToolContext } from '@maka/runtime/tool-runtime';
import {
buildBrowserClickTool,
buildBrowserExtractTool,
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src/main/__tests__/chat-readiness.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'node:assert/strict';
import { describe, test } from 'node:test';
import type { LlmConnection, SessionHeader } from '@maka/core';
import type { LlmConnection } from '@maka/core/llm-connections';
import type { SessionHeader } from '@maka/core/session';
import {
NO_REAL_CONNECTION_CODE,
assertSessionCanSend,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import type { ComputerUseToolSet, MakaTool } from '@maka/runtime';
import type { ComputerUseToolSet } from '@maka/runtime/computer-use-tools';
import type { MakaTool } from '@maka/runtime/tool-runtime';
import {
applyComputerUseRealModelPolicy,
parseComputerUseRealModelPolicy,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';
import type { AppSettings } from '@maka/core';
import type { AppSettings } from '@maka/core/settings';
import type { LlmConnection } from '@maka/core/llm-connections';
import type { CredentialKind } from '@maka/storage';
import { applyConfigImport, gatherConfigExport, type ConfigTransferDeps } from '../config-transfer-service.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';
import type { StoredMessage } from '@maka/core';
import type { StoredMessage } from '@maka/core/session';
import { renderConversationMarkdown } from '../../renderer/conversation-markdown.js';

describe('renderConversationMarkdown', () => {
Expand Down
10 changes: 7 additions & 3 deletions apps/desktop/src/main/__tests__/create-session-input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';
import type { AppSettings, ChatDefaultPermissionMode } from '@maka/core';
import { DEEP_RESEARCH_SESSION_LABEL, DEFAULT_SESSION_NAME } from '@maka/core';
import type { AppSettings, ChatDefaultPermissionMode } from '@maka/core/settings';
import { DEEP_RESEARCH_SESSION_LABEL } from '@maka/core/explore-agent';

import { DEFAULT_SESSION_NAME } from '@maka/core/session-name';

import {
type CreateSessionRequest,
Expand All @@ -17,7 +19,9 @@ import {
} from '../create-session-input.js';

function settings(permissionMode: ChatDefaultPermissionMode) {
return async () => ({ chatDefaults: { permissionMode } }) as AppSettings;
return async () => (({
chatDefaults: { permissionMode },
}) as AppSettings);
}

/** Anything the renderer can put on the wire, including what the type forbids:
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/main/__tests__/cursor-engine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';

import { DEFAULT_PRESENTATION_FINISHED_TIMEOUT_MS } from '@maka/runtime';
import { DEFAULT_PRESENTATION_FINISHED_TIMEOUT_MS } from '@maka/runtime/computer-use-tools';

import {
CODEX_CURSOR_GLYPH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import {
applyRuntimeEventHistoryCompact,
buildHistoryCompactBlockFromSummary,
type HistoryCompactBlock,
type HistoryCompactWriteInput,
} from '@maka/runtime';
} from '@maka/runtime/context-budget';
import { type HistoryCompactWriteInput } from '@maka/runtime/ai-sdk-compaction-contract';
import {
createSqliteArtifactStore,
type ArtifactStore,
} from '@maka/storage';
import {
loadHistoryCompactBlocksFromArtifacts,
persistHistoryCompactBlocksToArtifacts,
} from '@maka/runtime';
} from '@maka/runtime/history-compact-artifacts';

describe('desktop history compact artifact lifecycle', () => {
test('persists archived RuntimeEvent sources and a compact block', async () => {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/main/__tests__/maka-uri.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';
import { SETTINGS_SECTIONS } from '@maka/core';
import { SETTINGS_SECTIONS } from '@maka/core/settings';
import {
isMakaUri,
isMakaUriCandidate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { dirname, resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { describe, it } from 'node:test';
import { build } from 'esbuild';
import type { ChatModelChoice, LlmConnection, SessionSummary } from '@maka/core';
import type { ChatModelChoice } from '@maka/core/chat-model-choice';
import type { LlmConnection } from '@maka/core/llm-connections';
import type { SessionSummary } from '@maka/core/session';
import { buildChatModelChoices } from '@maka/core/chat-model-choice';
import {
normalizeActiveChatModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';
import type { AppSettings } from '@maka/core';
import type { AppSettings } from '@maka/core/settings';
import { createDefaultSettings } from '@maka/core/settings';
import { resolveDefaultPermissionMode } from '../permission-mode-default.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
collectPersonalizationWarnings,
sanitizeAssistantTone,
sanitizeDisplayName,
} from '@maka/runtime';
} from '@maka/runtime/system-prompt/personalization-prompt';

describe('personalization prompt fragment', () => {
test('empty personalization produces no prompt fragment', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { strict as assert } from 'node:assert';
import { describe, it } from 'node:test';
import type { QuoteRef } from '@maka/core';
import type { QuoteRef } from '@maka/core/events';
import {
consumeCompanionQuoteSnapshot,
consumeCompanionInitialPrompt,
Expand Down
Loading
Loading