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
11 changes: 5 additions & 6 deletions apps/desktop/renderer-architecture.json
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@
"react": 1
},
"importSpecifiers": 39,
"nonTriviaTokens": 3877
"nonTriviaTokens": 3836
},
"src/renderer/app-shell-overlays.tsx": {
"importDeclarations": 14,
Expand Down Expand Up @@ -2464,7 +2464,6 @@
"window.maka.sessionCollaboration.decideTurnRequest": 1,
"window.maka.sessionCollaboration.getAccess": 1,
"window.maka.sessionCollaboration.getTurnRequests": 1,
"window.maka.sessionCollaboration.importInvitation": 1,
"window.maka.sessionCollaboration.prepareInvitation": 1,
"window.maka.sessionCollaboration.revokeGrant": 1,
"window.maka.sessionCollaboration.revokePrincipal": 1
Expand All @@ -2476,9 +2475,9 @@
},
"hookCalls": {
"useEffect": 1,
"useState": 8,
"useToast": 2,
"useUiLocale": 2
"useState": 6,
"useToast": 1,
"useUiLocale": 1
},
"lifecycleMethods": {},
"unresolvedDependencies": 0,
Expand Down Expand Up @@ -3940,9 +3939,9 @@
"dependencyPaths": {
"../../preload/bridge-contract.js": 1,
"../features/runtime-host-management": 1,
"../features/session-collaboration": 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,
Expand Down
36 changes: 36 additions & 0 deletions apps/desktop/src/main/__tests__/desktop-session-projection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
projectDesktopTurnRecord,
projectDesktopUsageStats,
} from '../../shared/desktop-session-projection.js';
import { runtimeHostChangeRetiresSession } from '../../shared/runtime-host-identity.js';

test('keeps equal raw Session ids distinct across Runtime Hosts', () => {
const raw = summary('same-session');
Expand Down Expand Up @@ -57,6 +58,41 @@ test('keeps equal raw Session ids distinct across Runtime Hosts', () => {
assert.equal(remote.profileName, 'Office');
});

test('retires an active Session only after it leaves the refreshed Host catalog', () => {
const owner = projectDesktopSessionSummary(
{
hostId: 'shared-root',
profileId: 'owner',
profileName: 'Owner',
profileKind: 'remote',
},
summary('shared-session'),
);
const guest = projectDesktopSessionSummary(
{
hostId: 'shared-root',
profileId: 'guest',
profileName: 'Guest',
profileKind: 'remote',
},
summary('shared-session'),
);
const removedGuest = {
epoch: 'guest-epoch',
profileId: 'guest',
profileName: 'Guest',
profileKind: 'remote',
profileAccess: 'session_guest',
readiness: 'unavailable',
hostId: 'shared-root',
isDefault: false,
removed: true,
} as const;

assert.equal(runtimeHostChangeRetiresSession(removedGuest, guest.id, [owner]), false);
assert.equal(runtimeHostChangeRetiresSession(removedGuest, guest.id, []), true);
});

test('projects typed linked Session ids without rewriting opaque tool data', () => {
const host = { hostId: 'remote-root' };
const linkedSessionId = JSON.stringify(['remote-root', 'child-session']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ describe('createDesktopModuleHubServices', () => {
profileId: 'remote-a',
profileName: 'Remote',
profileKind: 'remote',
profileAccess: 'owner',
readiness: 'ready',
hostId: 'host-a',
isDefault: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,24 +567,61 @@ test('keeps independent shared-session credentials active for the same Host', as
candidateHarness({ hostId: 'host-local' }).candidate,
candidateHarness({ hostId: 'a'.repeat(64), ownership: 'external' }).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'));
await manager.mountGuest(remoteTarget('shared-one', 'shared', 'session_guest'));
await manager.mountGuest(remoteTarget('shared-two', 'shared', 'session_guest'));
await manager.enable(remoteTarget('owner', 'shared'));

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

test('aborts an in-flight Guest mount without publishing a late target', async () => {
const local = candidateHarness({ hostId: 'host-local' }).candidate;
let guestStarted!: () => void;
const started = new Promise<void>((resolve) => {
guestStarted = resolve;
});
const manager = await startRuntimeHostDesktopManager(
{} as DesktopRuntimeHostCandidateStartInput,
{
startCandidate: async (input) => {
if (!input.profileTarget) return ready(local);
guestStarted();
const signal = input.signal;
assert.ok(signal);
return new Promise<DesktopRuntimeHostCandidateStartResult>((_resolve, reject) => {
signal.addEventListener('abort', () => reject(signal.reason), { once: true });
});
},
},
);
const abort = new AbortController();
const mounting = manager.mountGuest(
remoteTarget('shared-cancelled', 'shared', 'session_guest'),
abort.signal,
);
await started;
abort.abort(new Error('cancelled'));
await assert.rejects(mounting, /cancelled/u);
await manager.unmountGuest('shared-cancelled');

assert.deepEqual(manager.entries().map(({ target }) => target.profile.id), ['local']);
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
Loading