-
Notifications
You must be signed in to change notification settings - Fork 0
[Review] feat: AI code completion & intellisense for python editor #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: base-for-pr-1263
Are you sure you want to change the base?
Conversation
421e788 to
746f520
Compare
Add AI code completion and Python IntelliSense to the Builder editor by starting
|
| const uri = model.uri.toString(); | ||
| const languageId = model.getLanguageId(); | ||
|
|
||
| let timeoutId: ReturnType<typeof setTimeout> | null = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Low
lsp/lspModelSync.ts:38 Consider tracking whether didOpen was sent before sending didClose. If dispose() is called before the 100ms timeout fires, didClose is sent for a document that was never opened, which violates the LSP specification.
🚀 Want me to fix this? Reply ex: "fix it for me".
| // Intercept: @codingame/monaco-vscode-api/vscode/vs/... | ||
| // Transform to absolute path in node_modules | ||
| if (source.startsWith("@codingame/monaco-vscode-api/vscode/vs/")) { | ||
| // Extract the path after /vscode/vs/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium
ui/vite.config.ts:18 If the import source contains a query string (e.g., ?worker), appending .js creates an invalid path like foo?worker.js. Consider stripping query parameters before constructing the path.
🚀 Want me to fix this? Reply ex: "fix it for me".
| port 0 (letting the OS assign a port) would require parsing pylsp's output | ||
| to discover the assigned port, adding complexity for minimal benefit. | ||
| """ | ||
| for port in range(start_port, end_port): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Low
writer/lsp_manager.py:48 range(start_port, end_port) excludes end_port, so port 5099 is never checked despite the error message implying it should be. Consider using end_port + 1.
| for port in range(start_port, end_port): | |
| for port in range(start_port, end_port + 1): |
🚀 Want me to fix this? Reply ex: "fix it for me".
| logger.error("LSP WebSocket error:", error); | ||
| }; | ||
|
|
||
| ws.onclose = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium
lsp/lspClient.ts:206 Race condition: onclose handler accesses global state without verifying the closing socket matches the current one. If stopLSPClient then initializeLSPClient are called quickly, the old socket's onclose can corrupt the new session's state. Consider capturing ws reference and checking webSocket === ws before modifying globals.
- ws.onclose = () => {
+ ws.onclose = () => {
+ // Guard against stale handler from previous connection
+ if (webSocket !== ws) return;
+🚀 Want me to fix this? Reply ex: "fix it for me".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix it for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on the fix to add a guard against the race condition in the onclose handler. The changes will be pushed to a new branch and automatically merged when checks pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a guard at the beginning of the ws.onclose handler in initWebSocketAndStartClient that checks if the global webSocket matches the current ws instance. If they don't match, the handler returns early without modifying any global state, preventing race conditions where a quickly closed old socket could corrupt a new session's state.
Commit cc68ac0 pushed to #5. When checks pass, it will merge automatically into this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>
Recreated from writer#1263 for Macroscope review.
Original PR: writer#1263 by @bybash
Status: open (open)
Recreated using direct PR head fetch - exact current state preserved.
Original PR: writer#1263