fix: allow PTT hotkey Tauri commands#3797
Conversation
📝 WalkthroughWalkthroughAdds a new Tauri permission definition ChangesPTT Hotkey ACL Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29c0a49b9b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/test/tauri-ptt-acl.test.ts (1)
24-26: ⚡ Quick winUse an
interfacefor the parsed capability shape.The inline object shape assertion should be replaced with a named interface for TS consistency.
Suggested change
+interface DefaultCapability { + permissions?: unknown[]; +} + describe('desktop Tauri ACL for push-to-talk hotkeys', () => { - const defaultCapability = JSON.parse(readFileSync(DEFAULT_CAPABILITY_PATH, 'utf8')) as { - permissions?: unknown[]; - }; + const defaultCapability = JSON.parse(readFileSync(DEFAULT_CAPABILITY_PATH, 'utf8')) as DefaultCapability;As per coding guidelines,
**/*.{ts,tsx}: Always useinterfacefor defining object shapes in TypeScript.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/test/tauri-ptt-acl.test.ts` around lines 24 - 26, The type assertion for the `defaultCapability` variable uses an inline object shape instead of a named interface, which violates TypeScript consistency guidelines. Create a named interface that defines the object shape with the `permissions?: unknown[]` property, then replace the inline `as { permissions?: unknown[] }` assertion with the new interface name. This will align with the coding guidelines that require named interfaces for defining object shapes in TypeScript.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/test/tauri-ptt-acl.test.ts`:
- Around line 33-35: The test in the it.each block only verifies that each
PTT_COMMANDS entry is contained within the extractAllowedCommands result, but
does not enforce that these are the only allowed commands. Change the test to
verify exact equality between the extracted allowed commands and the
PTT_COMMANDS array, rather than using containment checks. This ensures that
adding extra commands to the allow-ptt-hotkey-control permission would cause the
test to fail, preventing unintended ACL scope widening.
---
Nitpick comments:
In `@app/test/tauri-ptt-acl.test.ts`:
- Around line 24-26: The type assertion for the `defaultCapability` variable
uses an inline object shape instead of a named interface, which violates
TypeScript consistency guidelines. Create a named interface that defines the
object shape with the `permissions?: unknown[]` property, then replace the
inline `as { permissions?: unknown[] }` assertion with the new interface name.
This will align with the coding guidelines that require named interfaces for
defining object shapes in TypeScript.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f7d5d58d-bc24-4cb5-9e38-bab84627e7aa
📒 Files selected for processing (3)
app/src-tauri/capabilities/default.jsonapp/src-tauri/permissions/allow-ptt-hotkey-control.tomlapp/test/tauri-ptt-acl.test.ts
Summary
Problem
The PTT frontend invokes
register_ptt_hotkeyandunregister_ptt_hotkeyfrom the Tauri webview. Those commands are registered in the Rust invoke handler, but the default desktop capability did not grant them, so Tauri rejected calls withCommand unregister_ptt_hotkey not allowed by ACL(#3724).Follow-up review also caught that the default
showOverlaysetting callsshow_ptt_overlaybefore audio capture starts. Without that command in the same permission, the hotkey could register but the default PTT flow would still abort on the overlay invoke.Solution
allow-ptt-hotkey-control, scoped to the three PTT lifecycle commands:register_ptt_hotkeyunregister_ptt_hotkeyshow_ptt_overlayapp/src-tauri/capabilities/default.json.app/test/tauri-ptt-acl.test.ts, which parses the default capability and permission TOML contract.Submission Checklist
tauri-ptt-acl.test.ts; CI will enforce formal coverage.## Related.Closes #NNNin## Related.Impact
Related
AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
fix/ptt-hotkey-acl34dc3c03dd1565d69e7406f4897c1312939319d7Validation Run
pnpm --filter openhuman-app exec vitest run --config test/vitest.config.ts test/tauri-ptt-acl.test.ts --pool=threads- 1 file passed, 2 tests passed.pnpm --filter openhuman-app exec prettier --check test/tauri-ptt-acl.test.ts src-tauri/permissions/allow-ptt-hotkey-control.tomlgit diff --check -- app/src-tauri/permissions/allow-ptt-hotkey-control.toml app/test/tauri-ptt-acl.test.tsregister_ptt_hotkey/unregister_ptt_hotkeybefore opening this PR.pnpm --filter openhuman-app format:check- N/A: changed-file Prettier check passed instead.pnpm typecheck- N/A: focused Vitest compiled the test file and no app TypeScript source changed.app/test/tauri-ptt-acl.test.tspassed, 2 tests.Validation Blocked
command:N/Aerror:N/Aimpact:N/ABehavior Changes
Parity Contract
Duplicate / Superseded PR Handling
register_ptt_hotkey/unregister_ptt_hotkey.