Repository navigation
feat(computer-use): show snapshot selected text in model observations - #5050
Conversation
select_text already returns a snapshot.selectedText payload, but the shared observation type and renderer dropped it, so the model could not confirm what was selected. Surface the field on CuObservation and write it in the observation header, truncated like value and withheld when the focused control is a secure field. Generated-by: pi-coding-agent
The renderer already truncated like value. Review required a test that fails if a 300-character selection is shown in full. Generated-by: pi-coding-agent
me2seeks
left a comment
There was a problem hiding this comment.
Automated review notice: This comment was posted by an automated review agent operated by me2seeks make. It is not an independent human review and does not replace one.
Summary
Renders window selected text in Computer Use model observations: ComputerUseSelectedText { text, truncated } on CuObservation (maka.cu/2 §5.2), with three display rules all pinned by tests — a focused secure field (AXSecureTextField) withholds the text as selected_text=withheld(secure_field) and never leaks it, oversized selections are shortened visibly at 256 chars with an explicit (+N chars) marker, and the executor's own truncated flag is preserved. The backend comment is updated to match the new reality (selectedText now has a model-facing home). Every test path is asserted on the header line, including the no-selection case producing no mention.
Findings
- [P3] Only the
labelcheck ran on this head — for a change feeding application text into model context (with a security-relevant withhold rule), thetestlane should run green before merge.
Verdict
merge-ready — correct, well-fenced display of selected text with the secure-field rule tested; request CI as housekeeping.
hqhq1025
left a comment
There was a problem hiding this comment.
Reviewed the five-file change at this exact head. It adds selected text to the Computer Use observation header, preserves the executor truncation flag, and suppresses text when a focused secure element is present in the reported tree. I found one security-relevant issue in the missing-focus case (inline). Do not merge this head until the focus/secure-field decision is made from an untruncated authoritative signal or fails closed, with a regression for a focused token absent from the reported elements.\n\nNode 24 build:test and two focused test files (37 tests) pass. A direct probe of the emitted renderer shows a truncated observation without the secure element prints selected_text="SECRET-EXAMPLE"; adding the focused AXSecureTextField with the same selection yields selected_text=withheld(secure_field). Fresh main 076cdd1fb9bd60795a43c6fb4e716bfd73901efe merge-tree and diff-check are clean; its overlapping backend change is confined to session-generation cleanup, not selection rendering. The current-head hosted test check is still queued; label is green. I did not run the full suite, a real macOS accessibility provider, or packaged Desktop. Whether native secure controls ever return selected text could not be established here; the protocol and renderer currently accept that combination.\n\n> Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.
| function selectedTextCaption(observation: CuObservation): string | undefined { | ||
| const selected = observation.selectedText; | ||
| if (!selected) return undefined; | ||
| const focused = observation.elements.find((element) => element.focused === true); |
There was a problem hiding this comment.
[P1] Fail closed when the focused field is absent from the element list. selectedText and focusedElementToken are independent snapshot fields, while elements may be a truncated prefix (maka-cu-protocol.ts:530-541,846-855,925-948; maka-cu-backend.ts:1492-1496,1520-1523). If a focused AXSecureTextField falls outside that prefix, .find() returns no element and lines 502–505 send its selected text verbatim to the model. The existing secure-field test includes the focused element and misses this case. Preserve an authoritative secure/withhold signal across the snapshot boundary, or withhold when focus cannot be classified; test a valid truncated snapshot whose focused token is not in elements.
|
This pull request has had no new commits for 30 days and has been marked stale. It will be closed in 7 days unless a new commit is pushed. Comments do not reset this timer: only a new commit does. If the pull request is intentionally long-lived, a maintainer can apply the |
Astro-Han
left a comment
There was a problem hiding this comment.
Approved at @Astro-Han's explicit request: a small, focused change with no blocking findings in our automated review of this exact head, and CI is green.
Summary
select_textalready comes back withsnapshot.selectedText, but the shared observation type and renderer dropped it, so the model could not confirm what was selected.This PR:
ComputerUseSelectedTextin@maka/coreCuObservation.selectedTextvalueDoes not change protocol parsing or persist the selection into the call record.
Fixes #5047
Does this PR entail a change in behavior?
Verification
npm --workspace @maka/core run buildnpm --workspace @maka/runtime run buildnode --test packages/runtime/dist/__tests__/computer-use-observation-text.test.js— 17 pass, including selected-text header / truncated / secure withhold / length cap / absent fieldlint/format:check/ fulltypecheckAI use
Select exactly one:
Tool(s) and scope:
pi-coding-agent drafted the contract type, observation header rendering, tests, and this description. Commits carry
Generated-by: pi-coding-agent.Checklist