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
8 changes: 5 additions & 3 deletions hooks/useRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ export function useRoom(appConfig: AppConfig) {
}
};
const usesManagedRoomInput = browserSourceClient.enabled || appConfig.usesServerRoomInput;
const usesSandboxConcurrentStartup = Boolean(appConfig.sandboxId) && usesManagedRoomInput;
const usesConcurrentManagedStartup =
browserSourceClient.enabled ||
(Boolean(appConfig.sandboxId) && appConfig.usesServerRoomInput);

try {
await waitForAgentSessionStop();
Expand All @@ -266,7 +268,7 @@ export function useRoom(appConfig: AppConfig) {
recordFrontendObservability(FRONTEND_EVENTS.ROOM_CONNECT_FINISHED);
recordFrontendObservability(FRONTEND_EVENTS.ROOM_CONNECTED);
connectedRoomName = room.name;
if (usesSandboxConcurrentStartup) {
if (usesConcurrentManagedStartup) {
const [localInputResult, dispatchResult] = await Promise.allSettled([
startLocalInputOrCancelDispatch(),
dispatchAgentSession(),
Expand Down Expand Up @@ -299,7 +301,7 @@ export function useRoom(appConfig: AppConfig) {
]);
}

if (!usesSandboxConcurrentStartup) {
if (!usesConcurrentManagedStartup) {
await dispatchAgentSession();
}
setIsSessionActive(true);
Expand Down
4 changes: 2 additions & 2 deletions tests/browser-room-session.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ test('ending a voice session clears the reusable session id', async () => {
assert.doesNotMatch(useRoomSource, /if \(appConfig\.usesBrowserRawMediaInput\)/);
});

test('sandbox browser starts media and dispatch concurrently without changing local order', async () => {
test('browser input starts media and dispatch concurrently', async () => {
const useRoomSource = await readFile(new URL('../hooks/useRoom.ts', import.meta.url), 'utf8');
const browserSourceSource = await readFile(
new URL('../hooks/useBrowserSourceClient.ts', import.meta.url),
Expand All @@ -146,7 +146,7 @@ test('sandbox browser starts media and dispatch concurrently without changing lo
);
assert.match(
useRoomSource,
/usesSandboxConcurrentStartup = Boolean\(appConfig\.sandboxId\) && usesManagedRoomInput/
/usesConcurrentManagedStartup =\s*browserSourceClient\.enabled \|\|\s*\(Boolean\(appConfig\.sandboxId\) && appConfig\.usesServerRoomInput\)/
);
assert.match(
useRoomSource,
Expand Down
22 changes: 22 additions & 0 deletions tests/session-start-dispatch.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,28 @@ test('start call dispatches the agent with a cancellable room session id', async
assert.doesNotMatch(useRoomSource, /requestAgentSessionDispatch\(\s*room\.name,/);
});

test('browser input starts capture and agent dispatch concurrently outside sandbox', async () => {
const useRoomSource = await readFile(new URL('../hooks/useRoom.ts', import.meta.url), 'utf8');

assert.match(
useRoomSource,
/const usesConcurrentManagedStartup =\s*browserSourceClient\.enabled \|\|/
);
assert.match(
useRoomSource,
/if \(usesConcurrentManagedStartup\) \{[\s\S]*?Promise\.allSettled\(\[[\s\S]*?startLocalInputOrCancelDispatch\(\),[\s\S]*?dispatchAgentSession\(\),/
);
});

test('sandbox server-managed input keeps concurrent dispatch startup', async () => {
const useRoomSource = await readFile(new URL('../hooks/useRoom.ts', import.meta.url), 'utf8');

assert.match(
useRoomSource,
/usesConcurrentManagedStartup =\s*browserSourceClient\.enabled \|\|\s*\(Boolean\(appConfig\.sandboxId\) && appConfig\.usesServerRoomInput\)/
);
});

test('connection details request uses the same canonical session id as dispatch', async () => {
const useRoomSource = await readFile(new URL('../hooks/useRoom.ts', import.meta.url), 'utf8');

Expand Down
Loading