Skip to content

feat: add Windows support#44

Open
minchenlee wants to merge 14 commits intomainfrom
feature/windows-support
Open

feat: add Windows support#44
minchenlee wants to merge 14 commits intomainfrom
feature/windows-support

Conversation

@minchenlee
Copy link
Owner

Summary

Add Windows support to c9watch, building on the work from PR #1 by @ntuee10 (closed). This is a fresh implementation on current main (v0.4.0) that addresses all 6 review issues from the original PR.

  • Add Windows-specific session actions: process tree walking (PowerShell CIM), window activation (Win32 EnumWindows), app CLI detection, and taskkill-based termination
  • Add Windows CI job and release pipeline (x64 NSIS + MSI)
  • Add install.ps1 PowerShell installer (Windows 10 1803+, x64)
  • Update session detector for Windows path encoding and claude.exe matching
  • Update README with Windows install/run docs and terminal/IDE compatibility table
  • Fix reveal_in_file_manager to work cross-platform (was macOS-only)

Issues addressed from PR #1 review

Issue Resolution
WMIC deprecated Use PowerShell Get-CimInstance with JSON output
Win10/11 requirement inconsistency Check build 17134 (Win10 1803), not 22000
ARM64 mismatch x64 only — no ARM64 detection in installer
No Windows tests 4 new cross-platform tests for .exe suffix, backslash paths, terminals, path encoding
PowerShell+C# perf overhead Use Win32 EnumWindows/SetForegroundWindow via windows-sys
Fragile CSV parsing JSON output from CIM, parsed with serde_json

Test plan

  • All 104 Rust tests pass (macOS)
  • Windows CI check passes
  • macOS CI check passes (no regressions)
  • install.ps1 downloads and runs installer on Windows
  • Session detection works on Windows

Closes #1 (supersedes)
cc @jrgcubano @ntuee10

🤖 Generated with Claude Code

Co-Authored-By: Eric ntuee10@users.noreply.github.com

@jrgcubano
Copy link

@minchenlee Woo Thanks for doing this 🥇 . How I can test it locally?

@minchenlee
Copy link
Owner Author

minchenlee commented Mar 3, 2026

Hey @jrgcubano! Thanks for wanting to test it! 🙌

There's a pre-release with pre-built Windows installers you can grab directly:

  1. Go to the v0.4.1-windows-test release
  2. Download either:
    • c9watch_0.4.0_x64-setup.exe (NSIS installer)
    • c9watch_0.4.0_x64_en-US.msi (MSI installer)
  3. Run the installer and let me know how it goes!

If you'd prefer to build from source instead:

git clone https://github.com/minchenlee/c9watch.git
cd c9watch
git checkout feature/windows-support
npm install
npx tauri dev

(Requires Rust, Node.js 20+, and the Tauri prerequisites for Windows)

Let me know if you hit any issues!

@jrgcubano
Copy link

jrgcubano commented Mar 3, 2026

@minchenlee Thanks for this.

It doesn't seem to be detecting my active sessions or any new ones... I installed the app and it detected one, but not the other four I created in different projects... Then I uninstalled (forcing it to remove the app data too) and reinstalled it, and it still doesn't show any. I am using Powershell core from Windows Terminal.

image

Although I might be missing something... It works sometimes by restarting the command line windows/panes...

minchenlee pushed a commit that referenced this pull request Mar 4, 2026
Addresses session detection issues reported in PR #44 where sessions
were intermittently not detected on Windows. Three root causes fixed:

1. Process detection now checks exe path and command-line args in
   addition to process name, catching npm-installed Claude running
   as node.exe instead of claude.exe.

2. CWD refresh changed from OnlyIfNotSet to Always, ensuring retries
   when sysinfo's PEB-based CWD read initially fails on Windows.

3. Added temporal fallback matching for processes without CWD - when
   sysinfo can't read a process's working directory (common on Windows
   due to ReadProcessMemory permission requirements), sessions are
   matched by comparing process start times with session file
   modification times.

https://claude.ai/code/session_01UjgMVHSLLAuUFzT9h9sHwg
@jrgcubano
Copy link

