Repository navigation
Conversation
Greptile SummaryThe PR forwards Pi tool-approval events into Orca and normalizes them as blocked so approval waits become visible as requiring attention.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/main/pi/agent-status-handler-source.ts | Adds forwarding for Pi approval-request events and their identifying metadata. |
| src/shared/agent-hook-listener/providers/pi-family-events.ts | Normalizes Pi approval requests to the shared blocked state. |
| src/shared/agent-hook-listener/providers/pi-family-tool-fields.ts | Includes approval requests in Pi tool-field snapshot extraction. |
| src/main/pi/agent-status-extension-source.test.ts | Verifies the generated extension forwards approval-request metadata. |
| src/shared/agent-hook-listener-pi-compatible.test.ts | Verifies approval requests normalize to blocked with the expected tool details. |
Sequence Diagram
sequenceDiagram
participant Pi as Pi agent
participant Ext as Status extension
participant Listener as Orca hook listener
participant UI as Status UI
Pi->>Ext: tool_approval_requested
Ext->>Listener: tool name, call ID, reason, mode
Listener->>Listener: Normalize state as blocked
Listener->>UI: Publish action-required status
Reviews (2): Last reviewed commit: "fix: surface Pi tool approval requests a..." | Re-trigger Greptile
|
Ownership update: inspection of the affected |
bab6dcb to
eed7b6a
Compare
|
The adapter fixture has been aligned with the actual OMP approval-event shape observed during runtime inspection: |
📝 WalkthroughWalkthroughPi Merge Risk: 🟡 Moderate · up to This PR makes Pi dangerous-tool approval waits visible as blocked, but approval cards can show stale input for repeated same-tool requests, blocked updates can be superseded before consumers see them, and denial handling may leave the pane blocked. These bounded correctness and security risks should be fixed or explicitly accepted before merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the change, motivation, issue scope, and targeted tests. However, it does not follow the repository template and omits required sections such as ELI5, What Changed, Why, Visual Proof or an explicit N/A explanation, AI Disclosure, Review, Agent skill upstream boundary, Notes, and the Checklist. Resolution Update the description to use the required template headings. Add the missing required information, provide the linked issue in the Linked Issue section, document visual proof or state N/A with a reason, complete the testing and checklist items, and address the remaining review sections.
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
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 19be8b37-671f-4e26-8c23-8c577894bf5d
📥 Commits
Reviewing files that changed from the base of the PR and between a1f198b and bab6dcb0593004f906a2748ac0339faf5df34a0f.
📒 Files selected for processing (5)
src/main/pi/agent-status-extension-source.test.tssrc/main/pi/agent-status-handler-source.tssrc/shared/agent-hook-listener-pi-compatible.test.tssrc/shared/agent-hook-listener/providers/pi-family-events.tssrc/shared/agent-hook-listener/providers/pi-family-tool-fields.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| @@ -95,6 +95,17 @@ export function getPiAgentStatusHandlerSourceLines(kind: PiAgentKind): string[] | |||
| ' })', | |||
| ' })', | |||
| '', | |||
| ' // Pi pauses here while waiting for user approval; report it separately', | |||
| ' // so Orca can show action-required instead of leaving the pane working.', | |||
| ` pi.on('tool_approval_requested', (event${ctxParam}) => {`, | |||
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '=== repository convention files ==='
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print | sort
printf '%s\n' '=== applicable convention and architecture excerpts ==='
for f in /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/{conventions,architecture,learnings}/*.md; do
[ -f "$f" ] || continue
printf '\n--- %s ---\n' "$f"
head -80 "$f"
done
printf '%s\n' '=== changed file diff ==='
git diff --unified=30 -- src/main/pi/agent-status-handler-source.ts
printf '%s\n' '=== changed file context ==='
cat -n src/main/pi/agent-status-handler-source.ts | sed -n '1,180p'
printf '%s\n' '=== dependency manifests and Pi references ==='
find . -maxdepth 3 -type f \( -name 'package.json' -o -name 'package-lock.json' -o -name 'pnpm-lock.yaml' -o -name 'yarn.lock' -o -name 'bun.lockb' \) -print
rg -n --glob 'package.json' --glob '*lock*' '(^|[^A-Za-z])pi([^A-Za-z]|$)|`@mariozechner`|tool_approval_requested|tool_approval_resolved' .
printf '%s\n' '=== directly related definitions and consumers ==='
rg -n -C 5 'tool_approval_requested|tool_approval_resolved|toolUseId|tool_use_id|toolCallId|tool_call_id|agent-status-handler-source' srcRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '=== handler source ==='
cat -n src/main/pi/agent-status-handler-source.ts | sed -n '50,145p'
printf '%s\n' '=== repository state ==='
git status --short -- src/main/pi/agent-status-handler-source.ts
git diff --stat -- src/main/pi/agent-status-handler-source.ts
printf '%s\n' '=== Pi dependency declarations ==='
rg -n --glob 'package.json' --glob 'package-lock.json' --glob 'pnpm-lock.yaml' --glob 'yarn.lock' --glob 'bun.lockb' \
'(`@mariozechner`|pi-coding-agent|pi-agent|agent.*pi|pi.*agent)' . | head -200
printf '%s\n' '=== approval event references ==='
rg -n -C 8 --glob '!node_modules/**' \
'tool_approval_requested|tool_approval_resolved|tool_call_id|toolCallId|tool_use_id|toolUseId' \
src package.json pnpm-lock.yaml package-lock.json yarn.lock 2>/dev/null | head -300
printf '%s\n' '=== relevant test files ==='
rg -l --glob '*.{test,spec}.{ts,tsx,js,mjs}' \
'agent-status-handler-source|tool_approval_requested|tool_approval_resolved|approval' src tests | head -100Repository: stablyai/orca
Length of output: 36858
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '=== top-level files and manifests ==='
find . -maxdepth 2 -type f \( -name 'package.json' -o -name 'pnpm-lock.yaml' -o -name 'yarn.lock' -o -name 'package-lock.json' -o -name 'bun.lockb' \) -print | sort
git ls-files | head -80
printf '%s\n' '=== Pi-related tracked files ==='
git ls-files | rg '(^|/)(pi|.*pi.*|.*agent.*status.*|.*hook.*)' | head -200
printf '%s\n' '=== extension test harness ==='
cat -n src/main/pi/agent-status-extension-source.test.ts | sed -n '1,180p'
cat -n src/main/pi/agent-status-extension-source.test.ts | sed -n '640,710p'
printf '%s\n' '=== Pi installation and runtime integration ==='
rg -n -C 8 --glob '*.ts' --glob '*.tsx' --glob '*.json' \
'pi-coding-agent|`@mariozechner`|agent-status-handler|extension.*source|install.*extension|PiAgentKind|tool_approval_requested' \
src config scripts .github 2>/dev/null | head -400Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '=== root package dependency keys and Pi-related scripts ==='
jq '{dependencies,devDependencies,optionalDependencies,peerDependencies,scripts}' package.json
rg -n -i 'pi|omp|prime' package.json pnpm-lock.yaml | head -250
printf '%s\n' '=== Pi command/configuration references ==='
rg -n -i -C 5 --glob '*.ts' --glob '*.tsx' --glob '*.json' --glob '*.mjs' \
'PI_CODING_AGENT|pi-agent|pi-coding|omp|prime-agent|agent.*command|command.*agent' \
src config scripts package.json | head -400
printf '%s\n' '=== exact generated-source and integration paths ==='
cat -n src/main/pi/agent-status-extension-source.ts | sed -n '1,80p'
rg -n -C 12 --glob '*.ts' \
'getPiAgentStatusExtensionSource|materializePi|ORCA_PI_AGENT_STATUS_EXTENSION_FILE|ORCA_.*STATUS_EXTENSION' \
src/main src/relay src/shared | head -350
printf '%s\n' '=== Pi status normalizer and approval lifecycle ==='
cat -n src/shared/agent-hook-listener/providers/pi-family-tool-fields.ts
cat -n src/shared/agent-hook-listener/providers/pi-family-events.ts | sed -n '1,100p'
rg -n -C 12 --glob '*.ts' \
'tool_call_id|toolCallId|approval_mode|approvalMode|action-required|blocked' \
src/main/agent-hooks src/shared src/renderer | head -350Repository: stablyai/orca
Length of output: 50370
🌐 Web query:
Pi coding agent extension API tool_approval_requested toolCallId approvalMode event contract
💡 Result:
In the Pi coding agent framework, tool_approval_requested is an observability event emitted by the system to indicate that a tool call requires user or system approval before execution [1][2][3]. This event is part of the agent's extensibility API, allowing extensions to subscribe to, monitor, and potentially act upon tool lifecycle events [1][4][5]. The event interface, defined as ToolApprovalRequestedEvent, typically contains the following fields [6][4][7]: - type: "tool_approval_requested" - sessionId: A string identifier for the current session [6][7]. - toolCallId: A unique identifier for the specific tool invocation [6][7]. - toolName: The name of the tool requested [6][7]. - reason: An optional string explaining why approval is requested [6][7]. - approvalMode: An ApprovalMode enum value indicating the nature of the approval required (e.g., whether it involves potential system mutations) [6][7]. This event is paired with tool_approval_resolved, which reports the outcome of the request (whether it was approved or denied) [2][7][8]. Extensions can register handlers for these events using the extension API, enabling developers to integrate custom approval flows, such as UI-based notifications or external validation checks [2][8][9]. The system only emits these events when a tool is configured to require approval and an appropriate handler is registered in the environment [1][3].
Citations:
- 1: https://github.com/can1357/oh-my-pi/blob/main/docs/extensions.md
- 2: https://omp.sh/docs/hooks
- 3: https://github.com/can1357/oh-my-pi/blob/403931b9/docs/extensions.md
- 4: https://github.com/can1357/oh-my-pi/blob/d7383294/packages/coding-agent/src/extensibility/extensions/types.ts
- 5: https://github.com/earendil-works/pi/blob/main/packages/coding-agent/README.md
- 6: https://app.unpkg.com/@oh-my-pi/[email protected]/files/src/extensibility/extensions/types.ts
- 7: https://cdn.jsdelivr.net/npm/@oh-my-pi/[email protected]/src/extensibility/extensions/types.ts
- 8: https://github.com/epilande/ccmux/blob/main/docs/agent-adapters.md
- 9: http://pi.dev/docs/latest/rpc
🌐 Web query:
site:github.com/badlogic/pi-mono tool_approval_requested extensions types.ts
💡 Result:
In the pi-mono codebase, "tool_approval_requested" is not a standard type or event name found in the packages/coding-agent/src/core/extensions/types.ts file or the broader extension API [1][2][3][4]. The extension system uses specific event types for managing tool interactions, most notably the tool_call event [2][3]. Extensions can intercept tool calls using this event and return a result object that includes a block: true property to prevent a tool from executing [5][6]. It appears that "tool_approval_requested" may be either a custom event name defined in a specific third-party extension, a misremembered identifier, or a internal-only string used in specific implementation logic that is not exposed as a primary type [6]. For managing tool execution and approvals, the recommended authoritative pattern is to hook into the tool_call event: 1. Use pi.on("tool_call", (event) => { ... }) to listen for incoming tool calls [7]. 2. Use type guards like isToolCallEventType to safely access input arguments for specific tools [7]. 3. To block or approve a tool, the handler can return logic that evaluates the tool call, potentially signaling a block to the agent runtime [5][6]. If you are seeing "tool_approval_requested" in your own codebase, it is likely a custom implementation detail rather than a native part of the pi-mono extension SDK [1][4][8].
Citations:
- 1: https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/src/core/extensions/types.ts
- 2: https://github.com/badlogic/pi-mono/blob/83378aad/packages/coding-agent/src/core/extensions/types.ts
- 3: https://github.com/badlogic/pi-mono/blob/dd6bea41/packages/coding-agent/src/core/extensions/types.ts
- 4: https://github.com/badlogic/pi-mono/blob/38f18be4/packages/coding-agent/src/core/extensions/index.ts
- 5: https://github.com/badlogic/pi-mono/blob/dd6bea41/packages/agent/src/types.ts
- 6: GitHub issue 2543 in badlogic/pi-mono (link omitted to avoid creating a cross-reference)
- 7: https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/docs/extensions.md
- 8: https://github.com/badlogic/pi-mono/blob/38f18be4/packages/agent/src/types.ts
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '=== agent-kind and launch command definitions ==='
cat -n src/shared/pi-agent-kind.ts
rg -n -C 6 --glob '*.ts' --glob '*.tsx' --glob '*.json' --glob '*.mjs' \
'PI_CODING_AGENT|PI_AGENT|OMP|prime-agent|oh-my-pi|pi-mono|pi\.dev|agentKind|agent kind' \
src config package.json | head -500
printf '%s\n' '=== all approval event registrations and lifecycle handling ==='
rg -n -C 15 --glob '*.ts' --glob '*.tsx' \
'tool_approval_requested|tool_approval_resolved|tool_call' \
src/main/pi src/main/agent-hooks src/shared | head -500
printf '%s\n' '=== status server input and normalized output contracts ==='
cat -n src/shared/agent-hook-listener/providers/pi-family-tool-fields.ts
cat -n src/shared/agent-hook-listener/providers/pi-family-events.ts | sed -n '1,90p'
rg -n -C 10 --glob '*.ts' \
'toolCallId|toolUseId|tool_call_id|toolUseId|waitingTool|blocked' \
src/shared/agent-hook-listener src/main/agent-hooks | head -400Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '=== TUI agent configuration ==='
rg -n -l 'TUI_AGENT_CONFIG' src/shared src/main config
for f in $(rg -l 'TUI_AGENT_CONFIG' src/shared src/main config | head -20); do
printf '\n--- %s ---\n' "$f"
rg -n -C 12 'TUI_AGENT_CONFIG|launchCmd|pi:|omp:|prime-agent' "$f" | head -220
done
printf '%s\n' '=== concise Pi-family event handling ==='
rg -n --glob '*.ts' \
'tool_approval_requested|tool_approval_resolved|tool_call' \
src/main/pi src/shared/agent-hook-listener/providers src/main/agent-hooks/server.ts
printf '%s\n' '=== generated handler registration contract ==='
sed -n '1,125p' src/main/pi/agent-status-handler-source.ts
sed -n '155,205p' src/main/pi/agent-status-extension-source.test.tsRepository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -u
printf '%s\n' '=== Pi-family tool snapshot contract ==='
cat -n src/shared/agent-hook-listener/providers/pi-family-tool-fields.ts
printf '%s\n' '=== Pi-family state transition contract ==='
cat -n src/shared/agent-hook-listener/providers/pi-family-events.ts | sed -n '1,100p'
printf '%s\n' '=== approval-related tests ==='
cat -n src/shared/agent-hook-listener-pi-compatible.test.ts | sed -n '70,135p'
rg -n -C 12 --glob '*.ts' \
'tool_approval_requested|tool_approval_resolved|approval.*den|blocked.*tool|tool.*blocked' \
src/main/agent-hooks src/shared src/renderer | head -300Repository: stablyai/orca
Length of output: 34647
Add version-specific integration coverage for tool_approval_requested.
The repository launches the external pi binary, but it does not pin its version. The harness accepts any event name and invokes it directly, so the passing test does not establish runtime support. Upstream pi-mono exposes tool_call, not tool_approval_requested; if that implementation is deployed, this handler never runs and the blocked status is not posted.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- applicable repository conventions ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -type f -name '*.md' -print
printf '%s\n' '--- target file outline ---'
ast-grep outline src/main/pi/agent-status-handler-source.ts
printf '%s\n' '--- target handler and nearby code ---'
sed -n '1,180p' src/main/pi/agent-status-handler-source.ts
printf '%s\n' '--- related approval event symbols ---'
rg -n -C 3 "tool_approval_requested|tool_approval_resolved|tool_execution_start|tool_execution_end|blocked" src test tests 2>/dev/null || trueRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- knowledge files relevant to pi ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -type f -name '*.md' \
| grep -Ei 'pi|agent|status|main|convention' | head -80
printf '%s\n' '--- target file ---'
sed -n '1,180p' src/main/pi/agent-status-handler-source.ts
printf '%s\n' '--- pi event references ---'
rg -n -C 4 "tool_approval_requested|tool_approval_resolved|tool_execution_start|tool_execution_end|blocked" src/main/pi src/renderer/src/components/native-chat 2>/dev/null | head -300
printf '%s\n' '--- package/version declarations and Pi imports ---'
rg -n -C 3 '"@.*pi|pi-' package.json pnpm-lock.yaml yarn.lock package-lock.json src/main/pi 2>/dev/null | head -200Repository: stablyai/orca
Length of output: 41938
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- repository conventions ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/repo-wide.md
printf '%s\n' '--- main conventions ---'
cat /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions/src-main-daemon.md
printf '%s\n' '--- target remainder ---'
sed -n '180,360p' src/main/pi/agent-status-handler-source.ts
printf '%s\n' '--- exact package declarations ---'
rg -n -i -C 3 '"[^"]*(pi|omp)[^"]*"|pi-agent|`@mario`|pi-coding' package.json pnpm-lock.yaml 2>/dev/null | head -240
printf '%s\n' '--- status consumer definitions ---'
rg -n -C 5 "tool_approval_requested|tool_call_id|hook_event_name|deriveToolInputPreview|blocked" src/main src/renderer --glob '!**/*.test.*' | head -400Repository: stablyai/orca
Length of output: 45738
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- files that consume approval/status fields ---'
rg -l "deriveToolInputPreview|tool_call_id|tool_approval_requested|hook_event_name" src --glob '!**/*.test.*' | sort
printf '%s\n' '--- focused approval/status implementation excerpts ---'
for f in $(rg -l "deriveToolInputPreview|tool_call_id|tool_approval_requested|hook_event_name" src --glob '!**/*.test.*' | sort); do
echo "### $f"
rg -n -C 8 "deriveToolInputPreview|tool_call_id|tool_approval_requested|hook_event_name|blocked|working|waiting" "$f" | head -180
done
printf '%s\n' '--- focused Pi tests ---'
sed -n '620,740p' src/main/pi/agent-status-extension-source.test.ts
printf '%s\n' '--- Pi-related files and dependency names ---'
git ls-files src/main/pi
rg -n -i "pi.*(version|package|event)|`@mario`|pi-coding-agent|tool_approval" . --glob '!pnpm-lock.yaml' --glob '!**/node_modules/**' --glob '!**/*.map' | head -300Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- exact approval references in source TypeScript ---'
rg -n -C 8 "tool_approval_requested|tool_call_id|deriveToolInputPreview" src \
--glob '*.ts' --glob '*.tsx' --glob '!**/*.test.*' --glob '!**/*.d.ts'
printf '%s\n' '--- agent-hook source files ---'
find src -type f \( -iname '*agent*hook*' -o -iname '*status*' \) | sort | head -160
printf '%s\n' '--- native chat status bridge and hook state ---'
sed -n '1,180p' src/renderer/src/components/native-chat/StructuredAgentSessionStatusBridge.tsx 2>/dev/null || true
rg -n -C 8 "hookState|tool_call|tool_execution|status.*state|state.*blocked|approval" src/renderer/src/hooks src/renderer/src/components/native-chat src/main --glob '*.ts' --glob '*.tsx' --glob '!**/*.test.*' | head -320
printf '%s\n' '--- focused test harness ---'
sed -n '1,130p' src/main/pi/agent-status-extension-source.test.ts
sed -n '650,730p' src/main/pi/agent-status-extension-source.test.tsRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- Pi-family event state mapping ---'
cat src/shared/agent-hook-listener/providers/pi-family-events.ts
printf '%s\n' '--- Pi-family field extraction ---'
cat src/shared/agent-hook-listener/providers/pi-family-tool-fields.ts
printf '%s\n' '--- status ingest entry points ---'
rg -n -l "extractPiToolFields|resolve.*Event|hook_event_name|stateName|agent-hook" src/main/agent-hooks src/shared/agent-hook-listener --glob '*.ts' --glob '!**/*.test.*' | sort
printf '%s\n' '--- status ingest excerpts ---'
for f in $(rg -l "extractPiToolFields|stateName|hook_event_name" src/main/agent-hooks src/shared/agent-hook-listener --glob '*.ts' --glob '!**/*.test.*' | sort); do
echo "### $f"
rg -n -C 10 "extractPiToolFields|stateName|hook_event_name|working|blocked|tool_execution_end" "$f" | head -220
doneRepository: stablyai/orca
Length of output: 50369
🌐 Web query:
Pi coding agent tool_approval_requested tool_approval_resolved event contract
💡 Result:
In the Pi coding agent (often referred to as omp), tool_approval_requested and tool_approval_resolved are lifecycle events used for observability and handling tool execution permissions [1][2][3]. The tool_approval_requested event is emitted when the agent is about to execute a tool that requires user approval [4][5][2]. Its payload typically includes the sessionId, toolCallId, toolName, reason for the request, and the current approvalMode [6][4][2]. The tool_approval_resolved event is emitted after the approval process has concluded, signaling whether the tool was approved or denied [4][5][2]. Its payload includes the sessionId, toolCallId, toolName, the final decision (boolean approved), and optionally, a reason for the outcome [6][4][2]. These events are generated within the tool wrapper (wrapper.ts) when a tool's security policy requires a prompt and an approval handler is registered [1][4][5][7]. They allow extensions to intercept tool execution, prompt users through custom UI components, or log approval decisions [8][3][9]. If no interactive UI is available to handle a required approval, the agent may default to denying the request [5][10].
Citations:
- 1: https://github.com/can1357/oh-my-pi/blob/403931b9/docs/extensions.md
- 2: https://omp.sh/docs/hooks
- 3: https://omp.sh/docs/extension-authoring
- 4: https://github.com/can1357/oh-my-pi/blob/c0d0ad76/packages/coding-agent/src/extensibility/extensions/wrapper.ts
- 5: https://github.com/can1357/oh-my-pi/blob/d7383294/packages/coding-agent/src/extensibility/extensions/wrapper.ts
- 6: https://app.unpkg.com/@oh-my-pi/[email protected]/files/src/extensibility/extensions/types.ts
- 7: https://github.com/can1357/oh-my-pi/blob/main/docs/extensions.md
- 8: https://github.com/can1357/oh-my-pi/blob/c0d0ad76/packages/coding-agent/test/extensions-runner.test.ts
- 9: https://github.com/earendil-works/pi/blob/13437ca828894f43f973c630d208b488637d8fa9/packages/coding-agent/docs/extensions.md
- 10: https://cdn.jsdelivr.net/npm/@oh-my-pi/[email protected]/src/extensibility/extensions/wrapper.ts
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- dispatch and status retention ---'
rg -n -C 12 "normalizePiCompatibleEvent|lastStatusByPaneKey|normalize.*Event|parsed.*status|if \\(!.*payload|payload === null" \
src/shared/agent-hook-listener src/main/agent-hooks --glob '*.ts' --glob '!**/*.test.*' | head -500
printf '%s\n' '--- Pi runtime/version ownership ---'
rg -n -C 5 "pi-coding-agent|`@earendil`|oh-my-pi|omp\.sh|agentKind.*pi|kind.*pi|PiAgentKind" \
src/main src/shared config package.json --glob '*.ts' --glob '*.mjs' --glob '*.json' --glob '!**/*.map' | head -400
printf '%s\n' '--- exact Pi-family tests for unsupported events and blocked state ---'
rg -n -C 10 "tool_approval|normalizePiCompatibleEvent|blocked|tool_execution_end" \
src/shared/agent-hook-listener src/main/pi --glob '*.test.ts' | head -500Repository: stablyai/orca
Length of output: 50369
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- status write path ---'
rg -n -C 12 "lastStatusByPaneKey\.set|normalizeProviderEvent\(" \
src/shared/agent-hook-listener src/main/agent-hooks --glob '*.ts' --glob '!**/*.test.*'
printf '%s\n' '--- status payload persistence and fanout ---'
rg -n -C 10 "result\.payload|dispatchResult\.payload|payload\)" \
src/shared/agent-hook-listener src/main/agent-hooks --glob '*.ts' --glob '!**/*.test.*' | head -320Repository: stablyai/orca
Length of output: 29036
Handle tool_approval_resolved before clearing the blocked state.
normalizePiCompatibleEvent maps tool_approval_requested to blocked, but returns null for tool_approval_resolved. If a denial emits only the resolution event, no replacement status is written and the pane can remain blocked. Add resolution handling or an integration test for approval and denial that proves the existing clear path.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/shared/agent-hook-listener-pi-compatible.test.ts (1)
111-116: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAssert that
tool_call_idsurvives normalization.The fixture includes
tool_call_id, but the test only checksblocked.payload. Add an assertion forblocked?.toolUseIdso a regression that drops the approval identifier cannot pass unnoticed.Proposed test assertion
expect(blocked?.payload.interactivePrompt).toBeUndefined() + expect(blocked?.toolUseId).toBe('call-1')
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4f277ba7-d353-44b4-b2ef-4a2254380e13
📥 Commits
Reviewing files that changed from the base of the PR and between bab6dcb0593004f906a2748ac0339faf5df34a0f and eed7b6a.
📒 Files selected for processing (3)
src/main/pi/agent-status-extension-source.test.tssrc/main/pi/agent-status-handler-source.tssrc/shared/agent-hook-listener-pi-compatible.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
|
|
Superseded by merged #15713 and the current-main OMP hook path. |
|
Closing as superseded by merged #15713/current main; the OMP approval mapping is already present. |
Summary
tool_approval_requestedfrom generated status extension.blocked/ action-required in Orca backend.Pi can pause while awaiting dangerous-tool approval. Without this event, Orca keeps pane in
workingstate because no execution-end event arrives. This change makes approval waits visible as attention-required status.Tests
pnpm exec vitest run src/shared/agent-hook-listener-pi-compatible.test.ts src/main/pi/agent-status-extension-source.test.ts— 46 passedpnpm tc:node— passedgit diff --check— passedCloses the approval-waiting portion of #15145;
ask_userhandling remains covered separately by #10454.