Skip to content

[codex] Chain recording after source selection#7

Merged
EtienneLescot merged 6 commits into
mainfrom
codex/record-source-chain
Jun 19, 2026
Merged

[codex] Chain recording after source selection#7
EtienneLescot merged 6 commits into
mainfrom
codex/record-source-chain

Conversation

@EtienneLescot

@EtienneLescot EtienneLescot commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes #5.

  • Keeps the HUD record button enabled when no capture source is selected.
  • Treats record-button source selection as an explicit pending recording intent, then starts recording immediately after the user picks a source.
  • Keeps manual source selection separate, so opening the source picker from the source button only selects a source.
  • Adds typed source-selection lifecycle IPC events and regression coverage for the chained and manual paths.

Root Cause

The primary record action was disabled whenever getSelectedSource() returned null, leaving users with no tooltip and no way to progress from the primary action. The earlier fix made the button open the picker, but did not preserve the user's original intent to record after choosing a source.

Validation

  • npx vitest run
  • npx tsc --noEmit
  • npx biome check electron/main.ts electron/ipc/handlers.ts electron/preload.ts electron/electron-env.d.ts src/components/launch/LaunchWindow.tsx src/components/launch/LaunchWindow.test.tsx tests/e2e/windows-native-checklist.spec.ts
  • npm run build:native:win
  • npm run test:wgc-helper:win -- --capture-cursor

Summary by CodeRabbit

  • Bug Fixes

    • Improved error resilience when selecting recording sources with better failure handling.
  • New Features

    • Recording source selection now uses localized default naming.
    • Added periodic source polling with graceful error handling.
  • Improvements

    • Enhanced record button styling and responsiveness during source selection workflow.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@EtienneLescot, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 46 minutes and 2 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 69534320-b8fd-4f14-aa77-433b7a23d6f4

📥 Commits

Reviewing files that changed from the base of the PR and between eef9b2e and 45f8c50.

📒 Files selected for processing (1)
  • src/components/launch/LaunchWindow.test.tsx
📝 Walkthrough

Walkthrough

LaunchWindow now initializes the selected source from a localized default, polls getSelectedSource with error handling via console.warn, and subscribes to onSelectedSourceChanged/onSourceSelectorClosed to manage a deferred-recording flag. handleRecordButtonClick sets and clears that flag around the selector open attempt. The record button wiring, tooltip, and styling now key off hasSelectedSource || recording. Two new tests cover the openSourceSelector throw and polling failure paths.

Changes

LaunchWindow Source State, Deferred Record, and Error Handling

Layer / File(s) Summary
Source state, polling, and electron event subscriptions
src/components/launch/LaunchWindow.tsx
Initializes selectedSource from a localized defaultSourceName, refactors selection into applySelectedSource, wraps getSelectedSource() polling in try/catch with console.warn, and subscribes to onSelectedSourceChanged/onSourceSelectorClosed to conditionally trigger or clear deferred recording via recordAfterSourceSelectionRef.
handleRecordButtonClick and record button wiring
src/components/launch/LaunchWindow.tsx
openSourceSelector now returns an explicit { opened: false, reason: "electron-api-unavailable" } fallback. handleRecordButtonClick sets recordAfterSourceSelectionRef before opening the selector and clears it on failure or non-open results. The record button calls handleRecordButtonClick and its tooltip/aria-label/styling are driven by hasSelectedSource || recording.
Tests for error paths
src/components/launch/LaunchWindow.test.tsx
Adds a test verifying that if openSourceSelector throws, a subsequent source emission updates the button title but does not call toggleRecording. Adds a test verifying that if getSelectedSource throws during polling, console.warn is called with the expected message and error object.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 A source must be chosen before we record,
The selector opens, a flag gets stored.
If errors arise, we warn with care,
No phantom toggles floating in the air.
The button lights up when a source is found —
Hoppy little features, safe and sound! 🎬

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Chain recording after source selection' clearly describes the main implementation approach of enabling deferred recording after source picker interaction.
Description check ✅ Passed The PR description is comprehensive with summary, issue reference, validation steps, and root cause explanation. All major template sections are covered appropriately.
Linked Issues check ✅ Passed The PR successfully addresses issue #5 by enabling the record button when no source is selected and implementing automatic recording after source selection, fixing the disabled button bug.
Out of Scope Changes check ✅ Passed All changes in LaunchWindow.test.tsx and LaunchWindow.tsx are directly related to fixing the record button behavior and source selection workflow as specified in issue #5.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/record-source-chain

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@EtienneLescot EtienneLescot marked this pull request as ready for review June 19, 2026 09:19

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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 `@src/components/launch/LaunchWindow.tsx`:
- Around line 488-495: The handleRecordButtonClick function sets
recordAfterSourceSelectionRef.current to true before calling openSourceSelector,
but if that promise rejects, the .then() branch never executes, leaving the
deferred-record intent armed even though the source selector failed. Add error
handling to the promise chain using a .catch() clause or .finally() clause that
clears recordAfterSourceSelectionRef.current to false when openSourceSelector
fails, ensuring the flag doesn't persist and trigger an unexpected recording
later.
- Around line 443-454: The checkSelectedSource async function awaits
window.electronAPI.getSelectedSource() without error handling, which causes
unhandled promise rejections to repeat every 500ms when the IPC call fails. Wrap
the await statement for getSelectedSource() in a try/catch block to handle
potential rejections, and consider logging the error or providing appropriate
fallback behavior in the catch block to prevent the interval from continuously
producing unhandled rejections.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: cdad30bc-551d-4b41-80ce-d68e51b1bd97

📥 Commits

Reviewing files that changed from the base of the PR and between 1a17f8b and 8a9b8a5.

📒 Files selected for processing (8)
  • .github/workflows/discord.yaml
  • electron/electron-env.d.ts
  • electron/ipc/handlers.ts
  • electron/main.ts
  • electron/preload.ts
  • src/components/launch/LaunchWindow.test.tsx
  • src/components/launch/LaunchWindow.tsx
  • tests/e2e/windows-native-checklist.spec.ts

Comment thread src/components/launch/LaunchWindow.tsx
Comment thread src/components/launch/LaunchWindow.tsx Outdated
@EtienneLescot EtienneLescot force-pushed the codex/record-source-chain branch from 8a9b8a5 to d8eb5d2 Compare June 19, 2026 10:35

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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 `@src/components/launch/LaunchWindow.test.tsx`:
- Around line 279-287: The test has a race condition where
emitSelectedSourceChanged is called after verifying openSourceSelector was
called, but this does not guarantee the rejection catch handler has completed
and cleared the deferred-record intent. Before calling
emitSelectedSourceChanged(displayOneSource), add synchronization to ensure any
promise rejection handling from the record button click has fully completed.
This likely requires an additional waitFor assertion or similar synchronization
point that waits for the catch handler execution to finish before proceeding
with the source change emission.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ca0e9a20-009b-4829-9775-112adb21e6cf

📥 Commits

Reviewing files that changed from the base of the PR and between 8a9b8a5 and eef9b2e.

📒 Files selected for processing (2)
  • src/components/launch/LaunchWindow.test.tsx
  • src/components/launch/LaunchWindow.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/launch/LaunchWindow.tsx

Comment thread src/components/launch/LaunchWindow.test.tsx
@EtienneLescot EtienneLescot merged commit 4a90d6c into main Jun 19, 2026
11 checks passed
@EtienneLescot EtienneLescot deleted the codex/record-source-chain branch June 19, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Record button is disabled. No Tooltip.

1 participant