@minchenlee Any luck fixing the issue?

@minchenlee
Copy link
Owner Author

minchenlee commented Mar 4, 2026

Thanks for testing and reporting this! I found a bug in how c9watch encodes Windows paths for session matching — C:\ was being encoded as C- instead of C--, so the folder names never matched Claude Code's actual directory structure.

I've included a fix in the updated v0.4.1-windows-test pre-release (new build should be ready in ~15 minutes). Could you try it again and let me know if more sessions are detected?

If you still see missing sessions after the update, let me know how many sessions you have open vs how many c9watch shows — that will help me narrow down whether there's a second issue at play.

I don't have a Windows machine to test on, so I'm really relying on you here for validation — any feedback is hugely appreciated!

@jrgcubano
Copy link

jrgcubano commented Mar 4, 2026

@minchenlee Thanks for looking at this.

Currently I am working on two projects. It shows one, but not the other.

image

And the one missing is in the History:

image

I restarted the terminal and resumed the session, but it still doesn't appear.

And then the menu in the system try appears very far out of place:

image

@minchenlee
Copy link
Owner Author

minchenlee commented Mar 5, 2026

@jrgcubano Thanks for the detailed report and screenshots! I looked into a Windows fork and some Claude Code GitHub issues to better understand what's happening.

I found two more things that could explain the missing second session:

  1. Trailing path separator — Windows sysinfo sometimes returns CWD with a trailing \ (e.g., C:\Users\foo\project\), which produces a different encoded string than Claude's folder name. Now trimming these before matching.

  2. Claude Desktop interference — If you have Claude Desktop installed, its Electron subprocesses all contain "claude" in the name and were being picked up as Claude Code sessions, potentially blocking real CLI sessions from matching. Now filtering those out.

I've updated the v0.4.1-windows-test pre-release — the new build should be ready in ~15 minutes.

That said, I want to be upfront — since I don't have a Windows machine, I'm fixing these based on research rather than hands-on testing, so there's a chance the second session might still not show up. If that's the case, it would be super helpful if you could share the folder names under %USERPROFILE%\.claude\projects\ — that way I can compare them against what c9watch is encoding and pinpoint the exact mismatch.

Also noted the system tray positioning issue — I'll look into that separately. Really appreciate your patience and help with testing!

@jrgcubano
Copy link

@minchenlee It's working fine now 🥇. I'll keep an eye on it throughout the day and let you know next week if I find anything unusual. Thanks

@minchenlee minchenlee force-pushed the feature/windows-support branch from 4b8a1ad to 2efaea2 Compare March 14, 2026 08:29
@jrgcubano
Copy link

@minchenlee Hello. When do you plan to merge the code... to install the official version?

Thanks in advance.

@minchenlee minchenlee force-pushed the feature/windows-support branch from 1b54613 to 676ca16 Compare March 21, 2026 12:35
@minchenlee
Copy link
Owner Author

Hey @jrgcubano! I've rebased this branch onto latest main (v0.5.0) — a lot has landed since your last test on March 6, including new features like NeedsAttention status detection, session metadata display, token distance visualizer, and updated pricing.

There's a new pre-release with updated Windows installers you can grab:

  1. Go to the v0.5.1-windows-test release
  2. Download either:
    • c9watch_0.5.0_x64-setup.exe (NSIS installer)
    • c9watch_0.5.0_x64_en-US.msi (MSI installer)

Would love to get a quick sanity check on:

  1. Session detection — do your active Claude Code sessions show up?
  2. Status display — do statuses (Working, Idle, Needs Attention) update correctly?
  3. Open session — does clicking "Open" focus the correct terminal/IDE window?

No rush at all — just want to make sure nothing broke with the rebase before merging. Really appreciate your help with testing!

minchenlee and others added 14 commits March 22, 2026 11:38
- Create install.ps1 for Windows (PowerShell, x64 only)
- Require Windows 10 1803+ (build 17134), not Windows 11 only
- Run installer interactively (not silently) for user consent
- Update install.sh to redirect Windows Git Bash users to install.ps1

Co-Authored-By: Eric <ntuee10@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add Windows-specific implementations for process tree walking,
window activation, app CLI detection, and session termination.

