feat: updated workspace manager with kortex-cli calls#1214
feat: updated workspace manager with kortex-cli calls#1214gastoner merged 1 commit intokortex-hub:mainfrom
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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.
🧹 Nitpick comments (2)
packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts (1)
48-51: Consider wrappingJSON.parsewith error context.If
kortex-clireturns non-JSON output (e.g., an error message or corrupted output),JSON.parsethrows a genericSyntaxErrorthat won't indicate which command failed or what the actual output was. This makes debugging CLI integration issues harder.♻️ Proposed improvement
private async execKortex<T>(args: string[]): Promise<T> { const result = await this.exec.exec('kortex-cli', ['workspace', ...args, '--output', 'json']); - return JSON.parse(result.stdout) as T; + try { + return JSON.parse(result.stdout) as T; + } catch (err) { + throw new Error(`Failed to parse kortex-cli output for "workspace ${args.join(' ')}": ${result.stdout}`); + } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts` around lines 48 - 51, The execKortex method directly JSON.parse's result.stdout which will throw an opaque SyntaxError if kortex-cli returns non-JSON; wrap the JSON.parse call in a try/catch inside execKortex (the function name to change) and on parse failure throw a new Error that includes the command invoked (kortex-cli + ['workspace', ...args]), the raw result.stdout and result.stderr and the original error message so callers can see which CLI invocation and output caused the parse failure; keep rethrowing (or throw the enriched Error) so callers still receive an exception.packages/main/src/plugin/agent-workspace/agent-workspace-manager.spec.ts (1)
26-26: Rename imported type to avoid shadowing the globalProxy.The static analysis tool flags this as shadowing the global
Proxy. While it's a type-only import that doesn't affect runtime, renaming it silences the linter and improves clarity.♻️ Suggested fix
-import type { Proxy } from '/@/plugin/proxy.js'; +import type { Proxy as ProxyService } from '/@/plugin/proxy.js';Then update line 60:
-} as unknown as Proxy; +} as unknown as ProxyService;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/main/src/plugin/agent-workspace/agent-workspace-manager.spec.ts` at line 26, Rename the type-only import named "Proxy" to avoid shadowing the global Proxy: change the import to use an alias (e.g., import type { Proxy as ProxyType } from '...') and then update all type annotations/usages that currently reference "Proxy" (for example the spec's variable/type at the test usage around the previous line 60) to use "ProxyType" instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/main/src/plugin/agent-workspace/agent-workspace-manager.spec.ts`:
- Line 26: Rename the type-only import named "Proxy" to avoid shadowing the
global Proxy: change the import to use an alias (e.g., import type { Proxy as
ProxyType } from '...') and then update all type annotations/usages that
currently reference "Proxy" (for example the spec's variable/type at the test
usage around the previous line 60) to use "ProxyType" instead.
In `@packages/main/src/plugin/agent-workspace/agent-workspace-manager.ts`:
- Around line 48-51: The execKortex method directly JSON.parse's result.stdout
which will throw an opaque SyntaxError if kortex-cli returns non-JSON; wrap the
JSON.parse call in a try/catch inside execKortex (the function name to change)
and on parse failure throw a new Error that includes the command invoked
(kortex-cli + ['workspace', ...args]), the raw result.stdout and result.stderr
and the original error message so callers can see which CLI invocation and
output caused the parse failure; keep rethrowing (or throw the enriched Error)
so callers still receive an exception.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 716dfc00-e36b-44f2-be36-f162ef65e4ad
📒 Files selected for processing (3)
packages/main/src/plugin/agent-workspace/agent-workspace-manager.spec.tspackages/main/src/plugin/agent-workspace/agent-workspace-manager.tspackages/main/src/plugin/agent-workspace/agent-workspace-mock-data.ts
💤 Files with no reviewable changes (1)
- packages/main/src/plugin/agent-workspace/agent-workspace-mock-data.ts
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
jeffmaury
left a comment
There was a problem hiding this comment.
LGTM but error while started is not reported but maybe unrelated to this PR will create an issue
This PR updates the workspace manger with kortex-cli calls
Closes #1124
You can tesst this by having the kortex-cli in PATH
You should be able to start/stop/delete and list the workspaces
Known issue: the calls like list etc are called only during the startup so there is no refreshing of the wokspaces (unless you e.g. delete one workspace => the list will get updated) - but this is a different issue