Add Platform Utils / Show Labels by OS in File Explorer#416
Add Platform Utils / Show Labels by OS in File Explorer#416pedramamini merged 4 commits intoRunMaestro:mainfrom
Conversation
Add OS platform detection via IPC so UI components can show the correct label for the reveal action: "Reveal in Explorer" on Windows, "Reveal in Finder" on macOS/Linux. - Add os:getPlatform and os:getArch IPC handlers in system.ts - Expose OsApi via preload contextBridge - Add useOsPlatform hook with module-level caching to avoid repeated IPC - Update FileExplorerPanel and TabBar to use platform-aware revealLabel - Update tests to accept both label variants via regex Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove OsApi interface, createOsApi function, OsApiType from preload/system.ts
- Replace `os: createOsApi()` with `platform: process.platform` in preload/index.ts
- Update MaestroAPI type in global.d.ts: replace `os` namespace with `platform: string`
- Add shared getRevealLabel(platform) utility in src/renderer/utils/platformUtils.ts
with correct Linux support ("Reveal in File Manager")
- Delete useOsPlatform hook (src/renderer/hooks/useOsPlatform.ts)
- Update FileExplorerPanel.tsx: use getRevealLabel(window.maestro.platform) directly,
removing async hook call and useMemo derive
- Update TabBar.tsx: same refactor as FileExplorerPanel.tsx
- Update test setup.ts: add platform: 'darwin' to global window.maestro mock
- Update FileExplorerPanel.test.tsx: add platform to maestro mock in beforeEach and
individual tests that override window.maestro; update regex to include File Manager
- Update TabBar.test.tsx: update reveal label regex assertions to include File Manager
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughExpose a synchronous Changes
Sequence DiagramsequenceDiagram
participant Main as Main Process
participant Preload as Preload Script
participant Renderer as Renderer Process
participant Component as UI Component
Main->>Preload: read process.platform
Preload->>Renderer: expose window.maestro.platform
Component->>Renderer: read window.maestro.platform
Component->>Component: call getRevealLabel(platform)
Component->>Component: render platform-specific "Reveal in ..." label
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
🚥 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)
Comment |
Greptile SummaryThis PR improves cross-platform user experience by replacing hardcoded "Reveal in Finder" labels with platform-aware labels that display "Reveal in Explorer" on Windows, "Reveal in File Manager" on Linux, and "Reveal in Finder" on macOS. Key changes:
Minor suggestion:
Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Main Process: preload/index.ts] -->|Expose process.platform| B[contextBridge]
B -->|window.maestro.platform| C[Renderer Process]
C --> D[platformUtils.ts]
D -->|getRevealLabel| E{Platform Check}
E -->|win32| F[Return 'Reveal in Explorer']
E -->|linux| G[Return 'Reveal in File Manager']
E -->|darwin/other| H[Return 'Reveal in Finder']
F --> I[FileExplorerPanel.tsx]
G --> I
H --> I
F --> J[TabBar.tsx]
G --> J
H --> J
I -->|Display label in context menu| K[User sees platform-specific text]
J -->|Display label in tab menu| K
Last reviewed commit: 00c3115 |
| ipcMain.handle('os:getPlatform', async () => { | ||
| return process.platform; | ||
| }); | ||
|
|
||
| // Get architecture (x64, arm64, etc.) | ||
| ipcMain.handle('os:getArch', async () => { | ||
| return process.arch; | ||
| }); |
There was a problem hiding this comment.
These IPC handlers (os:getPlatform and os:getArch) are unused since window.maestro.platform is now exposed synchronously via the preload script. Consider removing to avoid maintaining dead code.
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!
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/utils/platformUtils.ts (1)
1-6: Minor: JSDoc comment mentions "linux-unknown" which is misleading.The comment states
darwin / linux-unknown → "Reveal in Finder" (macOS)but "linux-unknown" is not macOS. Consider clarifying that the default case covers darwin (macOS) and any other/unknown platforms.📝 Suggested documentation fix
/** * Returns the platform-appropriate label for the "reveal in file manager" action. - * darwin / linux-unknown → "Reveal in Finder" (macOS) + * darwin (and other/unknown) → "Reveal in Finder" (macOS default) * win32 → "Reveal in Explorer" (Windows) * linux → "Reveal in File Manager" (Linux) */🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/renderer/utils/platformUtils.ts` around lines 1 - 6, Update the top JSDoc in platformUtils.ts to remove the misleading "linux-unknown" entry and clearly describe mappings: specify that darwin → "Reveal in Finder" (macOS), win32 → "Reveal in Explorer" (Windows), linux → "Reveal in File Manager" (Linux), and that any unknown/other platforms fall back to the default behavior (e.g., treat as darwin or use a generic label). Edit the comment block so it references "unknown/other" or "default" instead of "linux-unknown" and ensure the mapping lines and examples reflect the actual behavior implemented by the module.
🤖 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/renderer/utils/platformUtils.ts`:
- Around line 1-6: Update the top JSDoc in platformUtils.ts to remove the
misleading "linux-unknown" entry and clearly describe mappings: specify that
darwin → "Reveal in Finder" (macOS), win32 → "Reveal in Explorer" (Windows),
linux → "Reveal in File Manager" (Linux), and that any unknown/other platforms
fall back to the default behavior (e.g., treat as darwin or use a generic
label). Edit the comment block so it references "unknown/other" or "default"
instead of "linux-unknown" and ensure the mapping lines and examples reflect the
actual behavior implemented by the module.
…ment - Remove unused os:getPlatform and os:getArch IPC handlers (platform is now exposed synchronously via window.maestro.platform in preload) - Fix misleading JSDoc comment in platformUtils.ts (darwin / linux-unknown → darwin and other/unknown) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pedramamini
left a comment
There was a problem hiding this comment.
Nice, clean PR. Synchronous process.platform via preload is the right approach — no IPC round-trip for a constant. getRevealLabel() utility is clean.
One issue to fix:
In src/__tests__/renderer/components/FileExplorerPanel.test.tsx line 271, the beforeEach override:
(window as any).maestro = { platform: 'darwin' };This replaces the full mockMaestro from setup.ts (which already has platform: 'darwin') with a bare object. All other window.maestro.* properties are destroyed for every test in the describe block. It doesn't break existing tests because the ones needing fs/shell re-mock explicitly, but it's a landmine — any future test relying on the global mock will fail and the cause won't be obvious.
Fix: Just delete these two lines (the comment + the assignment). setup.ts already provides platform: 'darwin' in the global mock.
Everything else looks good.
The bare `(window as any).maestro = { platform: 'darwin' }` in beforeEach
replaced the full mockMaestro from setup.ts, destroying all other API
properties for every test in the block. setup.ts already provides
platform: 'darwin' in the global mock, so these two lines were redundant
and a future-test landmine.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This pull request improves platform awareness and user interface labeling for file manager actions in the application. The most significant changes include introducing a utility function to generate platform-specific labels (e.g., "Reveal in Finder", "Reveal in Explorer", "Reveal in File Manager"), updating UI components and tests to use this function, and exposing the platform string synchronously to the renderer process.
Platform-aware labeling and UI updates:
getRevealLabelinplatformUtils.tsto return the appropriate label for the "reveal in file manager" action based on the user's operating system.FileExplorerPanelandTabBarcomponents to usegetRevealLabel(window.maestro.platform)instead of hardcoding "Reveal in Finder", ensuring the label matches the user's platform. [1] [2] [3] [4]Platform detection and preload changes:
window.maestro.platformin the preload script, replacing the need for an asynchronous IPC call.platformproperty onwindow.maestro, ensuring consistent platform detection in test environments. [1] [2] [3] [4] [5] [6]Test updates for platform-aware labels:
FileExplorerPanel.test.tsxandTabBar.test.tsxto check for the correct platform-specific label using regular expressions, rather than hardcoding "Reveal in Finder". [1] [2] [3] [4] [5]IPC handler additions:
system.tsto retrieve the platform and architecture, though the platform is now exposed synchronously via preload.Summary by CodeRabbit
Bug Fixes
Tests