- Use PowerShell Get-CimInstance + JSON for process tree walking (not deprecated WMIC)
- Use windows-sys Win32 APIs for window activation (not slow PowerShell+C#)
- Add Windows terminal/IDE detection (Windows Terminal, PowerShell, CMD, etc.)
- Add taskkill-based session termination with graceful-then-force strategy

Co-Authored-By: Eric <ntuee10@users.noreply.github.com>
- Add check-windows CI job mirroring macOS checks
- Add build-windows release job (x64 NSIS + MSI)
- Add Windows updater signature to release manifest
- Configure NSIS and MSI bundle targets in tauri.conf.json

Co-Authored-By: Eric <ntuee10@users.noreply.github.com>
…ames

- Handle Windows backslash and colon in path encoding for session matching
- Match claude.exe process name on Windows alongside claude on Unix
- Case-insensitive process name comparison for cross-platform reliability

Co-Authored-By: Eric <ntuee10@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update description to mention Windows alongside macOS
- Add Windows install section with PowerShell installer
- Add supported terminals/IDEs compatibility table
- Add platform-specific implementation details
- Update tech stack and features list

Co-Authored-By: Eric <ntuee10@users.noreply.github.com>
- Test .exe suffix stripping for Windows process names
- Test Windows backslash path parsing in get_app_name
- Test Windows terminal process name matching
- Test cross-platform path encoding logic (backslash + colon handling)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace FindWindowW (exact title match, effectively dead code) with
  EnumWindows + substring matching for reliable window activation
- Reduce path encoding from 4 chained .replace() to 2 using char arrays
- Make JSON parse failure in Windows find_parent_app a graceful loop-break
- Fix reveal_in_file_manager to use platform-specific commands (was macOS-only)
- Remove unused windows-sys Cargo features (Threading, ToolHelp)
- Simplify redundant is_claude exact-match arms in detector
- Use direct match in Windows get_app_cli to avoid allocating all paths
- Fix path encoding test to not duplicate the real encoding logic

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…back

windows-sys 0.59 defines HWND as *mut c_void, not isize. The previous
code used isize which compiled on macOS (cfg-gated) but failed on
actual Windows CI. Use HWND type directly and null_mut() for init.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adding nsis/msi to tauri.conf.json bundle targets caused macOS
DMG bundling to fail. Use --bundles CLI flag to explicitly set
platform-appropriate targets in each build job.
Claude Code encodes project directory names by replacing every
non-alphanumeric character with a dash. c9watch was only replacing
\, /, _ and removing colons, causing C:\ to encode as C- instead
of C-- (colon→dash + backslash→dash). This broke Method 2 (encoded
path fallback) matching on Windows.

- Extract encode_path_for_matching() as shared function
- Add diagnostic log when process CWD is unavailable
- Add UNC path test case

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two fixes for Windows session detection:

1. Trim trailing path separators before encoding — Windows sysinfo
   often returns CWD with trailing '\', causing encoded mismatch.

2. Filter out Claude Desktop (Electron) subprocesses on Windows by
   checking for --type= flags and AnthropicClaude in exe path.
   Without this, Desktop processes consume session matching slots
   before real CLI sessions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On macOS, the tab bar needs 80px left padding to clear the traffic light
buttons (titleBarStyle: Overlay). On Windows, overlay controls are on the
right side, so the padding creates an unnecessary gap. Platform is now
detected at runtime and the 80px padding only applies on macOS.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The drag-dot indicator (⠿ ⠿ ⠿) is only needed on macOS where the title
bar is hidden via titleBarStyle: Overlay. On Windows the native title bar
is still visible, making the drag dots redundant.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
test_log_and_retrieve was missing clear_buffer() at the start, so when
run in parallel with test_ring_buffer_capacity (which writes 550 entries
to a 500-entry ring buffer), the test entries could be evicted before
assertions ran. This caused flaky failures on Windows CI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@minchenlee minchenlee force-pushed the feature/windows-support branch from 676ca16 to fea1fdc Compare March 22, 2026 03:40
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.

2 participants