Skip to content

Update coder package for Pi 0.57 RPC UI compatibility#1158

Merged
jhaynie merged 3 commits intomainfrom
codex/pi-v0-57-rpc-ui-compat
Mar 10, 2026
Merged

Update coder package for Pi 0.57 RPC UI compatibility#1158
jhaynie merged 3 commits intomainfrom
codex/pi-v0-57-rpc-ui-compat

Conversation

@rblalock
Copy link
Member

@rblalock rblalock commented Mar 9, 2026

Summary

  • update @agentuity/coder Pi dependency ranges and refresh the workspace lockfile
  • normalize Hub tool metadata for Pi 0.57 tool registration changes
  • add a shared remote UI handler and native-remote context bridge so sandbox RPC UI requests work in both legacy and native remote TUI modes

Verification

  • bun run typecheck in packages/coder
  • bun test --tsconfig tsconfig.test.json test/remote-ui-handler.test.ts in packages/coder

Summary by CodeRabbit

  • New Features

    • Hub tool prompt guidelines now support both single string and array formats for more flexible configuration.
    • Enhanced native remote UI handling with improved context management and error resilience.
  • Chores

    • Updated peer and dev dependencies for pi-coding-agent and pi-tui to version ^0.57.1.

@agentuity-agent
Copy link

agentuity-agent bot commented Mar 9, 2026

The latest Agentuity deployment details. Learn more about Agentuity.

Project Deployment Preview Updated (UTC)
docs 🟢 Ready Preview Mar 09, 2026 8:53 PM

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Dependency Updates
package.json
Bumps @mariozechner/pi-coding-agent and @mariozechner/pi-tui from ^0.55.1 to ^0.57.1 in both peerDependencies and devDependencies.
Context Management
src/native-remote-ui-context.ts
Introduces new module managing shared ExtensionContext with wait-notify mechanism; exports setNativeRemoteExtensionContext(), getNativeRemoteExtensionContext(), and waitForNativeRemoteExtensionContext(timeoutMs).
Core Integration
src/index.ts
Integrates native remote UI by detecting NATIVE_REMOTE_ENV mode, conditionally propagating ExtensionContext to native handlers, and clearing context on shutdown; replaces large inline remote UI switch with single handleRemoteUiRequest() call.
Remote UI Handler
src/remote-ui-handler.ts
New module implementing handleRemoteUiRequest() function and REMOTE_FIRE_AND_FORGET_UI_METHODS constant; routes UI RPC requests to extension context with support for select, confirm, input, editor, notify, setStatus, setWidget, setTitle, and set_editor_text actions.
Remote TUI Implementation
src/remote-tui.ts
Replaces placeholder UI bridge with full implementation; fetches and waits for native extension context with timeout, delegates to handler, includes error handling, and manages context lifecycle on startup and cleanup.
Protocol Type Extension
src/protocol.ts
Extends HubToolDefinition.promptGuidelines type from string to string | string[] (remains optional).
Test Coverage
test/remote-ui-handler.test.ts
New test file with createUiContext helper and tests verifying handleRemoteUiRequest() maps blocking dialog and fire-and-forget methods to Pi UI APIs with correct return values and side effects.
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Mar 9, 2026

📦 Canary Packages Published

version: 1.0.38-2104951

Packages
Package Version URL
@agentuity/frontend 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-frontend-1.0.38-2104951.tgz
@agentuity/cli 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-cli-1.0.38-2104951.tgz
@agentuity/coder 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-coder-1.0.38-2104951.tgz
@agentuity/claude-code 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-claude-code-1.0.38-2104951.tgz
@agentuity/workbench 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-workbench-1.0.38-2104951.tgz
@agentuity/core 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-core-1.0.38-2104951.tgz
@agentuity/schema 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-schema-1.0.38-2104951.tgz
@agentuity/runtime 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-runtime-1.0.38-2104951.tgz
@agentuity/server 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-server-1.0.38-2104951.tgz
@agentuity/react 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-react-1.0.38-2104951.tgz
@agentuity/opencode 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-opencode-1.0.38-2104951.tgz
@agentuity/drizzle 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-drizzle-1.0.38-2104951.tgz
@agentuity/auth 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-auth-1.0.38-2104951.tgz
@agentuity/evals 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-evals-1.0.38-2104951.tgz
@agentuity/postgres 1.0.38-2104951 https://agentuity-sdk-objects.t3.storageapi.dev/npm/1.0.38-2104951/agentuity-postgres-1.0.38-2104951.tgz
Install

Add to your package.json:

{
  "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

@rblalock rblalock marked this pull request as ready for review March 9, 2026 20:38
@rblalock rblalock requested a review from jhaynie March 9, 2026 20:39
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
packages/coder/src/remote-ui-handler.ts (1)

23-30: Consider handling empty options array for select.

If options is empty after filtering, calling ui.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, and set_editor_text, but confirm, editor, notify, and setTitle are 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

📥 Commits

Reviewing files that changed from the base of the PR and between cdae827 and 2104951.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • packages/coder/package.json
  • packages/coder/src/index.ts
  • packages/coder/src/native-remote-ui-context.ts
  • packages/coder/src/protocol.ts
  • packages/coder/src/remote-tui.ts
  • packages/coder/src/remote-ui-handler.ts
  • packages/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.ts
  • packages/coder/src/native-remote-ui-context.ts
  • packages/coder/test/remote-ui-handler.test.ts
  • packages/coder/src/remote-ui-handler.ts
  • packages/coder/src/remote-tui.ts
  • packages/coder/src/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript Strict mode with ESNext target and bundler moduleResolution
Use StructuredError from @agentuity/core for error handling

Files:

  • packages/coder/src/protocol.ts
  • packages/coder/src/native-remote-ui-context.ts
  • packages/coder/test/remote-ui-handler.test.ts
  • packages/coder/src/remote-ui-handler.ts
  • packages/coder/src/remote-tui.ts
  • packages/coder/src/index.ts
**/test/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/test/**/*.{ts,tsx}: Place tests in test/ folder, never in src/ or __tests__/ directories
Import from ../src/ in test files
Use @agentuity/test-utils for 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.ts files

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.ts
  • packages/coder/src/native-remote-ui-context.ts
  • packages/coder/test/remote-ui-handler.test.ts
  • packages/coder/src/remote-ui-handler.ts
  • packages/coder/src/remote-tui.ts
  • packages/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 string to string | string[] is backward compatible. The consuming code in index.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 createUiContext helper provides a clean mock implementation that tracks method calls. Test file placement in test/ 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 promptGuidelines from string | string[] to string[] aligns with the type change in protocol.ts.


1360-1362: LGTM!

The native remote extension context is correctly set during session_start when 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 handleRemoteUiRequest call. The null guard for footerCtx prevents 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 the finally block, 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 waitForNativeRemoteExtensionContext with timer cleanup
  • Setting context to null intentionally resolves waiters immediately, signaling context unavailability
packages/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.1 and @mariozechner/pi-tui@0.57.1 exist on npm and are consistently pinned across peerDependencies and devDependencies.

@jhaynie jhaynie merged commit 0525924 into main Mar 10, 2026
18 checks passed
@jhaynie jhaynie deleted the codex/pi-v0-57-rpc-ui-compat branch March 10, 2026 17:26
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