Skip to content

fix(chat): route OMP question cards to terminal - #31440

Merged
nwparker merged 7 commits into
mainfrom
nwparker/mobile-b2-omp-answers
Oct 21, 2026
Merged

nwparker merged 7 commits into
mainfrom
nwparker/mobile-b2-omp-answers

Conversation

@nwparker

@nwparker nwparker commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​335 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​327
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​176 $\color{#cf222e}{\Huge{\mathbf{−}}}$​52 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​124

OMP question cards could silently submit the highlighted option, toggle the wrong checkbox state, or answer the wrong question after terminal navigation. Desktop and mobile now show Answer in terminal for terminal-backed OMP questions. Opening the terminal preserves the active dialog and draft; card answer/cancel callbacks refuse to write terminal input.

Automatic OMP card answering is deferred. Refs #26692 and #26198; this PR does not close the remaining request for semantic card answering.

Changes

  • Use the existing desktop view switch and mobile per-tab view selection to open the owning terminal.
  • Replace OMP question answer/cancel controls with a terminal action. Disable the action if its owning tab is unavailable.
  • Refuse OMP answer/cancel writes at the sender, including retained mobile callbacks and paced writes after the agent changes to OMP. Refusal neither heals a pending draft nor dismisses the prompt or clears its waiting status.
  • Keep structured-session semantic response controls and other agents' answer paths intact.
  • Recognize OMP's multi flag in canonical status and transcript parsing.
  • Introduce no new host RPC, dependency patch, collaboration permission, or version-dependent keyboard plan. The client policy also works with older hosts and folder workspaces.

Why terminal input cannot safely submit these answers

Verification against the actual selector implementation reproduces three independent state ambiguities:

Existing terminal state Intended card answer Actual keyboard-plan answer
Up/Down remapped to k/j B A
B already checked A + C A + B + C
Two questions, currently on question 2 q1=B, q2=C q1 empty, q2=B

The current public local extension API can create a dialog but cannot resolve an existing ask by ID. Semantic RPC and collaboration responses belong to different process/session transports. Reusing them for ordinary terminal sessions would require a separate integration.

Verification

  • 76 desktop/shared tests passed across actual card presentation, resolved-view callback wiring, sender refusal, parser and agent support suites.
  • 99 mobile tests passed across card/view/overlay routing, structured-session exclusion, answer/cancel refusal, retained callbacks, replacement-agent pacing and controller behavior.
  • Renderer TypeScript check passed across 15,313 files; mobile production TypeScript check passed.
  • Changed-code quality passed with zero new findings, including type-aware rules, React Doctor and design-system checks.
  • English catalog, runtime catalog and localization extraction checks passed. Only two English strings were added.
  • Hidden Electron/CDP rendered check: inspected the production fallback card, confirmed no Send/Cancel controls, clicked the terminal action and observed one navigation callback, zero input writes and zero dismissals. This was a component fixture in the running app; actual view/tab routing is covered separately by desktop and mobile tests. No mobile emulator was launched for this follow-up.
  • Independent adversarial review of exact commit d922b3f3240 found no blocking findings and independently passed the same 99 mobile and 76 desktop/shared tests.
  • Final head 7bbfc88e0e4 only fixes typed component selectors in two test fixtures; no production delta from the independent review. Both affected suites (10 tests) and the native mobile test-typecheck ratchet pass.
  • Final-head full PR workflow and PR checks passed aggregate, all five main test shards, relay integration, Linux/Windows packaging, mobile web bundle, Mobile Checks, and headless-server persistence CI pass. The separate, explicitly nonrequired WSL distro host-transport lane remains queued; this PR adds no host protocol or dependency changes.

Community credit

Follow-up to @jairuspace's #26688 and @daniellp-rubio's #29184. Both contributors remain credited through Co-authored-by commit trailers. The final scope is the safe terminal fallback rather than automatic keyboard submission.

Risk

LOW for this narrowed scope, independently approved at d922b3f3240; full final-head PR CI and aggregate pass. Optional WSL distro CI remains queued. The intentional limitation is that terminal-backed OMP questions must be answered in terminal view. Automatic card answering still needs an active-dialog-ID-bound semantic answer API.

OMP question terminal fallback

Adapt the community navigation-key answer plan for desktop and mobile,
including OMP multi-select parsing and paced mobile delivery coverage.

Refs: #26688
Refs: #29184
Fixes: #26692

Co-authored-by: jairuspace <jairusbpace@gmail.com>
Co-authored-by: Daniel Lopez <dafeloru@gmail.com>
@nwparker
nwparker marked this pull request as ready for review October 21, 2026 06:59
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The changes identify OMP asks as requiring terminal interaction. Desktop and mobile chat views provide a terminal navigation action, while their answer and cancel paths reject native actions for OMP. Mobile terminal navigation targets the active session tab. Ask parsing also recognizes the multiple and multi aliases for multi-select input.

Priority: ⚪ Pending latest changes

Merge Risk: 🟡 Moderate · up to d922b

The mobile verification job is blocked by a new test type error. Fix it and rerun the mobile checks before merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 33 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description clearly explains the user impact, implementation, rationale, visual change, testing, risk, and known limitation. However, it does not follow the required template closely: it omits the… Add the missing required template sections and complete them with the requested information. Include an actual linked issue reference, such as “Fixes #,” rather than only “Refs #26692 and #26198.” Complete the testing checkbox…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: routing OMP question cards to the terminal.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 33 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Full details: Description check

Explanation

The description clearly explains the user impact, implementation, rationale, visual change, testing, risk, and known limitation. However, it does not follow the required template closely: it omits the required ELI5, What Changed, Why, Linked Issue, Review, Agent skill upstream boundary, Notes, and Checklist sections, and it provides only “Refs #26692 and #26198” instead of an actual linked issue with a Fixes reference.

Resolution

Add the missing required template sections and complete them with the requested information. Include an actual linked issue reference, such as “Fixes #<issue-number>,” rather than only “Refs #26692 and #26198.” Complete the testing checkboxes and document platform coverage or explain why it is not applicable.

✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0fbc6a73-c5f6-4d28-8d59-20d7331bde18
📥 Commits

Reviewing files that changed from the base of the PR and between a04b2eb and 54e88a8.

📒 Files selected for processing: 17
  • mobile/src/session/use-mobile-bridge-chat-prompt-writes.ts
  • mobile/src/session/use-mobile-native-chat-answer-send-omp.test.ts
  • mobile/src/session/use-mobile-native-chat-answer-send.ts
  • mobile/src/session/use-mobile-native-chat-controller.ts
  • src/renderer/src/components/native-chat/native-chat-input-clear.ts
  • src/renderer/src/components/native-chat/native-chat-interactive-prompt.test.ts
  • src/renderer/src/components/native-chat/native-chat-interactive-prompt.ts
  • src/renderer/src/components/native-chat/native-chat-observed-send.ts
  • src/renderer/src/components/native-chat/native-chat-runtime-send.test.ts
  • src/renderer/src/components/native-chat/native-chat-runtime-send.ts
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
  • src/shared/native-chat-agent-support.test.ts
  • src/shared/native-chat-agent-support.ts
  • src/shared/native-chat-ask.test.ts
  • src/shared/native-chat-ask.ts
  • src/shared/native-chat-omp-selection.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment on lines +126 to +129
if (omp && attemptedOmpAskRef.current === baselineKey) {
onDeliverySettled?.(false)
return { settleAfterMs: 0 }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '55,125p' src/shared/agent-hook-listener/providers/pi-family-events.ts
sed -n '165,208p' src/shared/program-status/agent-status-projector.ts
sed -n '112,157p' src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts

Repository: stablyai/orca

Length of output: 6691


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- OMP status producer references ---'
rg -n -F --glob '*.ts' -e 'tool_execution_start' -e 'resolvePrompt' -e 'projectRoot' -e 'rootStateStartedAt' src/shared src/renderer/src | head -160
printf '%s\n' '--- renderer sender block ---'
nl -ba src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts | sed -n '1,190p'
printf '%s\n' '--- projector block ---'
nl -ba src/shared/program-status/agent-status-projector.ts | sed -n '130,220p'
printf '%s\n' '--- prompt/status listener block ---'
nl -ba src/shared/agent-hook-listener/providers/pi-family-events.ts | sed -n '1,240p'

Repository: stablyai/orca

Length of output: 33439


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- OMP listener callers and status timestamp flow ---'
rg -n -F --glob '*.ts' -e 'normalizePiCompatibleEvent(' -e 'lastStatusByPaneKey' -e 'stateStartedAt' src/shared src/renderer/src | head -220
printf '%s\n' '--- listener state and dispatch definitions ---'
rg -n -F --glob '*.ts' -e 'type HookListenerState' -e 'interface HookListenerState' -e 'lastStatusByPaneKey:' -e 'normalizeAgentStatusPayload' src/shared/agent-hook-listener src/shared | head -180
printf '%s\n' '--- prompt field cache ---'
nl -ba src/shared/agent-hook-listener/prompt-fields.ts | sed -n '1,180p'
printf '%s\n' '--- status event applicator ---'
nl -ba src/renderer/src/hooks/ipc-events/agent-status-event-applicator.ts | sed -n '180,270p'

Repository: stablyai/orca

Length of output: 42599


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- non-test stateStartedAt assignments ---'
rg -n -F --glob '*.ts' --glob '!*.test.ts' -- 'stateStartedAt' src/shared src/renderer/src
printf '%s\n' '--- hook listener publish callers ---'
rg -n -F --glob '*.ts' --glob '!*.test.ts' -e 'normalizePiCompatibleEvent' -e 'publishAgentStatus' -e 'applyAgentStatus' -e 'stateStartedAt:' src/shared/agent-hook-listener.ts src/shared/agent-hook-status-cache.ts src/shared/agent-status-event* src/shared | head -220
printf '%s\n' '--- main hook listener dispatch ---'
nl -ba src/shared/agent-hook-listener.ts | sed -n '1,340p'
printf '%s\n' '--- hook status cache ---'
nl -ba src/shared/agent-hook-status-cache.ts | sed -n '1,220p'

Repository: stablyai/orca

Length of output: 42341


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- lead status fold ---'
nl -ba src/shared/agent-lead-status-fold.ts | sed -n '1,135p'
printf '%s\n' '--- fold callers and status timing construction ---'
rg -n -F --glob '*.ts' --glob '!*.test.ts' -e 'continueAgentLeadStatus' -e 'foldAgentLeadStatus' -e 'agent-lead-status-fold' -e 'stateStartedAt:' -e 'receivedAt:' src/shared src/renderer/src | head -260
printf '%s\n' '--- status mutation and IPC payload path ---'
nl -ba src/shared/agent-status-store-mutation.ts | sed -n '180,310p'
nl -ba src/shared/agent-status-ipc-payload.ts | sed -n '1,125p'
printf '%s\n' '--- tmux hook owner timing path ---'
nl -ba src/shared/tmux-agent-hook-owner.ts | sed -n '95,165p'

Repository: stablyai/orca

Length of output: 39933


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- OMP tool fields and event identity ---'
nl -ba src/shared/agent-hook-listener/providers/pi-family-tool-fields.ts | sed -n '1,150p'
rg -n -F --glob '*.ts' -e 'promptInteractionKey' -e 'tool_use_id' -e 'toolUseId' -e 'tool_execution_start' src/shared/agent-hook-listener src/shared/agent-hook-listener.ts src/renderer/src/components/native-chat src/renderer/src/hooks | head -260
printf '%s\n' '--- OMP and Pi-family tests around repeated asks ---'
rg -n -F --glob '*test.ts' -e 'agentType: .omp.' -e 'tool_name: .ask.' -e 'tool_use_id' -e 'promptInteractionKey' -e 'blocked' src/shared/agent-hook-listener* src/shared | head -240
printf '%s\n' '--- status payload identity fields ---'
nl -ba src/shared/agent-hook-listener/listener-event.ts | sed -n '1,180p'
nl -ba src/shared/agent-status-types.ts | sed -n '150,225p'

Repository: stablyai/orca

Length of output: 41465


Include a stable OMP ask occurrence in the retry fence.

stateStartedAt is required, so the timestamp-free premise is incorrect. However, the OMP hook publisher preserves stateStartedAt when a new event remains blocked, while updating receivedAt. Two distinct asks with identical question content can therefore produce the same baselineKey.

Do not reset the fence on generic status changes or use receivedAt. That can allow duplicate writes for one ask. Populate the existing promptInteractionKey (or an equivalent stable OMP ask identity) for each ask occurrence and include it in baselineKey. Retransmissions of one ask must retain the same key, while a distinct ask must receive a new key.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0cd29ea8-c850-4a6c-991d-1d31a685231b
📥 Commits

Reviewing files that changed from the base of the PR and between 54e88a8 and 58794ac.

📒 Files selected for processing: 9
  • mobile/src/session/use-mobile-bridge-chat-prompt-writes.ts
  • mobile/src/session/use-mobile-native-chat-answer-send-omp.test.ts
  • mobile/src/session/use-mobile-native-chat-answer-send.ts
  • mobile/src/session/use-mobile-native-chat-controller.ts
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
  • src/shared/native-chat-omp-answer-retry-fence.test.ts
  • src/shared/native-chat-omp-answer-retry-fence.ts
  • src/shared/native-chat-omp-prompt-identity.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment on lines +1 to +17
const OMP_ANSWER_RETRY_FENCE_CAPACITY = 128

export function createOmpAnswerRetryFence(): {
blocks: (key: string) => boolean
record: (key: string) => void
} {
const attempts = new Set<string>()
return {
blocks: (key) => attempts.has(key) || attempts.size >= OMP_ANSWER_RETRY_FENCE_CAPACITY,
record: (key) => {
// Retain earlier attempts; reaching capacity must never reopen stale retries.
if (attempts.size < OMP_ANSWER_RETRY_FENCE_CAPACITY) {
attempts.add(key)
}
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -u
printf '%s\n' '--- diff summary ---'
git diff --stat 7dfcfbf7356b0a34f12d4c3d2b48d4a2a7dcfdd5 58794aca7f811d2773b178812a9c8c2ed17edb9f -- src/shared/native-chat-omp-answer-retry-fence.ts src/shared/native-chat-omp-answer-retry-fence.test.ts
printf '%s\n' '--- fence source ---'
nl -ba src/shared/native-chat-omp-answer-retry-fence.ts
printf '%s\n' '--- fence test ---'
nl -ba src/shared/native-chat-omp-answer-retry-fence.test.ts
printf '%s\n' '--- all fence references ---'
rg -n -F --glob '!node_modules' --glob '!dist' -e 'createOmpAnswerRetryFence' -e 'OMP_ANSWER_RETRY_FENCE_CAPACITY' -e 'attempts.size' -e 'native-chat-omp-answer-retry-fence' . || test "$?" -eq 1
printf '%s\n' '--- sender lifecycle references ---'
rg -n -F --glob '*.{ts,tsx}' -e 'useState(createOmpAnswerRetryFence)' -e 'fence.blocks' -e 'fence.record' -e 'cleanup' -e 'cancel' renderer/src/components/native-chat mobile/src/session 2>/dev/null || true
printf '%s\n' '--- bounded-memory/capacity language ---'
rg -n -i --glob '*.{ts,tsx,md,json,yml,yaml}' -e 'bounded memory' -e 'memory bound' -e 'capacity' -e 'retry fence' -e 'retry-fence' -e 'max.*attempt' -e 'evict' src renderer mobile docs .github 2>/dev/null || true
printf '%s\n' '--- relevant diff ---'
git diff --unified=80 7dfcfbf7356b0a34f12d4c3d2b48d4a2a7dcfdd5 58794aca7f811d2773b178812a9c8c2ed17edb9f -- src/shared/native-chat-omp-answer-retry-fence.ts src/shared/native-chat-omp-answer-retry-fence.test.ts

Repository: stablyai/orca

Length of output: 45657


🏁 Script executed:

printf '%s\n' '--- desktop sender ---'
nl -ba src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts | sed -n '1,125p'
printf '%s\n' '--- mobile sender part 1 ---'
nl -ba mobile/src/session/use-mobile-native-chat-answer-send.ts | sed -n '1,190p'
printf '%s\n' '--- mobile sender part 2 ---'
nl -ba mobile/src/session/use-mobile-native-chat-answer-send.ts | sed -n '190,380p'
printf '%s\n' '--- exact fence key construction and calls ---'
rg -n -C 8 -F --glob '*.{ts,tsx}' -e 'attemptedOmpAsks' -e 'ompAnswer' -e 'askKey' -e 'answerKey' src/renderer/src/components/native-chat mobile/src/session src/shared | head -n 500
printf '%s\n' '--- direct fence contract comments/docs ---'
rg -n -F --glob '*.{ts,tsx,md}' -e 'native-chat-omp-answer-retry-fence' -e 'OMP answer retry fence' -e 'OMP_ANSWER_RETRY_FENCE_CAPACITY' -e 'bounded' -e 'unbounded' src/shared src/renderer/src/components/native-chat mobile/src/session docs 2>/dev/null || true

Repository: stablyai/orca

Length of output: 41676


Remove the capacity guard from both fence operations.

After 128 recorded OMP attempts, blocks rejects every new key. Remove that fail-closed branch and let record retain every key. Keep attempts.has(key) so an uncertain retry remains blocked.

Suggested fix
-const OMP_ANSWER_RETRY_FENCE_CAPACITY = 128
-
 export function createOmpAnswerRetryFence(): {
   blocks: (key: string) => boolean
   record: (key: string) => void
@@
   const attempts = new Set<string>()
   return {
-    blocks: (key) => attempts.has(key) || attempts.size >= OMP_ANSWER_RETRY_FENCE_CAPACITY,
+    blocks: (key) => attempts.has(key),
     record: (key) => {
-      // Retain earlier attempts; reaching capacity must never reopen stale retries.
-      if (attempts.size < OMP_ANSWER_RETRY_FENCE_CAPACITY) {
-        attempts.add(key)
-      }
+      attempts.add(key)
     }
   }
 }

Update the test to expect an unseen key to remain allowed after 200 distinct recorded keys, then verify that recording it makes it blocked.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const OMP_ANSWER_RETRY_FENCE_CAPACITY = 128
export function createOmpAnswerRetryFence(): {
blocks: (key: string) => boolean
record: (key: string) => void
} {
const attempts = new Set<string>()
return {
blocks: (key) => attempts.has(key) || attempts.size >= OMP_ANSWER_RETRY_FENCE_CAPACITY,
record: (key) => {
// Retain earlier attempts; reaching capacity must never reopen stale retries.
if (attempts.size < OMP_ANSWER_RETRY_FENCE_CAPACITY) {
attempts.add(key)
}
}
}
}
export function createOmpAnswerRetryFence(): {
blocks: (key: string) => boolean
record: (key: string) => void
} {
const attempts = new Set<string>()
return {
blocks: (key) => attempts.has(key),
record: (key) => {
attempts.add(key)
}
}
}

Use a visible terminal action for OMP ask dialogs and refuse automated card answer/cancel writes. Preserve structured-session responses and OMP multi-select parsing.

Co-authored-by: jairuspace <jairusbpace@gmail.com>

Co-authored-by: Daniel Lopez <dafeloru@gmail.com>
@nwparker nwparker changed the title fix(mobile): deliver OMP question answers with selector keys fix(chat): route OMP question cards to terminal Oct 21, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 719410ea-4a86-44f6-b9e9-b45552a6c389
📥 Commits

Reviewing files that changed from the base of the PR and between 58794ac and d922b3f.

📒 Files selected for processing: 22
  • mobile/src/session/MobileNativeChatOverlay.test.ts
  • mobile/src/session/MobileNativeChatOverlay.tsx
  • mobile/src/session/MobileNativeChatPromptCard.test.tsx
  • mobile/src/session/MobileNativeChatPromptCard.tsx
  • mobile/src/session/MobileNativeChatView.prompt-presentation.test.ts
  • mobile/src/session/MobileNativeChatView.tsx
  • mobile/src/session/MobileSessionActiveContent.tsx
  • mobile/src/session/use-mobile-bridge-chat-prompt-writes.ts
  • mobile/src/session/use-mobile-native-chat-answer-send-omp.test.ts
  • mobile/src/session/use-mobile-native-chat-answer-send.ts
  • mobile/src/session/use-mobile-native-chat-cancel-ask.test.ts
  • mobile/src/session/use-mobile-native-chat-cancel-ask.ts
  • src/renderer/src/components/native-chat/NativeChatInteractiveCard.test.tsx
  • src/renderer/src/components/native-chat/NativeChatInteractiveCard.tsx
  • src/renderer/src/components/native-chat/NativeChatResolvedView.reveal-latest.test.tsx
  • src/renderer/src/components/native-chat/NativeChatResolvedView.tsx
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/native-chat-agent-support.ts
  • src/shared/native-chat-ask.test.ts
  • src/shared/native-chat-ask.ts
💤 Files with no reviewable changes: 1
  • src/shared/native-chat-ask.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment on lines +37 to +62
let tree: ReactTestRenderer | null = null
await act(async () => {
tree = create(
createElement(MobileNativeChatPromptCard, {
ask,
requiresTerminal: true,
onAnswerAsk,
onCancelAsk,
onDismissAsk,
onAnswerInTerminal: available ? onAnswerInTerminal : undefined
})
)
})
const buttons = tree!.root.findAllByType('Pressable')
expect(buttons).toHaveLength(1)
expect(buttons[0]!.props.accessibilityLabel).toBe('Answer in terminal')
expect(buttons[0]!.props.disabled).toBe(!available)
expect(tree!.root.findAllByType('TextInput')).toHaveLength(0)
if (available) {
act(() => buttons[0]!.props.onPress())
}
expect(onAnswerInTerminal).toHaveBeenCalledTimes(available ? 1 : 0)
expect(onAnswerAsk).not.toHaveBeenCalled()
expect(onCancelAsk).not.toHaveBeenCalled()
expect(onDismissAsk).not.toHaveBeenCalled()
act(() => tree!.unmount())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Fix the narrowed tree variable. It breaks typecheck:tests and fails the "Mobile verify" job.

Line 37 declares let tree: ReactTestRenderer | null = null. The code assigns tree only inside the act callback. TypeScript narrows tree to null after the callback. At Lines 50 and 54, tree! therefore has type never, and .root is a type error. This matches the pipeline failure "Test file no longer typechecks".

Store the renderer on an object property. Property reads are not narrowed by the initializer. The repo already uses this pattern in agent-history-current-host-capability.test.tsx (rendered.tree = create(...)).

💚 Proposed fix
--- "a/mobile/src/session/MobileNativeChatPromptCard.test.tsx"
+++ "b/mobile/src/session/MobileNativeChatPromptCard.test.tsx"
@@ -34,32 +34,32 @@
       const onAnswerAsk = vi.fn(async () => true)
       const onCancelAsk = vi.fn(async () => true)
       const onDismissAsk = vi.fn()
-      let tree: ReactTestRenderer | null = null
+      const rendered: { tree: ReactTestRenderer | null } = { tree: null }
       await act(async () => {
-        tree = create(
+        rendered.tree = create(
           createElement(MobileNativeChatPromptCard, {
             ask,
             requiresTerminal: true,
             onAnswerAsk,
             onCancelAsk,
             onDismissAsk,
             onAnswerInTerminal: available ? onAnswerInTerminal : undefined
           })
         )
       })
-      const buttons = tree!.root.findAllByType('Pressable')
+      const buttons = rendered.tree!.root.findAllByType('Pressable')
       expect(buttons).toHaveLength(1)
       expect(buttons[0]!.props.accessibilityLabel).toBe('Answer in terminal')
       expect(buttons[0]!.props.disabled).toBe(!available)
-      expect(tree!.root.findAllByType('TextInput')).toHaveLength(0)
+      expect(rendered.tree!.root.findAllByType('TextInput')).toHaveLength(0)
       if (available) {
         act(() => buttons[0]!.props.onPress())
       }
       expect(onAnswerInTerminal).toHaveBeenCalledTimes(available ? 1 : 0)
       expect(onAnswerAsk).not.toHaveBeenCalled()
       expect(onCancelAsk).not.toHaveBeenCalled()
       expect(onDismissAsk).not.toHaveBeenCalled()
-      act(() => tree!.unmount())
+      act(() => rendered.tree!.unmount())
     }
   )
 
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let tree: ReactTestRenderer | null = null
await act(async () => {
tree = create(
createElement(MobileNativeChatPromptCard, {
ask,
requiresTerminal: true,
onAnswerAsk,
onCancelAsk,
onDismissAsk,
onAnswerInTerminal: available ? onAnswerInTerminal : undefined
})
)
})
const buttons = tree!.root.findAllByType('Pressable')
expect(buttons).toHaveLength(1)
expect(buttons[0]!.props.accessibilityLabel).toBe('Answer in terminal')
expect(buttons[0]!.props.disabled).toBe(!available)
expect(tree!.root.findAllByType('TextInput')).toHaveLength(0)
if (available) {
act(() => buttons[0]!.props.onPress())
}
expect(onAnswerInTerminal).toHaveBeenCalledTimes(available ? 1 : 0)
expect(onAnswerAsk).not.toHaveBeenCalled()
expect(onCancelAsk).not.toHaveBeenCalled()
expect(onDismissAsk).not.toHaveBeenCalled()
act(() => tree!.unmount())
const rendered: { tree: ReactTestRenderer | null } = { tree: null }
await act(async () => {
rendered.tree = create(
createElement(MobileNativeChatPromptCard, {
ask,
requiresTerminal: true,
onAnswerAsk,
onCancelAsk,
onDismissAsk,
onAnswerInTerminal: available ? onAnswerInTerminal : undefined
})
)
})
const buttons = rendered.tree!.root.findAllByType('Pressable')
expect(buttons).toHaveLength(1)
expect(buttons[0]!.props.accessibilityLabel).toBe('Answer in terminal')
expect(buttons[0]!.props.disabled).toBe(!available)
expect(rendered.tree!.root.findAllByType('TextInput')).toHaveLength(0)
if (available) {
act(() => buttons[0]!.props.onPress())
}
expect(onAnswerInTerminal).toHaveBeenCalledTimes(available ? 1 : 0)
expect(onAnswerAsk).not.toHaveBeenCalled()
expect(onCancelAsk).not.toHaveBeenCalled()
expect(onDismissAsk).not.toHaveBeenCalled()
act(() => rendered.tree!.unmount())

Source: Pipeline failures

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.

1 participant