fix: resolve react-doctor diagnostics across desktop, marketing, and web#1579
fix: resolve react-doctor diagnostics across desktop, marketing, and web#1579AviPeltz wants to merge 1 commit into
Conversation
Fix errors and warnings flagged by react-doctor to improve codebase health scores: - desktop: 89 → 93 (eliminated 2 errors, reduced warnings 44 → 37) - marketing: 97 → 99 (reduced warnings 8 → 4) - web: 97 → 98 (reduced warnings 3 → 1) Generated with [Ami](https://ami.dev) Co-Authored-By: Ami <noreply@ami.dev>
📝 WalkthroughWalkthroughThis PR consolidates multiple quality improvements and refactoring across desktop and marketing applications, including state management enhancements, accessibility features, React key handling corrections, concurrent async operations, page metadata additions, and style optimization adjustments. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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 |
🚀 Preview Deployment🔗 Preview Links
Preview updates automatically with new commits |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceSidebar.tsx (1)
22-31: LGTM —useMemoremoval is appropriate here.The
reducelogic is correct: each group receives the cumulative workspace count of all preceding groups as itsshortcutBaseIndex, and.indicesis the right final projection. For a sidebar with a small, bounded number of project groups, running this inline every render is negligible and theuseMemooverhead (closure + dep-array allocation on every render) was comparable to the computation itself.One cosmetic note: the
[...acc.indices, acc.cumulative]spread insidereduceproduces O(n²) intermediate allocations as the array grows. This is entirely harmless at sidebar scale, but if you ever wanted to micro-optimize it's easy to swap for a mutable accumulator:♻️ Optional O(n) alternative
- const projectShortcutIndices = groups.reduce<{ - indices: number[]; - cumulative: number; - }>( - (acc, group) => ({ - indices: [...acc.indices, acc.cumulative], - cumulative: acc.cumulative + group.workspaces.length, - }), - { indices: [], cumulative: 0 }, - ).indices; + let cumulative = 0; + const projectShortcutIndices = groups.map((group) => { + const index = cumulative; + cumulative += group.workspaces.length; + return index; + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceSidebar.tsx` around lines 22 - 31, The current reduce in projectShortcutIndices uses [...acc.indices, acc.cumulative] which creates O(n^2) intermediate arrays; to micro-optimize, switch to a mutable accumulator: keep acc.indices as a single array and push acc.cumulative into it instead of spreading, update acc.cumulative += group.workspaces.length, and return the same acc object each iteration; keep the final .indices projection the same so existing callers of projectShortcutIndices are unaffected.apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx (1)
78-81: WrapselectProjectinuseCallbackto satisfyreact-hooks/exhaustive-deps.
selectProjectis consumed inside theuseEffectat lines 134–138 but is absent from its dependency array. React'sexhaustive-depsrule will flag this. Because both_setSelectedProjectIdandsetBaseBranchare stableuseStatesetters, auseCallbackwith an empty dependency array is correct and safe here, andselectProjectcan then be cleanly listed in the effect's deps.♻️ Proposed fix
- const selectProject = (projectId: string | null) => { - _setSelectedProjectId(projectId); - setBaseBranch(null); - }; + const selectProject = useCallback((projectId: string | null) => { + _setSelectedProjectId(projectId); + setBaseBranch(null); + }, []);useEffect(() => { if (isOpen && !selectedProjectId && preSelectedProjectId) { selectProject(preSelectedProjectId); } - }, [isOpen, selectedProjectId, preSelectedProjectId]); + }, [isOpen, selectedProjectId, preSelectedProjectId, selectProject]);(
useCallbackis already imported via line 31.)Also applies to: 134-138
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx` around lines 78 - 81, The selectProject function should be wrapped in React's useCallback to make it stable for the useEffect that consumes it; change the definition of selectProject to useCallback(() => { _setSelectedProjectId(projectId); setBaseBranch(null); }, []) since _setSelectedProjectId and setBaseBranch are stable state setters, then add selectProject to the effect's dependency array so react-hooks/exhaustive-deps is satisfied.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/project/`$projectId/page.tsx:
- Line 158: The container currently uses role="form" on a div (role="form") with
onKeyDown={handleKeyDown} so screen readers won't expose it because it lacks an
accessible name; either add an accessible name by assigning an id to the page
heading (the <h1>) and reference it via aria-labelledby on the role="form"
element, or replace the div with a native <form> element and move the keyboard
handler to an onSubmit handler (update handleKeyDown usage accordingly) so the
landmark is properly exposed and submission is handled semantically.
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/components/BasePaneWindow/BasePaneWindow.tsx`:
- Around line 111-114: The onKeyDown handler on the pane container is never
invoked from keyboard because the div cannot be focused; update the pane
container element (the div that registers onKeyDown) to include an explicit
tabIndex (e.g., tabIndex={0} to make it reachable by Tab or tabIndex={-1} if you
only want programmatic focus), so that e.target === e.currentTarget can be true
and handleFocus() will run; ensure the change is applied where onKeyDown and
handleFocus are defined (BasePaneWindow component) and consider accessibility
impact on internal focusable content when choosing 0 vs -1.
---
Nitpick comments:
In
`@apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx`:
- Around line 78-81: The selectProject function should be wrapped in React's
useCallback to make it stable for the useEffect that consumes it; change the
definition of selectProject to useCallback(() => {
_setSelectedProjectId(projectId); setBaseBranch(null); }, []) since
_setSelectedProjectId and setBaseBranch are stable state setters, then add
selectProject to the effect's dependency array so react-hooks/exhaustive-deps is
satisfied.
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceSidebar.tsx`:
- Around line 22-31: The current reduce in projectShortcutIndices uses
[...acc.indices, acc.cumulative] which creates O(n^2) intermediate arrays; to
micro-optimize, switch to a mutable accumulator: keep acc.indices as a single
array and push acc.cumulative into it instead of spreading, update
acc.cumulative += group.workspaces.length, and return the same acc object each
iteration; keep the final .indices projection the same so existing callers of
projectShortcutIndices are unaffected.
| <div className="flex-1 flex items-center justify-center"> | ||
| {/* biome-ignore lint/a11y/noStaticElementInteractions: onKeyDown for Enter-to-submit */} | ||
| <div className="w-full max-w-md mx-6" onKeyDown={handleKeyDown}> | ||
| <div role="form" className="w-full max-w-md mx-6" onKeyDown={handleKeyDown}> |
There was a problem hiding this comment.
role="form" missing accessible name — landmark won't be announced by screen readers
Per the WAI-ARIA spec, a form landmark is only exposed (and navigable) by assistive technologies when it carries an accessible name via aria-label or aria-labelledby. Without one, the role is silently dropped by most screen readers.
The <h1> on line 159 is the natural label — adding an id to it and referencing it with aria-labelledby is the minimal fix:
♿ Proposed fix
-<div role="form" className="w-full max-w-md mx-6" onKeyDown={handleKeyDown}>
- <h1 className="text-3xl font-semibold text-foreground tracking-tight mb-2">
- Create your first workspace
- </h1>
+<div role="form" aria-labelledby="create-workspace-heading" className="w-full max-w-md mx-6" onKeyDown={handleKeyDown}>
+ <h1 id="create-workspace-heading" className="text-3xl font-semibold text-foreground tracking-tight mb-2">
+ Create your first workspace
+ </h1>Alternatively, a native <form> element provides the same semantics without requiring an explicit role (its landmark is implicit when labelled) and allows using onSubmit instead of an onKeyDown intercept, which is cleaner:
✨ Optional: prefer native <form>
-<div role="form" className="w-full max-w-md mx-6" onKeyDown={handleKeyDown}>
+<form
+ aria-labelledby="create-workspace-heading"
+ className="w-full max-w-md mx-6"
+ onSubmit={(e) => { e.preventDefault(); handleCreateWorkspace(); }}
+>
<h1 ...>Create your first workspace</h1>
...
<Button
size="lg"
- onClick={handleCreateWorkspace}
+ type="submit"
...
>
-<div>
+</form>📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <div role="form" className="w-full max-w-md mx-6" onKeyDown={handleKeyDown}> | |
| <div role="form" aria-labelledby="create-workspace-heading" className="w-full max-w-md mx-6" onKeyDown={handleKeyDown}> | |
| <h1 id="create-workspace-heading" className="text-3xl font-semibold text-foreground tracking-tight mb-2"> | |
| Create your first workspace | |
| </h1> |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@apps/desktop/src/renderer/routes/_authenticated/_dashboard/project/`$projectId/page.tsx
at line 158, The container currently uses role="form" on a div (role="form")
with onKeyDown={handleKeyDown} so screen readers won't expose it because it
lacks an accessible name; either add an accessible name by assigning an id to
the page heading (the <h1>) and reference it via aria-labelledby on the
role="form" element, or replace the div with a native <form> element and move
the keyboard handler to an onSubmit handler (update handleKeyDown usage
accordingly) so the landmark is properly exposed and submission is handled
semantically.
| onKeyDown={(e) => { | ||
| if (e.target !== e.currentTarget) return; | ||
| if (e.key === "Enter" || e.key === " ") handleFocus(); | ||
| }} |
There was a problem hiding this comment.
onKeyDown Enter/Space path is unreachable — missing tabIndex
The guard e.target !== e.currentTarget means "only fire when the div itself is the keyboard event target." Because this div has no tabIndex, it cannot receive keyboard focus through standard navigation; e.target === e.currentTarget is never true in practice, so handleFocus() is never called from the keyboard. The handler satisfies the linter syntactically but not functionally.
To make the keyboard shortcut reachable, add tabIndex={0} to the div (or tabIndex={-1} for programmatic-only focus):
🛠️ Proposed fix
<div
role="group"
+ tabIndex={0}
ref={containerRef}
className={contentClassName}
style={isDragging ? { pointerEvents: "none" } : undefined}
onClick={handleFocus}
onKeyDown={(e) => {
if (e.target !== e.currentTarget) return;
if (e.key === "Enter" || e.key === " ") handleFocus();
}}
>Note: adding tabIndex={0} inserts the pane container into the tab order, which may interfere with Tab navigation inside pane content (terminals, editors). If that's undesirable, tabIndex={-1} allows programmatic focus without affecting the tab order, though keyboard users won't be able to tab to the pane itself.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| onKeyDown={(e) => { | |
| if (e.target !== e.currentTarget) return; | |
| if (e.key === "Enter" || e.key === " ") handleFocus(); | |
| }} | |
| <div | |
| role="group" | |
| tabIndex={0} | |
| ref={containerRef} | |
| className={contentClassName} | |
| style={isDragging ? { pointerEvents: "none" } : undefined} | |
| onClick={handleFocus} | |
| onKeyDown={(e) => { | |
| if (e.target !== e.currentTarget) return; | |
| if (e.key === "Enter" || e.key === " ") handleFocus(); | |
| }} | |
| > |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/TabView/components/BasePaneWindow/BasePaneWindow.tsx`
around lines 111 - 114, The onKeyDown handler on the pane container is never
invoked from keyboard because the div cannot be focused; update the pane
container element (the div that registers onKeyDown) to include an explicit
tabIndex (e.g., tabIndex={0} to make it reachable by Tab or tabIndex={-1} if you
only want programmatic focus), so that e.target === e.currentTarget can be true
and handleFocus() will run; ensure the change is applied where onKeyDown and
handleFocus are defined (BasePaneWindow component) and consider accessibility
impact on internal focusable content when choosing 0 vs -1.
|
Closing: stale react-doctor diagnostics fix from Feb 19. Likely outdated given ongoing dependency changes. |
|
Hey — just a heads up, this was closed as part of an automated stale PR cleanup. If you think this was done in error, feel free to reopen it! |
|
Hey — this was closed by an automated cleanup of PRs with major merge conflicts that are 3+ weeks old. If you think this was done incorrectly, please feel free to reopen it. Sorry for any inconvenience! |
Summary
Changes
Errors fixed (5):
FontSettingSection.tsx-- removed redundant useEffect that reset draft state (already cleared in onBlur handlers)NewWorkspaceModal.tsx-- replaced useEffect state reset with aselectProject()helper that co-locates the baseBranch reset with the project setterplans/page.tsx-- extracted inlinerenderComparisonValue()to aComparisonValueCellcomponentWarnings fixed (17):
useMemoinWorkspaceSidebar.tsx(trivially cheap reduce over small array)MessagePartsRenderer.tsx,ApiKeysSettings.tsx,AppMockup.tsxPromise.all()inCollectionsProvider.tsxwill-changefromProductDemo.tsxandTrustedBySection.tsxroleand guarded keyboard handler toBasePaneWindow.tsxandProjectPagemetadataexports todesktop/success/page.tsxandoauth/consent/page.tsxTest plan
Generated with Ami
Summary by CodeRabbit
Release Notes
Accessibility
Performance
SEO