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
49 changes: 5 additions & 44 deletions apps/desktop/renderer-architecture.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@
"src/renderer/settings/runtime-host-interaction-boundary.tsx",
"src/renderer/settings/runtime-host-management-dialog.tsx",
"src/renderer/settings/runtime-host-onboarding-dialog.tsx",
"src/renderer/settings/runtime-host-peer-mesh-dialog.tsx",
"src/renderer/settings/runtime-host-profiles-section.tsx",
"src/renderer/settings/runtime-host-project-directory-editor.tsx",
"src/renderer/settings/runtime-host-settings-bridge.ts",
Expand Down Expand Up @@ -3911,34 +3910,6 @@
"react": 1
}
},
"src/renderer/settings/runtime-host-peer-mesh-dialog.tsx": {
"bridgePaths": {
"window.maka.runtimeHostPeerMesh.execute": 6
},
"environmentCapabilities": {
"navigator.clipboard.writeText": 1
},
"hookCalls": {
"useEffect": 1,
"useState": 5,
"useToast": 1,
"useUiLocale": 1
},
"lifecycleMethods": {},
"unresolvedDependencies": 0,
"actionFactories": [],
"dependencyPaths": {
"../../preload/bridge-contract.js": 1,
"@astryxdesign/core": 1,
"@astryxdesign/core/Dialog": 1,
"@astryxdesign/core/Layout": 1,
"@astryxdesign/core/Stack": 1,
"@maka/runtime-host/protocol": 2,
"@maka/ui": 1,
"@maka/ui/icons": 1,
"react": 1
}
},
"src/renderer/settings/runtime-host-profiles-section.tsx": {
"bridgePaths": {
"window.maka.localRuntimeHostRemoteAccess.createConnectionCode": 1,
Expand All @@ -3949,7 +3920,6 @@
"window.maka.runtimeHostProfiles.addAndEnable": 1,
"window.maka.runtimeHostProfiles.getSnapshot": 1,
"window.maka.runtimeHostProfiles.remove": 1,
"window.maka.runtimeHostProfiles.resolvePairingRecovery": 1,
"window.maka.runtimeHostProfiles.setDefault": 1,
"window.maka.runtimeHostProfiles.setEnabled": 1,
"window.maka.runtimeHostProfiles.subscribeChanges": 1
Expand All @@ -3969,14 +3939,14 @@
"actionFactories": [],
"dependencyPaths": {
"../../preload/bridge-contract.js": 1,
"../features/runtime-host-management": 1,
"../locales/session-collaboration-copy.js": 1,
"../locales/settings-projects-copy.js": 1,
"../session-collaboration-dialog.js": 1,
"./password-input.js": 1,
"./runtime-host-connection-code-dialog.js": 1,
"./runtime-host-management-dialog.js": 1,
"./runtime-host-onboarding-dialog.js": 1,
"./runtime-host-peer-mesh-dialog.js": 1,
"./settings-error-copy.js": 1,
"./settings-section.js": 1,
"@astryxdesign/core": 1,
Expand Down Expand Up @@ -5570,7 +5540,7 @@
"nonTriviaTokens": 206
},
"src/renderer/main.tsx": {
"importDeclarations": 17,
"importDeclarations": 8,
"bridgePaths": {
"window.maka.onboarding.getSnapshot": 2
},
Expand All @@ -5586,23 +5556,14 @@
"../preload/bridge-contract.js": 1,
"./app": 1,
"./cached-theme-bootstrap": 1,
"./features/goals": 1,
"./features/module-hub": 1,
"./features/session-navigation": 1,
"./features/task-entry": 1,
"./features/workbar": 1,
"./platform/desktop/create-goal-services": 1,
"./platform/desktop/create-module-hub-services": 1,
"./platform/desktop/create-session-navigation-services": 1,
"./platform/desktop/create-task-entry-services": 1,
"./platform/desktop/create-workbar-services": 1,
"./composition/desktop-feature-services": 1,
"./styles.css": 1,
"./use-system-ui-locale": 1,
"@maka/ui": 1,
"react-dom/client": 1
},
"importSpecifiers": 16,
"nonTriviaTokens": 412
"importSpecifiers": 8,
"nonTriviaTokens": 268
}
},
"rootDebtClosure": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,29 @@ test('keeps Local and remote Hosts active and routes work by owning Host', async
await manager.close();
});

test('keeps independent shared-session credentials active for the same Host', async () => {
const candidates = [
candidateHarness({ hostId: 'host-local' }).candidate,
candidateHarness({ hostId: 'a'.repeat(64), ownership: 'external' }).candidate,
candidateHarness({ hostId: 'a'.repeat(64), ownership: 'external' }).candidate,
];
const manager = await startRuntimeHostDesktopManager(
{} as DesktopRuntimeHostCandidateStartInput,
{ startCandidate: async () => ready(candidates.shift()!) },
);

await manager.enable(remoteTarget('shared-one', 'shared', 'session_guest'));
await manager.enable(remoteTarget('shared-two', 'shared', 'session_guest'));

assert.deepEqual(manager.entries().map(({ target }) => target.profile.id), [
'local',
'shared-one',
'shared-two',
]);
assert.notEqual(manager.current('shared-one')?.epoch, manager.current('shared-two')?.epoch);
await manager.close();
});

