Conversation
📝 WalkthroughWalkthroughAdds file-based timestamped logging and startup observability, switches Windsurf port discovery from lsof to parsing Windsurf log files with tightened process filtering, and exposes a new public alias export Changes
Sequence DiagramsequenceDiagram
participant Plugin as Plugin
participant OS as OS / ProcessList
participant WindsurfLog as Windsurf Log
participant Proxy as Proxy Server
participant Creds as Credentials Store
Plugin->>OS: Query processes (filter for Windsurf)
OS-->>Plugin: Return Windsurf process info
Plugin->>WindsurfLog: Read most recent logs from WINDSURF_LOG_PATHS
WindsurfLog-->>Plugin: Return log entries
Note over Plugin: Parse "Language server listening on random port at <port>"
alt Port found
Plugin->>Creds: Extract port + CSRF/API key
Creds-->>Plugin: Return credentials
Plugin->>Proxy: Start/configure proxy with discovered port
Proxy-->>Plugin: Server started
Plugin->>WindsurfLog: Write startup/connection log entry
WindsurfLog-->>Plugin: Acknowledge write
else Port not found
Plugin->>Plugin: Log error about missing or unreadable logs
Plugin-->>Proxy: Continue with fallback/no port (non-blocking)
end
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes 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
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.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/plugin/auth.ts`:
- Around line 149-193: getPort currently uses findstr on Windows which returns
all matches and then applies output.match(), yielding the first port instead of
the most recent; change the Windows branch handling (where grepCmd is set for
'win32' and findstr is used) to capture the full execSync output, split it into
lines, filter out empty lines, sort the lines lexicographically (ISO timestamps
make this valid), pick the last line, and then run the existing regex (/Language
server listening on random port at (\d+)/) against that last line to extract and
return the port; keep the non-Windows path as-is and preserve existing error
handling and WindsurfError behavior in getPort.
- Around line 94-118: getLanguageServerProcess currently performs case-sensitive
checks for "/windsurf/" and "--ide_name windsurf", causing misses; update both
branches to perform case-insensitive matching: in the Unix branch, change the
ps/grep pipeline to use case-insensitive matching (e.g., add grep -i or use -i
with grep -E for "/windsurf/|--ide_name windsurf"); in the Windows branch,
lowercase the WMIC command output and perform includes checks against lowercase
literals (or use a case-insensitive regex) so checks in getLanguageServerProcess
align with WINDSURF_LOG_PATHS and ensure getCSRFToken/getWindsurfVersion detect
the process reliably; keep references to getLanguageServerPattern and preserve
existing timeout/encoding behavior.
🧹 Nitpick comments (1)
src/plugin.ts (1)
18-53: Consider platform‑specific log directories.
~/.local/shareis Linux‑centric; on macOS/Windows this ends up in a non‑standard location. A small helper keeps logs consistent with OS conventions.♻️ Suggested refactor
-const LOG_FILE = path.join(os.homedir(), '.local', 'share', 'opencode', 'windsurf-plugin.log'); +const LOG_FILE = (() => { + const home = os.homedir(); + switch (process.platform) { + case 'darwin': + return path.join(home, 'Library', 'Application Support', 'opencode', 'windsurf-plugin.log'); + case 'win32': + return path.join(home, 'AppData', 'Local', 'opencode', 'windsurf-plugin.log'); + default: + return path.join(home, '.local', 'share', 'opencode', 'windsurf-plugin.log'); + } +})();
Issue: Windsurf spawns language server on random port on startup on linux, here is my approach.
Note: Changes are Linux focused but contain logic for MacOS and Windows.
Changes:
Summary by CodeRabbit
Improvements
New Features
✏️ Tip: You can customize this high-level summary in your review settings.