Update coder package for Pi 0.57 RPC UI compatibility#1158
Conversation
📝 WalkthroughWalkthroughThis PR introduces native remote UI integration to the coder package by adding a context management system, a dedicated remote UI handler supporting multiple UI actions, and integrating these into the main entry point and remote TUI. Dependencies are bumped and protocol types extended for promptGuidelines flexibility. Changes
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
📦 Canary Packages Publishedversion: PackagesInstallAdd to your {
"dependencies": {
"@agentuity/frontend": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-frontend-1.0.38-2104951.tgz",
"@agentuity/cli": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-cli-1.0.38-2104951.tgz",
"@agentuity/coder": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-coder-1.0.38-2104951.tgz",
"@agentuity/claude-code": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-claude-code-1.0.38-2104951.tgz",
"@agentuity/workbench": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-workbench-1.0.38-2104951.tgz",
"@agentuity/core": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-core-1.0.38-2104951.tgz",
"@agentuity/schema": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-schema-1.0.38-2104951.tgz",
"@agentuity/runtime": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-runtime-1.0.38-2104951.tgz",
"@agentuity/server": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-server-1.0.38-2104951.tgz",
"@agentuity/react": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-react-1.0.38-2104951.tgz",
"@agentuity/opencode": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-opencode-1.0.38-2104951.tgz",
"@agentuity/drizzle": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-drizzle-1.0.38-2104951.tgz",
"@agentuity/auth": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-auth-1.0.38-2104951.tgz",
"@agentuity/evals": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-evals-1.0.38-2104951.tgz",
"@agentuity/postgres": "https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-postgres-1.0.38-2104951.tgz"
}
}Or install directly: bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-frontend-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-cli-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-coder-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-claude-code-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-workbench-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-core-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-schema-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-runtime-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-server-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-react-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-opencode-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-drizzle-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-auth-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-evals-1.0.38-2104951.tgz
bun add https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-postgres-1.0.38-2104951.tgz |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/coder/src/remote-ui-handler.ts (1)
23-30: Consider handling empty options array for select.If
optionsis empty after filtering, callingui.select(title, [])may produce a confusing UI. Consider adding a guard or returning null early.💡 Optional enhancement
case 'select': { const options = Array.isArray(request.params.options) ? request.params.options.filter( (option): option is string => typeof option === 'string' ) : []; + if (options.length === 0) { + return null; + } const title = (request.params.title as string) ?? 'Select'; return (await ui.select(title, options)) ?? null; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/coder/src/remote-ui-handler.ts` around lines 23 - 30, The select branch currently filters request.params.options into the local options array and always calls ui.select(title, options); if options is empty this can create a confusing UI—update the 'select' case (the options variable and the call to ui.select) to guard for an empty options array and return null (or an appropriate no-selection response) immediately instead of invoking ui.select with an empty list; preserve the existing title logic (title variable) when deciding the early return.packages/coder/test/remote-ui-handler.test.ts (1)
49-111: Consider adding test coverage for remaining UI methods.The tests cover
select,input,setStatus,setWidget, andset_editor_text, butconfirm,editor,notify, andsetTitleare not directly tested. Consider adding test cases for completeness.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/coder/test/remote-ui-handler.test.ts` around lines 49 - 111, Add unit tests that use createUiContext and handleRemoteUiRequest to cover the remaining UI methods: call handleRemoteUiRequest with method 'confirm' (assert returned boolean and that calls contains { method: 'confirm', args: [...] }), with method 'editor' (assert returned editor result and that calls contains { method: 'editor', args: [...] }), with method 'notify' (assert no return and that calls contains { method: 'notify', args: [title, body or options] }), and with method 'setTitle' (assert no return and that calls contains { method: 'setTitle', args: [title] }); place these alongside the existing tests so they use the same ctx/calls from createUiContext and match the same call-shape convention used elsewhere.
🤖 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/coder/src/remote-ui-handler.ts`:
- Around line 23-30: The select branch currently filters request.params.options
into the local options array and always calls ui.select(title, options); if
options is empty this can create a confusing UI—update the 'select' case (the
options variable and the call to ui.select) to guard for an empty options array
and return null (or an appropriate no-selection response) immediately instead of
invoking ui.select with an empty list; preserve the existing title logic (title
variable) when deciding the early return.
In `@packages/coder/test/remote-ui-handler.test.ts`:
- Around line 49-111: Add unit tests that use createUiContext and
handleRemoteUiRequest to cover the remaining UI methods: call
handleRemoteUiRequest with method 'confirm' (assert returned boolean and that
calls contains { method: 'confirm', args: [...] }), with method 'editor' (assert
returned editor result and that calls contains { method: 'editor', args: [...]
}), with method 'notify' (assert no return and that calls contains { method:
'notify', args: [title, body or options] }), and with method 'setTitle' (assert
no return and that calls contains { method: 'setTitle', args: [title] }); place
these alongside the existing tests so they use the same ctx/calls from
createUiContext and match the same call-shape convention used elsewhere.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1cc30054-e04e-4ba2-bbf6-1c239460657b
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
packages/coder/package.jsonpackages/coder/src/index.tspackages/coder/src/native-remote-ui-context.tspackages/coder/src/protocol.tspackages/coder/src/remote-tui.tspackages/coder/src/remote-ui-handler.tspackages/coder/test/remote-ui-handler.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Agentuity Deployment
- GitHub Check: Build
- GitHub Check: Sandbox CLI Tests
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use Biome as code formatter with tabs (width 3), single quotes, semicolons, lineWidth 100, and trailingCommas es5
Files:
packages/coder/src/protocol.tspackages/coder/src/native-remote-ui-context.tspackages/coder/test/remote-ui-handler.test.tspackages/coder/src/remote-ui-handler.tspackages/coder/src/remote-tui.tspackages/coder/src/index.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript Strict mode with ESNext target and bundler moduleResolution
UseStructuredErrorfrom@agentuity/corefor error handling
Files:
packages/coder/src/protocol.tspackages/coder/src/native-remote-ui-context.tspackages/coder/test/remote-ui-handler.test.tspackages/coder/src/remote-ui-handler.tspackages/coder/src/remote-tui.tspackages/coder/src/index.ts
**/test/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/test/**/*.{ts,tsx}: Place tests intest/folder, never insrc/or__tests__/directories
Import from../src/in test files
Use@agentuity/test-utilsfor mocks in tests
Files:
packages/coder/test/remote-ui-handler.test.ts
**/index.ts
📄 CodeRabbit inference engine (AGENTS.md)
Use named exports from package
index.tsfiles
Files:
packages/coder/src/index.ts
🧠 Learnings (2)
📚 Learning: 2025-12-21T00:31:41.858Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 274
File: packages/cli/src/cmd/build/vite/server-bundler.ts:12-41
Timestamp: 2025-12-21T00:31:41.858Z
Learning: In Bun runtime, BuildMessage and ResolveMessage are global types and are not exported from the bun module. Do not import { BuildMessage } from 'bun' or similar; these types are available globally and should be used without import. This applies to all TypeScript files that target the Bun runtime within the repository.
Applied to files:
packages/coder/src/protocol.tspackages/coder/src/native-remote-ui-context.tspackages/coder/test/remote-ui-handler.test.tspackages/coder/src/remote-ui-handler.tspackages/coder/src/remote-tui.tspackages/coder/src/index.ts
📚 Learning: 2026-02-21T02:05:57.982Z
Learnt from: jhaynie
Repo: agentuity/sdk PR: 1010
File: packages/drizzle/test/proxy.test.ts:594-603
Timestamp: 2026-02-21T02:05:57.982Z
Learning: Do not rely on StructuredError from agentuity/core in test files or simple error handling paths. In tests and straightforward error handling, use plain Error objects to represent failures, reserving StructuredError for more complex error scenarios in application logic.
Applied to files:
packages/coder/test/remote-ui-handler.test.ts
🧬 Code graph analysis (3)
packages/coder/test/remote-ui-handler.test.ts (1)
packages/coder/src/remote-ui-handler.ts (1)
handleRemoteUiRequest(12-86)
packages/coder/src/remote-ui-handler.ts (1)
packages/coder/src/remote-session.ts (1)
RpcUiRequest(35-39)
packages/coder/src/remote-tui.ts (2)
packages/coder/src/native-remote-ui-context.ts (3)
setNativeRemoteExtensionContext(8-14)getNativeRemoteExtensionContext(16-18)waitForNativeRemoteExtensionContext(20-41)packages/coder/src/remote-ui-handler.ts (2)
REMOTE_FIRE_AND_FORGET_UI_METHODS(4-10)handleRemoteUiRequest(12-86)
🔇 Additional comments (15)
packages/coder/src/protocol.ts (1)
9-9: LGTM!The type widening from
stringtostring | string[]is backward compatible. The consuming code inindex.ts(lines 579-585) already normalizes this to an array, handling both cases correctly.packages/coder/test/remote-ui-handler.test.ts (1)
1-47: LGTM! Test helper and mock setup are well-structured.The
createUiContexthelper provides a clean mock implementation that tracks method calls. Test file placement intest/folder and import from../src/follow coding guidelines.packages/coder/src/index.ts (5)
21-22: LGTM!Clean imports for the new native remote UI context and handler modules.
579-585: LGTM!Proper normalization of
promptGuidelinesfromstring | string[]tostring[]aligns with the type change inprotocol.ts.
1360-1362: LGTM!The native remote extension context is correctly set during
session_startwhen in native remote mode with a remote session, enabling the UI handler to access the context.
1493-1496: LGTM!Good refactoring that replaces the inline switch with a centralized
handleRemoteUiRequestcall. The null guard forfooterCtxprevents potential null reference errors.
1518-1520: LGTM!Properly clears the native remote extension context on session shutdown, completing the lifecycle management.
packages/coder/src/remote-tui.ts (4)
36-44: LGTM!Clean imports for the native remote UI context management and handler modules.
72-72: LGTM!Clearing the context at startup ensures a clean state before the remote TUI session begins.
469-487: LGTM!Robust UI handler implementation with:
- Synchronous context check before async wait
- 10-second timeout for context availability
- Proper error handling with logging
- Fire-and-forget semantics respected in both timeout and error paths
752-767: LGTM!Context cleanup is properly handled in both the signal handler (
cleanup) and thefinallyblock, ensuring the context is cleared regardless of how the TUI exits.packages/coder/src/native-remote-ui-context.ts (1)
1-41: LGTM!Well-implemented wait/notify pattern for sharing the
ExtensionContext:
- Synchronous notification to all waiters when context is set
- Proper cleanup of waiters after notification (prevents memory leaks)
- Timeout handling in
waitForNativeRemoteExtensionContextwith timer cleanup- Setting context to
nullintentionally resolves waiters immediately, signaling context unavailabilitypackages/coder/src/remote-ui-handler.ts (2)
4-10: LGTM!Clear definition of fire-and-forget methods that don't require a response value.
12-85: LGTM!Comprehensive UI request handler with:
- Proper guard for no-UI context (Line 16-18)
- Defensive filtering of options arrays (Lines 24-28, 64-66)
- Consistent null fallback for cancelled dialogs (Lines 30, 42, 49)
- Strict validation of widget placement values (Lines 71-73)
- Unknown methods return null for safe handling
packages/coder/package.json (1)
28-34: Dependency versions are valid. Both@mariozechner/pi-coding-agent@0.57.1and@mariozechner/pi-tui@0.57.1exist on npm and are consistently pinned across peerDependencies and devDependencies.
Summary
@agentuity/coderPi dependency ranges and refresh the workspace lockfileVerification
bun run typecheckinpackages/coderbun test --tsconfig tsconfig.test.json test/remote-ui-handler.test.tsinpackages/coderSummary by CodeRabbit
New Features
Chores