Repository navigation
feat: Codex voice conversations on web, desktop, and mobile #14638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
jakeleventhal
wants to merge
7
commits into
pingdotgg:t3code/codex-turn-mapping
from
jakeleventhal:t3code/codex-voice-mode-rebased
+3,154
−47
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
feaf56e
feat: Codex voice conversations on web, desktop, and mobile
jakeleventhal d05cb90
fix: harden voice handoff resubmits and mobile voice controls
jakeleventhal 001dfd4
refactor: use Toggle for the voice button and a schema voice error
jakeleventhal c68b69f
fix(web): dim the disabled voice glyph instead of restyling Toggle
jakeleventhal 673d43a
fix: keep failed voice handoffs and let /voice always stop a live con…
jakeleventhal e712590
fix(server): don't let a conditional default shadow a user's uncondit…
jakeleventhal 4c1dbdf
fix: follow the base's namespace imports in voice code
jakeleventhal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { describe, expect, it } from "vite-plus/test"; | ||
|
|
||
| import { decideMainWindowMediaRequest, isAppUrl } from "./MainWindowPermissions.ts"; | ||
|
|
||
| const APP_URL = "t3code://app/"; | ||
|
|
||
| function decide(overrides: Partial<Parameters<typeof decideMainWindowMediaRequest>[0]> = {}) { | ||
| return decideMainWindowMediaRequest({ | ||
| requestingUrl: "t3code://app/threads/abc", | ||
| appUrl: APP_URL, | ||
| mediaTypes: ["audio"], | ||
| platform: "darwin", | ||
| microphoneStatus: () => "granted", | ||
| ...overrides, | ||
| }); | ||
| } | ||
|
|
||
| describe("isAppUrl", () => { | ||
| it("matches the app shell and nothing that merely shares its prefix", () => { | ||
| expect(isAppUrl("t3code://app", APP_URL)).toBe(true); | ||
| expect(isAppUrl("t3code://app/settings", APP_URL)).toBe(true); | ||
| expect(isAppUrl("t3code://application/", APP_URL)).toBe(false); | ||
| expect(isAppUrl("https://example.com/", APP_URL)).toBe(false); | ||
| expect(isAppUrl(undefined, APP_URL)).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("decideMainWindowMediaRequest", () => { | ||
| it("denies media to frames outside the app shell", () => { | ||
| expect(decide({ requestingUrl: "https://example.com/embed" })).toBe("deny"); | ||
| }); | ||
|
|
||
| it("asks macOS for the microphone until the user has granted it", () => { | ||
| expect(decide({ microphoneStatus: () => "not-determined" })).toBe("ask-microphone"); | ||
| expect(decide({ microphoneStatus: () => "denied" })).toBe("ask-microphone"); | ||
| expect(decide()).toBe("grant"); | ||
| }); | ||
|
|
||
| it("grants the microphone directly off macOS", () => { | ||
| expect(decide({ platform: "win32", microphoneStatus: () => "unknown" })).toBe("grant"); | ||
| }); | ||
|
|
||
| it("keeps granting video-only capture such as preview tab recording", () => { | ||
| expect(decide({ mediaTypes: ["video"], microphoneStatus: () => "denied" })).toBe("grant"); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import * as Electron from "electron"; | ||
|
|
||
| export type MediaPermissionDecision = "grant" | "deny" | "ask-microphone"; | ||
|
|
||
| /** Whether `url` belongs to the app shell served from `appUrl` (e.g. `t3code://app/`). */ | ||
| export function isAppUrl(url: string | undefined, appUrl: string): boolean { | ||
| if (!url) return false; | ||
| // Custom schemes have an opaque WHATWG origin, so compare the serialized prefix. | ||
| const appOrigin = appUrl.endsWith("/") ? appUrl.slice(0, -1) : appUrl; | ||
| return url === appOrigin || url.startsWith(`${appOrigin}/`); | ||
| } | ||
|
|
||
| /** | ||
| * Media requests come from the app shell (voice conversations use the | ||
| * microphone; preview tab recording routes `getDisplayMedia` through the same | ||
| * permission). Frames from any other origin never get media. On macOS the | ||
| * microphone also needs the system's consent, asked for on first use. | ||
| */ | ||
| export function decideMainWindowMediaRequest(input: { | ||
| readonly requestingUrl: string; | ||
| readonly appUrl: string; | ||
| readonly mediaTypes: ReadonlyArray<"audio" | "video">; | ||
| readonly platform: NodeJS.Platform; | ||
| readonly microphoneStatus: () => string; | ||
| }): MediaPermissionDecision { | ||
| if (!isAppUrl(input.requestingUrl, input.appUrl)) return "deny"; | ||
| if (!input.mediaTypes.includes("audio") || input.platform !== "darwin") return "grant"; | ||
| return input.microphoneStatus() === "granted" ? "grant" : "ask-microphone"; | ||
| } | ||
|
|
||
| /** | ||
| * Installs the main window session's permission handlers. Only `media` is | ||
| * decided here; every other permission keeps Electron's default of allowing | ||
| * it, which is what this session did before it had handlers. | ||
| */ | ||
| export function installMainWindowPermissionHandlers( | ||
| session: Electron.Session, | ||
| options: { readonly appUrl: string; readonly platform: NodeJS.Platform }, | ||
| ): void { | ||
| session.setPermissionRequestHandler((_webContents, permission, callback, details) => { | ||
| if (permission !== "media") { | ||
| callback(true); | ||
| return; | ||
| } | ||
| const decision = decideMainWindowMediaRequest({ | ||
| requestingUrl: details.requestingUrl, | ||
| appUrl: options.appUrl, | ||
| mediaTypes: "mediaTypes" in details ? (details.mediaTypes ?? []) : [], | ||
| platform: options.platform, | ||
| microphoneStatus: () => Electron.systemPreferences.getMediaAccessStatus("microphone"), | ||
| }); | ||
| if (decision !== "ask-microphone") { | ||
| callback(decision === "grant"); | ||
| return; | ||
| } | ||
| Electron.systemPreferences.askForMediaAccess("microphone").then(callback, () => { | ||
| callback(false); | ||
| }); | ||
| }); | ||
| session.setPermissionCheckHandler((_webContents, permission, requestingOrigin) => | ||
| permission === "media" ? isAppUrl(requestingOrigin, options.appUrl) : true, | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High
window/MainWindowPermissions.ts:61Trusted
mediachecks returntrue, so Electron skipssetPermissionRequestHandlerand never callsaskForMediaAccess("microphone"). On macOS, users withmicrophoneStatus()set to"not-determined"therefore receive no system consent prompt and voice capture remains unauthorized. Returnfalseformediachecks so the request handler can grant or deny the request and trigger the prompt.🤖 Copy this AI Prompt to have your agent fix this: