Repository navigation
Add Caffeinate controls to the status bar - #13480
Conversation
📝 WalkthroughWalkthroughThe change replaces boolean computer-awake configuration with normalized 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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.
🧹 Nitpick comments (2)
src/renderer/src/components/status-bar/CaffeinateStatusSegment.tsx (2)
59-82: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueGuard the mount effect against paired web client windows.
isPairedWebClientWindow()returnstruefor these windows, and the component then rendersnull. TheuseEffecton Line 59 still runs before that check. It subscribes towindow.api.agentAwake.onChangedand callsgetStatus()in windows that never display this segment.Move the check inside the effect to skip the subscription and the status fetch when the window is a paired web client window.
♻️ Proposed fix
useEffect(() => { + if (isPairedWebClientWindow()) { + return + } let mounted = true const unsubscribe = window.api.agentAwake.onChanged((status) => { if (mounted) { setServiceStatus(status) } }) void window.api.agentAwake .getStatus() .then((status) => { if (mounted) { setServiceStatus(status) } }) .catch(() => {}) return () => { mounted = false unsubscribe() } }, [])
84-84: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSimplify the
modeassignment; the ternary always resolves toconfiguredMode.When
serviceStatus.mode === configuredModeis true,serviceStatus.modeequalsconfiguredModeby definition. When it is false, the expression returnsconfiguredModedirectly. Both branches produce the same value, somodeis alwaysconfiguredMode.Only
activeneeds to reconcile live status against the configured mode. Simplifymodeto remove the misleading ternary.♻️ Proposed fix
- const mode = serviceStatus.mode === configuredMode ? serviceStatus.mode : configuredMode + const mode = configuredMode const active = serviceStatus.mode === configuredMode ? serviceStatus.active : configuredMode === 'on'
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 16cb6dd0-36dc-4cb8-bee5-88b0c1b579fa
📒 Files selected for processing (20)
src/main/agent-awake-service.test.tssrc/main/agent-awake-service.tssrc/main/index.tssrc/main/ipc/settings.test.tssrc/main/ipc/settings.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/feature-wall/KeepAwakeCard.tsxsrc/renderer/src/components/settings/AgentAwakeSetting.tsxsrc/renderer/src/components/settings/AgentsPane.test.tsxsrc/renderer/src/components/settings/agent-awake-copy.tssrc/renderer/src/components/status-bar/CaffeinateStatusSegment.tsxsrc/renderer/src/components/status-bar/StatusBar.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/web/web-preload-api.tssrc/shared/computer-awake-mode.test.tssrc/shared/computer-awake-mode.tssrc/shared/types.tstests/e2e/settings-agent-awake.spec.tstests/e2e/status-bar-caffeinate.spec.ts
* feat: add caffeinate status controls * refactor: compact caffeinate status * fix: harden caffeinate readiness
Summary
Readiness review
Testing
pnpm run typecheckpnpm run check:code-quality:changedpnpm run check:max-lines-ratchetv1.4.176Visual proof
Before
Compact mode menu
Compact Auto active