test('replays pairing finalization after an unknown commit and reconnect', async () => {
const local = candidateHarness({ hostId: 'host-a' });
const remoteHostId = 'a'.repeat(64);
Expand Down Expand Up @@ -1442,6 +1465,7 @@ function ready(candidate: DesktopRuntimeHostCandidate): DesktopRuntimeHostCandid
function remoteTarget(
id: string,
target = 'default',
access?: 'session_guest',
): NonNullable<DesktopRuntimeHostCandidateStartInput['profileTarget']> {
return {
profile: {
Expand All @@ -1450,6 +1474,7 @@ function remoteTarget(
kind: 'remote',
transport: { kind: 'tls', url: `wss://${target}.example.com/` },
rootId: 'a'.repeat(64),
...(access ? { access } : {}),
},
credential: `credential-${target}`,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { EventEmitter } from 'node:events';
import { PassThrough } from 'node:stream';
import test from 'node:test';
import {
encodeRuntimeHostPeerMeshManagementFrame,
encodeRuntimeHostServiceManagementFrame,
encodeRuntimeHostSetupFrame,
RUNTIME_HOST_OPERATOR_PROJECT_DIRECTORY_CONFIGURATION_REQUEST_ENV,
Expand Down Expand Up @@ -206,3 +207,91 @@ test('local update runs the selected package against the exact managed deploymen
);
assert.deepEqual(phases, ['staging']);
});

test('local Peer Mesh join keeps invitations off argv and accepts bounded large results', async (t) => {
let args: readonly string[] | undefined;
let input = '';
const largeSnapshot = {
available: true,
localPeerId: 'local-peer',
meshes: Array.from({ length: 16 }, (_, meshIndex) => ({
meshId: `mesh-${meshIndex}`,
role: 'authority' as const,
authorityPeerId: 'local-peer',
revision: 1,
closed: false,
members: Array.from({ length: 64 }, (_, memberIndex) => ({
peerId: `peer-${meshIndex}-${memberIndex}-${'x'.repeat(48)}`,
endpointKind: 'client' as const,
displayName: `Member ${meshIndex}-${memberIndex} ${'x'.repeat(60)}`,
state: 'route_available' as const,
expiresAt: 4_000_000_000_000,
})),
pendingInvitationCount: 0,
})),
transit: {
meshId: null,
allowedMemberCount: 0,
activeReservationCount: 0,
activeCircuitCount: 0,
maxReservationCount: 32,
maxCircuitCount: 8,
maxCircuitsPerPeer: 2,
maxCircuitDurationSeconds: 7_200,
maxCircuitBytes: 256 * 1024 * 1024,
},
};
const spawnProcess = ((_command, commandArgs) => {
args = Array.isArray(commandArgs) ? commandArgs : undefined;
const child = new EventEmitter() as ReturnType<typeof spawn>;
const stdin = new PassThrough();
const stdout = new PassThrough();
const stderr = new PassThrough();
stdin.on('data', (chunk: Buffer) => { input += chunk.toString('utf8'); });
Object.assign(child, { pid: 1234, stdin, stdout, stderr, kill: () => true });
process.nextTick(() => {
const resultFrame = encodeRuntimeHostPeerMeshManagementFrame({
kind: 'result',
action: 'join',
result: largeSnapshot,
});
assert.ok(resultFrame.length > 30_000);
stdout.write(
encodeRuntimeHostPeerMeshManagementFrame({ kind: 'input', action: 'join' }) +
resultFrame.slice(0, 30_000),
);
stdout.end(resultFrame.slice(30_000));
stderr.end();
child.emit('close', 0, null);
});
return child;
}) as typeof spawn;
const operator = createDesktopRuntimeHostLocalOperator({ spawnProcess });
t.after(() => operator.close());
const invitation = JSON.stringify({ secret: 'one-time-mesh-secret' });

const result = await operator.runPeerMesh({
operatorPath: '/tmp/maka/operator',
action: 'join',
target: {
serviceId: 'b'.repeat(64),
rootPath: '/tmp/maka/root',
rootId: 'a'.repeat(64),
deploymentId: '00000000-0000-4000-8000-000000000001',
},
invitation,
});

assert.deepEqual(args, [
'mesh', 'join', '--framed',
'--expected-service-id', 'b'.repeat(64),
'--expected-root-path', '/tmp/maka/root',
'--expected-root-id', 'a'.repeat(64),
'--expected-deployment-id', '00000000-0000-4000-8000-000000000001',
]);
assert.equal(input, `${invitation}\n`);
assert.equal(
result.kind === 'result' && result.action === 'join' ? result.result.meshes.length : 0,
16,
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@ function unusedUpdateDependencies() {

function unusedDirectPeerProfileDependencies() {
return {
assertPairingComplete: () => undefined,
resolveManagedDirectPeerProfile: async (): Promise<never> =>
assert.fail('direct peer profile inspection is not expected'),
upsertManagedDirectPeerProfile: async (): Promise<never> =>
Expand Down
Loading
Loading