Skip to content

fix(terminal): map image paste to native provider bindings - #409

Merged
DeadWaveWave merged 3 commits into
mainfrom
codex/issues-402-406
Sep 10, 2026
Merged

fix(terminal): map image paste to native provider bindings#409
DeadWaveWave merged 3 commits into
mainfrom
codex/issues-402-406

Conversation

@DeadWaveWave

@DeadWaveWave DeadWaveWave commented Sep 9, 2026

Copy link
Copy Markdown
Owner

💡 Change Scope

  • Small Change: Fast feedback, localized UI/logic, low-risk.
  • Large Change: New feature, cross-boundary logic, runtime-risk (persistence, IPC, lifecycle, recovery).

📝 What Does This PR Do?

Fixes #402.
Fixes #406.

Desktop terminal paste now distinguishes native images from text and maps image gestures to the provider's native image binding. Previously the text-only clipboard path could swallow image paste. Text keeps its existing normalization and bracketed-paste encoding; image triggers are raw terminal input.

Provider Windows image trigger macOS image trigger
Pi / Claude Code Alt+V Ctrl+V
Kimi / Codex Ctrl+V Ctrl+V
Unidentified terminal, including OMP Ctrl+V Ctrl+V

Windows Alt+V aliases are normalized only for identified Pi, Kimi, Codex, or Claude Code. Unidentified Windows shells retain Alt+V. macOS Cmd+V with an image emits Ctrl+V even for unidentified terminals, matching OMP's native binding. Pi/Kimi provider hints now survive persistence, and the input bridge reads changing provider identity without recreating the terminal.

Scope: the provider CLI reads the native clipboard itself, so this works for local desktop CLI sessions. Remote desktop providers cannot read the local clipboard; browser clients retain text-only paste. This does not transfer image files or inspect custom provider keybindings. E2E verifies native clipboard presence and terminal input bytes, not attachment/upload inside every external CLI.


🏗️ Large Change Spec (Required if "Large Change" is checked)

1. Context & Business Logic

One clipboard boundary reports text and native image presence, and one terminal handler routes the platform gesture. Provider mappings follow the upstream Pi, OMP, Codex, Claude Code, and Kimi references recorded in docs/terminal/CLIPBOARD_INPUT.md. Native image bytes stay in the system clipboard; no temporary files or durable image state are introduced.

2. State Ownership & Invariants

Main owns clipboard access; the renderer terminal handler owns gesture routing and pending delivery; the provider CLI owns image attachment. Existing provider metadata remains the identity source.

  • Images emit raw provider key sequences, never bracketed text; text retains its existing encoding.
  • Late clipboard results cannot write after session disposal or apply an image mapping after provider identity changes.
  • Unidentified Windows shells preserve Alt+V semantics; browser/remote limitations remain explicit.

3. Verification Plan & Regression Layer

Unit/contract coverage verifies mapping, clipboard IPC, disposal, current provider identity, persisted Pi/Kimi hints, and text encoding. macOS E2E writes a real native image then verifies Cmd+V PTY bytes and subsequent bracketed text paste. Windows E2E covers Pi, Kimi, Codex, and Claude Code with both Alt+V and Ctrl+V; all four provider cases passed on Windows CI.

Final-version validation:

  • Complete CI run passed on final head faff57c6e34f08b30c6e73388dbd1faa00f53678, including all macOS shards, Ubuntu checks/E2E shards, Windows platform E2E, and Web Canvas continuity. gh pr checks 409 also confirmed all PR checks passed. The local first-run failure and independent recheck below remain recorded separately; this PR stays draft and the local full-gate checkbox stays unchecked.
  • pnpm line-check:staged, secret/naming/style/format checks, lint, and typecheck passed.
  • Related tests: 1087 passed, 3 skipped; Electron-native recovery: 8 passed.
  • OPENCOVE_REQUIRE_STAGED=1 pnpm pre-commit exited 1: full E2E had 322 passed, 83 skipped, 1 failed (27.1 minutes), with zero retries and no crash fallback.
  • The sole failure was the existing app-header.primary-sidebar-toggle.spec.ts:390 Agent ring equality assertion: green at the first sample and amber after hover. Sidebar reveal, width, and idle checks passed. No clipboard operation occurred in that test.
  • That exact failed test passed independently without retries (5.4 seconds), using the same build and unchanged source. The first full-gate failure remains recorded; this draft does not claim a green full gate.
  • The macOS image/text paste regression passed in the full run (6.9 seconds). Four Windows provider tests were platform-skipped locally.
  • Windows platform CI passed on final head faff57c6e34f08b30c6e73388dbd1faa00f53678: 42 passed, 3 skipped. All four workspace-canvas.terminal-image-paste.windows.spec.ts cases (Pi, Kimi, Codex, and Claude Code) actually executed and passed. This platform result does not erase the local full-gate failure recorded above.
  • The gate's lint fixer added braces to one existing return guard; subsequent formatting and focused checks cover that semantics-preserving cleanup.

✅ Delivery & Compliance Checklist

  • My code passes the ultimate gatekeeper: pnpm pre-commit is completely green.
  • I have signed the CLA if required (see CLA.md).
  • I have included new tests to lock down the behavior (or explicitly stated why it's untestable).
  • I have strictly adhered to the DEVELOPMENT.md architectural boundaries.
  • I have attached a screenshot or screen recording (if this touches the UI).
  • I have updated the documentation accordingly (if adding a feature or changing a contract).

📸 Screenshots / Visual Evidence

The native clipboard E2E asserts exact PTY input bytes and no canvas image node, followed by preserved text paste; this change has no layout changes. The first failing sidebar screenshot and trace remain in the local Playwright report. Review-only images are not committed. CLA status is left to the repository check.

@DeadWaveWave
DeadWaveWave marked this pull request as ready for review September 10, 2026 15:57
@DeadWaveWave
DeadWaveWave merged commit 1f14d9b into main Sep 10, 2026
11 checks passed
@DeadWaveWave
DeadWaveWave deleted the codex/issues-402-406 branch September 10, 2026 16:22
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.

[BUG] Agent 终端无法粘贴图片 [BUG]

1 participant