fix: use namespace import for os in main constants#555
fix: use namespace import for os in main constants#555reachraza merged 3 commits intoRunMaestro:mainfrom
Conversation
|
@pedramamini fix is up in this PR. It switches \ to a namespace \ import, which reproduces and fixes the Node 22 CI failure () that was breaking main. |
📝 WalkthroughWalkthroughUpdated the OS module import in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
|
@pedramamini fix is up in this PR. It switches |
Greptile SummaryThis PR fixes a Node 22 + Vitest SSR compatibility failure in Key changes:
Observation: Several other files in Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["import os from 'os'\n(default import)"] --> B{Vitest SSR\nmodule resolver}
C["import * as os from 'os'\n(namespace import)"] --> B
B -->|default import| D["os = { default: <osModule> }"]
B -->|namespace import| E["os = <osModule>\n{ tmpdir, homedir, ... }"]
D --> F["os.tmpdir()\n→ default.tmpdir is not a function ❌"]
E --> G["os.tmpdir()\n→ '/tmp' ✅"]
G --> H["DEMO_DATA_PATH resolved correctly"]
F --> I["Module load failure in Node 22 + Vitest SSR"]
Last reviewed commit: 3580462 |
| @@ -6,7 +6,7 @@ | |||
| */ | |||
|
|
|||
| import path from 'path'; | |||
There was a problem hiding this comment.
Inconsistent import style with path
The os import has been updated to namespace style (* as os) to fix the Node 22 / Vitest SSR issue, but the path import on the line above still uses the default import style. Since both path and os are Node built-in modules and both are used together in the same module-level expression on line 85 (path.join(os.tmpdir(), ...)), aligning them to the same import style would be cleaner and guards against the same potential SSR interop issue for path.
| import path from 'path'; | |
| import * as path from 'path'; |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
4f750d1 to
08a7ed2
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/__tests__/renderer/hooks/useAgentConfiguration.test.ts (1)
252-258: Consider verifying the mock was called with the correct agent ID.The new assertion verifies the resulting state but no longer checks that
getConfigwas invoked with'claude-code'. SincemockGetConfigreturns{ model: 'opus' }regardless of input, this test would pass even if the code regressed to pass an incorrect agent ID.Adding the mock call verification alongside the state assertion would catch regressions where the agent key drifts:
Suggested addition
await waitFor(() => { expect(result.current.agentConfig).toEqual({ model: 'opus' }); }); + + expect(mockGetConfig).toHaveBeenCalledWith('claude-code');🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/__tests__/renderer/hooks/useAgentConfiguration.test.ts` around lines 252 - 258, After toggling the config and asserting result.current.agentConfig, also assert the mock fetch was called with the expected agent ID: add an expectation that mockGetConfig (the mocked getConfig used in the test) was called with 'claude-code' so the test verifies both state and that getConfig was invoked with the correct agent key; reference the toggleConfigExpanded call and result.current.agentConfig to locate the right test block and add expect(mockGetConfig).toHaveBeenCalledWith('claude-code').
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/__tests__/renderer/hooks/useAgentConfiguration.test.ts`:
- Around line 252-258: After toggling the config and asserting
result.current.agentConfig, also assert the mock fetch was called with the
expected agent ID: add an expectation that mockGetConfig (the mocked getConfig
used in the test) was called with 'claude-code' so the test verifies both state
and that getConfig was invoked with the correct agent key; reference the
toggleConfigExpanded call and result.current.agentConfig to locate the right
test block and add expect(mockGetConfig).toHaveBeenCalledWith('claude-code').
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 817df631-1fe6-4b61-91c4-1024ae9f3c78
📒 Files selected for processing (2)
src/__tests__/renderer/hooks/useAgentConfiguration.test.tssrc/main/constants.ts
✅ Files skipped from review due to trivial changes (1)
- src/main/constants.ts
Summary
src/main/constants.tsfrom a defaultosimport to a namespace importDEMO_DATA_PATH(default.tmpdir is not a function)Verification
npx vitest run src/__tests__/main/agents/session-storage.test.tsnpx -p node@22 node node_modules/vitest/vitest.mjs run src/__tests__/main/agents/session-storage.test.tsnpx -p node@22 node node_modules/vitest/vitest.mjs run src/__tests__/main/constants.test.tsSummary by CodeRabbit
Refactor
Tests
Note: Internal improvements only; no visible impact to end-user functionality.