Skip to content

feat(cli): Cursor-only display_links MCP for unmangled URLs (re-cut #1564) - #2741

Open
heavygee wants to merge 19 commits into
tiann:mainfrom
heavygee:feat/display-links-recut-1564
Open

heavygee wants to merge 19 commits into
tiann:mainfrom
heavygee:feat/display-links-recut-1564

Conversation

@heavygee

@heavygee heavygee commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Re-cut of stalled #1564 from current upstream/main: Cursor-only MCP display_links paints constructed http(s) URL cards into SessionChat without a fake user turn (Cursor-routed doubled-letter URL recall → tap-404s).
  • CLI / script fallback: hapi display-links and scripts/tooling/hapi-display-links.mjs (same idea as hapi-display-image.mjs).
  • Web + iOS/Android display-links blocks render <a href> / copy cards from stored bytes; deny javascript: / data: / vbscript: / file:. Fixture projection bumps to fixtureVersion 2 for the new block shape.
  • Left sessionCitation.ts alone (Wave 0 #2737). No fork-only tools.

Test plan

  • Shared parse/validate + redaction tests
  • MCP registration: display_links on Cursor flavor only; paints concatenated href bytes; rejects javascript
  • STDIO bridge / buildHapiMcpBridge auto-approve for display_links
  • Web normalize + ToolMessage / ShareTurn / markdown export tests
  • bun run typecheck:cli + bun run typecheck:web
  • CI on tip (incl. re-check stale iOS app-build from feat(cli): Cursor-only display_links MCP for unmangled URLs #1564)
  • Cursor ACP dogfood: display_links with concatenated landmine href; tap card; address bar has tiann

Issues

Fixes #1516

Supersedes #1564 (CONFLICTING tip frozen since 2026-09-16) — please close #1564 in favor of this re-cut.

Made with Cursor

Re-cut of stalled tiann#1564 from upstream/main. Cursor-routed agents drop
doubled letters when recalling hosts; paint constructed http(s) href
cards via MCP display_links / hapi display-links without a fake user turn.
Includes web + native display-links blocks and fixtureVersion 2 projection.

Fixes tiann#1516

Co-authored-by: Cursor <[email protected]>
heavygee added a commit to heavygee/hapi that referenced this pull request Dec 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Needs changes

Review mode: initial

Requirement — Pass

Remote Cursor operators need to open the exact URL supplied by a tool or script from their current chat. Cursor can drop characters in visible assistant text, and the existing workaround adds a user turn to the transcript. A dedicated link card fits HAPI's inline output model.

Evidence

  • Issue #1516 documents the malformed URLs, the fake user turn workaround, and the requirement for a shell fallback on flavors without the MCP tool. #1516
  • The base repository already uses agent-authored messages for inline media. cli/src/claude/utils/startHappyServer.ts:344, cli/src/api/apiSession.ts:1211

Approach — Needs changes

The dedicated agent payload can preserve the supplied URL and keep it out of the user transcript. The delivery design couples the shell fallback to Cursor-only registration, so the fallback cannot work on flavors such as Claude. It also gives every concurrent Cursor bridge the same tool name, allowing a misrouted call to publish into another chat.

Evidence

  • Both shell entry points invoke the same HTTP MCP tool that the server registers only for Cursor. cli/src/commands/displayLinks.ts:283, scripts/tooling/hapi-display-links.mjs:245, cli/src/claude/utils/startHappyServer.ts:120, cli/src/claude/utils/startHappyServer.ts:590
  • Concurrent Cursor bridges stay enabled in the shared config. The shared protocol describes Cursor's duplicate-tool routing behavior, while the STDIO bridge exports a fixed name and the HTTP handler publishes through its bound client without checking the caller's session. cli/src/cursor/utils/cursorMcpOverlay.ts:294, shared/src/displayLinks.ts:162, cli/src/codex/happyMcpStdioBridge.ts:325, cli/src/claude/utils/startHappyServer.ts:600

Suggestions

  • Keep agent-visible MCP discovery Cursor-only and route both shell entry points through a session-bound local CLI handler available to the supported flavors. Reuse the same URL validation and agent-message emitter.
  • Give each Cursor bridge a session-specific tool name and verify the caller's session against the destination before emitting. Verify that two simultaneous Cursor sessions each receive only their own card.

Code — Not reviewed

Line-by-line review was skipped because the delivery approach needs changes.

Testing

Not run (automation; PR code execution is prohibited).

  • At the fixed head, GitHub's core and fixture drift checks passed. CLI, web, integration, and native checks were still in progress.
  • The PR test plan leaves the real Cursor ACP invocation and link tap unchecked. This review used static inspection only.

HAPI Bot

@github-actions github-actions Bot added the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026
Restore the tip-matched Cursor collision guard: advertise
hapi_<sessionId>_display_links, require matching sessionId before paint,
and keep fail-closed exact-copy redaction. Addresses Approach findings on tiann#2741.

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot removed the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Needs changes

Review mode: follow-up after new commits

Requirement — Pass

Remote Cursor operators need to open the exact URL supplied by a tool or script from SessionChat. Cursor can drop characters from URLs in assistant prose, and the current workaround adds a fake user turn. A dedicated link card fits HAPI's existing inline output model.

Evidence

  • Issue #1516 documents malformed URLs, the fake user turn workaround, and the acceptance criterion for a shell fallback on flavors without the MCP tool. #1516
  • The base implementation already publishes inline media as an agent-authored chat message. cli/src/claude/utils/startHappyServer.ts:343, cli/src/api/apiSession.ts:1211

Approach — Needs changes

Per-session MCP tool names and a destination check address the prior Cursor routing concern. Both shell entry points still depend on the Cursor-only tool, so they cannot publish a card from a Claude or OpenCode session. The design also expands URL display into credential delivery and stores submitted credentials in ordinary chat history.

Evidence

  • The Cursor bridge forwards the per-session tool name, and the HTTP handler verifies the supplied session ID before emitting. cli/src/codex/happyMcpStdioBridge.ts:333, cli/src/claude/utils/startHappyServer.ts:633
  • Both shell entry points invoke the same per-session HTTP MCP tool. Registration defaults to Cursor, and the server test confirms the tool is absent for OpenCode. cli/src/commands/displayLinks.ts:283, scripts/tooling/hapi-display-links.mjs:254, cli/src/claude/utils/startHappyServer.ts:127, cli/src/claude/utils/startHappyServer.test.ts:1290
  • The tool schema explicitly invites secrets and tokens. The handler includes the submitted values in the agent message, which the hub persists in session history. Markdown export omits the exact-copy value from its output. cli/src/claude/utils/startHappyServer.ts:277, cli/src/claude/utils/startHappyServer.ts:635, hub/src/socket/handlers/cli/sessionHandlers.ts:216, web/src/lib/sessionExport/markdown.ts:99

Suggestions

  • Keep MCP discovery Cursor-only and have both shell entry points call a session-bound local handler available on the supported flavors. Reuse the URL validation and agent-message emitter, and verify that the shell command produces a clickable card in a non-Cursor session.
  • Limit this PR to HTTP(S) link cards. Address credential delivery separately with explicit access and retention requirements before directing agents to submit secrets.

Code — Not reviewed

Line-by-line review stopped at the approach stage because the shell fallback remains unavailable on non-Cursor flavors and the design persists credentials in session history.

Testing

Not run (automation; PR code execution is prohibited).

  • At fixed head 9932ab2, GitHub's core and fixture drift checks passed. The CLI, web, browser, integration, and native checks were queued or in progress when observed.
  • This review used static inspection. The PR test plan still leaves the real Cursor ACP invocation and link tap unchecked.

HAPI Bot

@github-actions github-actions Bot added the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026
Drop exact-copy credential submission from this PR and route shell
fallbacks through POST /display-links on the session loopback server so
Claude/OpenCode can paint without Cursor MCP discovery.

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot removed the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Needs changes

Review mode: follow-up after new commits

Requirement — Pass

Remote Cursor users need to open the exact URL supplied by a tool or script from SessionChat. Cursor can drop characters in assistant prose, and the current workaround adds a fake user turn. An agent-authored link card fits HAPI’s existing inline output model, with a shell fallback for flavors without MCP discovery.

Evidence

  • Issue #1516 documents the broken links, the user-message workaround, and the acceptance criteria for exact hrefs and a shell fallback. #1516
  • The base CLI already publishes inline media as an agent-authored chat message in cli/src/claude/utils/startHappyServer.ts:343 and cli/src/api/apiSession.ts:1211.

Approach — Needs changes

The per-session Cursor tool and shared URL emitter address routing, and the loopback route lets non-Cursor sessions with a HappyServer publish cards. Both shell entry points still require that server, so the advertised all-flavor fallback fails in Pi sessions when peer tools are disabled. The PR also adds a copy-only text protocol and UI across all three clients even though both publishing paths now emit URLs only.

Evidence

  • Cursor MCP and the loopback route share a publisher that checks the destination session and emits a URL payload with an empty texts array. cli/src/claude/utils/startHappyServer.ts:139, cli/src/claude/utils/startHappyServer.ts:652, cli/src/claude/utils/startHappyServer.ts:1052
  • Both shell entry points stop when the session has no hapiMcpUrl. Pi skips the only server that publishes that metadata when HAPI_DISABLE_PEER_TOOLS is enabled. cli/src/commands/displayLinks.ts:202, scripts/tooling/hapi-display-links.mjs:197, cli/src/pi/runPi.ts:249, cli/src/claude/utils/startHappyServer.ts:1109
  • The new conformance fixture makes exact-copy text part of the client contract, and the PR adds copy controls and export handling for that field. shared/fixtures/chat/cursor-display-links.json:2, web/src/components/AssistantChat/messages/ToolMessage.tsx:65, ios/Hapi/Features/Chat/Blocks/DisplayLinksBlockView.swift:39, android/app/src/main/kotlin/app/hapi/companion/feature/chat/blocks/DisplayLinksBlockView.kt:35, web/src/lib/sessionExport/markdown.ts:97

Suggestions

  • Make the session-bound shell endpoint available independently of MCP server startup and peer-tool settings. Keep Cursor-only MCP discovery and reuse the shared URL publisher. Verify a shell invocation from a Pi session with peer tools disabled.
  • Limit the new payload, renderers, and generated conformance fixtures to HTTP(S) link cards. Remove the copy-only text field and its clipboard and export handling from this PR.

Code — Not reviewed

Line-by-line review stopped at the approach stage because the shell fallback depends on optional server startup and the new client contract extends beyond URL cards.

Testing

Not run (automation; PR code execution is prohibited).

  • At fixed head d28bb2e, GitHub reported success for a core check and the fixture drift gate. Other checks, including CLI, web, integration, and Android transcript layout, were still in progress when observed.
  • This review used static inspection. The snapshot’s test plan leaves the real Cursor ACP invocation and link tap unchecked. The new non-Cursor test starts HappyServer directly, so it does not cover shell invocation from a launcher that skips server startup.

HAPI Bot

@github-actions github-actions Bot added the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026
Strip exact-copy fields from payload/UI/fixtures/native, and always start
HappyServer for Pi (display_image only when peer tools are disabled) so
shell POST /display-links works without Cursor MCP discovery.

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot removed the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Needs changes

Review mode: follow-up after new commits

Requirement — Pass

Remote Cursor users need tappable SessionChat links that preserve URLs constructed by tools or scripts. Cursor can drop characters when recalling a URL in assistant prose, and the current workaround inserts a fake user turn. An agent-authored link card and a shell fallback for sessions without the MCP tool fit HAPI’s existing inline output model.

Evidence

  • Issue #1516 documents the broken links, the fake user turn workaround, and the acceptance criteria for exact hrefs and a shell fallback. #1516
  • The base CLI already publishes inline media as an agent-authored chat message through cli/src/claude/utils/startHappyServer.ts:343 and cli/src/api/apiSession.ts:1211.

Approach — Needs changes

The per-session Cursor tool and shared URL publisher fit the use case. The current head removes the copy-only text payload and starts HappyServer in Pi even when peer tools are disabled. The shell fallback still depends on HappyServer, which ordinary terminal-started Copilot and Cursor sessions do not start in local mode. Both shell entry points therefore fail in a fresh local session even though it has a valid HAPI session ID.

Evidence

  • The shared publisher emits URL cards as agent messages, and Pi now starts the listener independently of the peer-tool flag. cli/src/claude/utils/startHappyServer.ts:139, cli/src/pi/runPi.ts:249
  • Both shell entry points require hapiMcpUrl, which HappyServer publishes at startup. cli/src/commands/displayLinks.ts:202, scripts/tooling/hapi-display-links.mjs:197, cli/src/claude/utils/startHappyServer.ts:1109
  • Terminal-started Copilot and Cursor default to local mode. Their local launchers inherit the session environment and start the native agent directly. The bridge is initialized by the remote launchers. cli/src/copilot/runCopilot.ts:89, cli/src/copilot/copilotLocal.ts:37, cli/src/copilot/copilotRemoteLauncher.ts:95, cli/src/cursor/runCursor.ts:67, cli/src/cursor/cursorLocal.ts:85, cli/src/cursor/cursorAcpRemoteLauncher.ts:257

Suggestions

  • Give the shell publisher a session-scoped endpoint whose lifetime follows the wrapped HAPI session across local and remote modes. Reuse the URL publisher and keep MCP discovery limited to Cursor ACP. Verify that both shell entry points paint a card from a fresh terminal-started Copilot or Cursor session before any handoff.

Code — Not reviewed

Code review stopped at the approach stage because the shell transport is unavailable in supported local sessions.

Testing

Not run (automation; PR code execution is prohibited).

  • At fixed head c57a38d, GitHub reported success for core, the fixture drift gate, and windows-codex-mcp. CLI and web unit tests, browser, integration, wrapper parity, and Android build and transcript checks were still in progress when observed.
  • Static review only. The Pi startup test verifies a mocked HappyServer call, and the PR test plan leaves the end-to-end Cursor ACP invocation and link tap unchecked.

HAPI Bot

@github-actions github-actions Bot added the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026
Start a session-scoped POST /display-links publisher in terminal-local
Cursor and Copilot modes so shell fallback does not depend on HappyServer.

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot removed the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Needs changes

Review mode: follow-up after new commits

Requirement — Pass

Remote Cursor users need tappable SessionChat links that preserve the supplied URL when Cursor drops characters in assistant prose. An agent-authored card keeps the link clickable without adding a fake user turn. The shell fallback gives sessions without the MCP tool the same capability.

Evidence

  • Issue #1516 documents broken tap targets, the fake user turn workaround, and acceptance criteria for preserving the supplied href and providing a shell fallback. #1516
  • The base CLI already publishes inline media as agent-authored chat output. cli/src/claude/utils/startHappyServer.ts:343

Approach — Needs changes

The Cursor-only MCP tool and shared publisher fit the use case. The new listener covers fresh terminal starts, but both shell commands fail after a Cursor ACP or Copilot session hands control back to the terminal. The remote bridge replaces the published loopback URL and closes its listener on handoff, leaving the hub pointing at a closed port.

Evidence

  • Cursor and Copilot start the shell listener only when the wrapper starts in local mode. cli/src/cursor/runCursor.ts:73, cli/src/copilot/runCopilot.ts:96
  • The shell listener and remote MCP bridge publish different ports to the same hapiMcpUrl field. Both shell commands read that field for every invocation. cli/src/claude/utils/startHappyServer.ts:213, cli/src/claude/utils/startHappyServer.ts:1173, cli/src/commands/displayLinks.ts:202, scripts/tooling/hapi-display-links.mjs:197
  • The remote launchers stop their bridges during cleanup before the same session re-enters local mode. The mode-change handler preserves the existing URL. cli/src/cursor/cursorAcpRemoteLauncher.ts:1533, cli/src/copilot/copilotRemoteLauncher.ts:362, cli/src/agent/loopBase.ts:59, cli/src/agent/runnerLifecycle.ts:238

Suggestions

  • Start the shell listener once per wrapped session regardless of starting mode and give shell callers a dedicated endpoint that survives ownership changes. Keep MCP discovery limited to Cursor ACP and reuse the same publisher. Verify both shell entry points before and after a local-to-remote-to-local handoff and after a remote-started session hands off to local control.

Code — Not reviewed

Code review stopped at the approach stage because the shell endpoint does not survive an ownership handoff.

Testing

Not run (automation; PR code execution is prohibited).

  • Static review only. At fixed head c8f53ee, the fixture drift gate passed. The CLI and web unit suites, integration, browser, wrapper parity, and native checks were still pending when checked.
  • The new loopback test calls the listener directly and does not exercise hub endpoint discovery across a handoff. The PR test plan also leaves the end-to-end Cursor ACP invocation and link tap unchecked.

HAPI Bot

@github-actions github-actions Bot added the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026
Always start the shell loopback for Cursor/Copilot and publish a dedicated
metadata URL so remote HappyServer swaps cannot strand shell callers.

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot removed the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026
Add the durable shell endpoint field to Metadata schema and summaries so
CLI typecheck accepts HappyServer / loopback publishers.

Co-authored-by: Cursor <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Needs changes

Review mode: follow-up after new commits

Requirement — Pass

Remote Cursor users need tappable SessionChat links that preserve the supplied URL and appear as agent output. This addresses broken links when Cursor drops characters in assistant prose and removes the need for the fake user-message workaround. A shell fallback serves agents without the MCP tool.

Evidence

  • Issue #1516 documents the broken tap targets, the workaround, and the acceptance criteria for preserving the href and providing a shell fallback. #1516
  • The base CLI already publishes inline media as agent-authored output. cli/src/claude/utils/startHappyServer.ts:343

Approach — Needs changes

The dedicated listener resolves the previous handoff problem for Cursor and Copilot. Other wrappers still depend on an optional, launcher-scoped MCP bridge. After an OpenCode handoff, both shell commands keep dialing the first bridge's closed port even though the new bridge is running. Antigravity's supported stream-JSON path starts no listener, so the fallback is unavailable there.

Evidence

  • Cursor and Copilot now start a dedicated listener before entering their ownership loops. cli/src/cursor/runCursor.ts:73, cli/src/copilot/runCopilot.ts:96
  • HappyServer preserves any existing hapiDisplayLinksUrl, including one published by a transient bridge. Both shell entry points prefer that field over the current hapiMcpUrl. cli/src/claude/utils/startHappyServer.ts:1174, cli/src/commands/displayLinks.ts:202, scripts/tooling/hapi-display-links.mjs:197
  • OpenCode uses separate local and remote launchers for the same session, and each closes its bridge when it exits. cli/src/opencode/loop.ts:68, cli/src/opencode/opencodeLocalLauncher.ts:660, cli/src/opencode/opencodeRemoteLauncher.ts:2514
  • The CLI advertises the fallback for all flavors. Antigravity's stream-JSON path launches the headless driver without a bridge or dedicated shell listener. cli/src/ui/doctorInlineMedia.ts:229, cli/src/agy/agyRemoteLauncher.ts:5, cli/src/agy/legacyStreamJson/index.ts:17

Suggestions

  • Reserve hapiDisplayLinksUrl for listeners owned by the wrapped session. Let callers use the current hapiMcpUrl where the active bridge serves the shell route, and start a dedicated listener for supported paths without a bridge. Keep MCP discovery Cursor-only.

Code — Not reviewed

The review stopped at the approach stage because shell endpoint ownership still leaves supported session paths without a working fallback.

Testing

Not run (automation; PR code execution is prohibited).

  • Static review only. At fixed head 1cb34ba, drift-gate, Windows Codex MCP, and Android transcript layout on API 29 had passed. The CLI and web unit suites, integration, browser, wrapper parity, and iOS checks were still pending.
  • The loopback test posts directly to the listener. Coverage is missing for hub endpoint discovery across an OpenCode handoff and for the fallback on Antigravity stream-JSON. The PR test plan also leaves the end-to-end Cursor ACP invocation and link tap unchecked.

HAPI Bot

@github-actions github-actions Bot added the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026
…e/AGY

Stop HappyServer from advertising hapiDisplayLinksUrl (fixes Claude wrapper
parity), prefer hapiMcpUrl for shell, and start session-owned loopback on
OpenCode/Antigravity so handoffs and stream-JSON still have a shell route.

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot removed the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Needs changes (3 Major, 3 Minor)

Review mode: follow-up after new commits

Requirement — Pass

Remote Cursor users need tappable SessionChat links that preserve the supplied URL and appear as agent output. This addresses broken links in Cursor prose and removes the need to inject a user message. A shell fallback serves flavors without the MCP tool.

Evidence

  • Issue #1516 documents the broken tap targets, the user-message workaround, and the acceptance criteria for URL preservation and shell access. #1516
  • The base CLI already publishes inline media as agent output, but has no equivalent for publishing structured URL cards. cli/src/claude/utils/startHappyServer.ts:343

Approach — Pass

A Cursor-only MCP tool and shell commands can share a session-bound publisher. A dedicated agent payload lets each client render the supplied URLs directly, and session-owned listeners can keep shell access available across launcher handoffs.

Evidence

  • The publisher validates the session and URLs before emitting agent output. Cursor advertises a distinct tool name for each session. cli/src/claude/utils/startHappyServer.ts:139, cli/src/claude/utils/startHappyServer.ts:1050
  • OpenCode and Antigravity now start shell listeners at wrapper scope, including Antigravity's stream-JSON path. cli/src/opencode/runOpencode.ts:106, cli/src/agy/runAgy.ts:71
  • The generated chat fixture defines the link block and verifies that the client projection retains the href. shared/fixtures/chat/cursor-display-links.json

Code — Reviewed

Both shell entry points can still fail after a handoff, and fresh local Grok and Kimi sessions have no endpoint. The review also found issues with the loopback handlers, unread tracking, and Android URL parity.

  • [Major] Use the session listener after a launcher closes its MCP bridge — cli/src/commands/displayLinks.ts:204
  • [Major] Provide a shell endpoint for local Grok and Kimi sessions — cli/src/ui/doctorInlineMedia.ts:229
  • [Major] Avoid opening an image-reading MCP endpoint for Pi's shell fallback — cli/src/pi/runPi.ts:255
  • [Minor] Bound the loopback request body before buffering it — cli/src/claude/utils/startHappyServer.ts:154
  • [Minor] Count link cards as unread output — cli/src/claude/utils/startHappyServer.ts:145
  • [Minor] Keep Android from dropping URLs that the publisher accepts — android/core/protocol/src/main/kotlin/app/hapi/protocol/chat/NormalizeAgent.kt:46

Testing

Not run (automation; PR code execution is prohibited).

  • Static review only. No PR code, tests, or builds were run locally.
  • At 22dadd8, fixture drift, core, CLI and web unit suites, integration, browser, wrapper parity, Windows Codex MCP, iOS package tests, Mac Catalyst, and both Android transcript-layout checks passed. The iOS simulator check was queued.
  • The Android build job failed in :app:testDebugUnitTest with six Robolectric MavenArtifactFetcher errors. The APK assembly and lint step was skipped. https://github.com/tiann/hapi/actions/runs/46906539045/job/143550137951
  • The loopback tests POST directly to the listeners. They do not exercise command discovery with a stale bridge URL, and the PR test plan leaves the end-to-end Cursor ACP invocation and link tap unchecked.

HAPI Bot

Comment thread cli/src/commands/displayLinks.ts Resolved
Comment thread cli/src/ui/doctorInlineMedia.ts Resolved
Comment thread cli/src/pi/runPi.ts Resolved
@github-actions github-actions Bot added the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026
Prefer hapiDisplayLinksUrl after handoffs leave a stale hapiMcpUrl, start
session-owned loopbacks for Grok/Kimi and peer-tools-off Pi, bound loopback
bodies, count link cards as unread, and align Android href validation with
WHATWG path brackets.

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot removed the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Needs changes (1 Major, 6 Minor)

Review mode: follow-up after new commits

Requirement — Pass

Remote Cursor operators need tappable links that preserve caller-supplied URLs and appear as agent output. The shell fallback extends that capability to wrappers without the MCP tool.

Evidence

  • Issue #1516 documents broken tap targets from Cursor prose, the user-message workaround, and the URL round-trip acceptance criteria. #1516
  • The base CLI publishes structured inline media as agent output and has no equivalent URL publisher. cli/src/claude/utils/startHappyServer.ts:343

Approach — Pass

A session-bound publisher and dedicated agent payload let clients render the supplied href directly. A session-owned shell listener keeps the feature available across launcher handoffs.

Evidence

  • The publisher validates URLs and emits agent output, and Cursor advertises a distinct tool name per HAPI session. cli/src/claude/utils/startHappyServer.ts:139 and :1067
  • The wrapper owns the shell listener, while the generated fixture pins the URL data projected by the web and native clients. cli/src/cursor/runCursor.ts:73 and shared/fixtures/chat/cursor-display-links.json

Code — Reviewed

The follow-up fixes listener preference after handoff, adds local Grok and Kimi listeners, and keeps Pi's shell listener separate when peer tools are disabled. Loopback authorization and several shell and client integration issues remain.

  • [Major] Authenticate local callers before publishing agent output — cli/src/claude/utils/startHappyServer.ts:143
  • [Minor] Resolve an accepted self prefix directly to the current session — cli/src/commands/displayLinks.ts:171
  • [Minor] Honor HAPI_HOME in the standalone helper — scripts/tooling/hapi-display-links.mjs:19
  • [Minor] Normalize the scheme before opening Android links — android/app/src/main/kotlin/app/hapi/companion/feature/chat/blocks/DisplayLinksBlockView.kt:62
  • [Minor] Keep third-party MCP arguments out of HAPI-specific redaction — shared/src/displayLinks.ts:144
  • [Minor] Apply the intended approval policy on Cursor's actual tool path — cli/src/codex/utils/buildHapiMcpBridge.ts:127
  • [Minor] Provide a copy action on the Android link card — android/app/src/main/kotlin/app/hapi/companion/feature/chat/blocks/DisplayLinksBlockView.kt:55

Testing

Not run (automation; PR code execution is prohibited).

  • Static review of fixed head 7e3768d. No PR code, tests, or builds were run locally.
  • GitHub reported passing fixture drift, core, CLI and web unit, integration, wrapper parity, Windows Codex MCP, Android build, and both Android transcript-layout checks. Browser and iOS jobs were still in progress.
  • The PR test plan leaves the end-to-end Cursor ACP tool invocation and link tap unchecked. The shell tests cover argument parsing and direct listener calls without exercising full command discovery.

HAPI Bot

Comment thread cli/src/commands/displayLinks.ts Resolved
Comment thread scripts/tooling/hapi-display-links.mjs Resolved
Comment thread shared/src/displayLinks.ts Resolved
@github-actions github-actions Bot added the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026
Authenticate POST /display-links with a happy-home token file (0600), not
hub metadata. Also resolve self-prefixes without a list scan and honor
HAPI_HOME in the standalone helper.

Co-authored-by: Cursor <[email protected]>
@github-actions github-actions Bot removed the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026
heavygee and others added 5 commits December 2, 2026 15:44
Scope redaction/auto-approval to HAPI per-session tool names, lowercase
http(s) schemes for Android ACTION_VIEW, and add an accessible Copy action
on the Android link card.

Co-authored-by: Cursor <[email protected]>
…ix match

Split shouldRedactDisplayLinksToolInput (bare + per-session) from
isHapiDisplayLinksToolName (auto-approve only) so ACP "Display Links"
titles still whitelist args while other_server_display_links stays intact.

Co-authored-by: Cursor <[email protected]>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Needs changes (2 Major, 4 Minor)

Review mode: follow-up after new commits

Requirement — Pass

Remote Cursor operators need tappable links that preserve a caller-constructed URL and appear as agent output. The existing workaround adds a user turn, and the inline-media tools cannot publish a URL card.

Evidence

  • Issue #1516 documents the broken tap targets, the user-message workaround, and the URL round-trip acceptance criteria. #1516
  • The base inline-media publisher already emits structured agent output. cli/src/claude/utils/startHappyServer.ts:343

Approach — Pass

A structured agent payload lets clients render the supplied href directly. A per-session Cursor tool name addresses discovery collisions, and a wrapper-owned shell listener can survive launcher handoffs.

Evidence

  • The publisher checks the target session and sends a dedicated agent message. cli/src/claude/utils/startHappyServer.ts:139
  • The Cursor registration uses a per-session name, and the generated fixture pins the hrefs projected by web and native clients. cli/src/claude/utils/startHappyServer.ts:724 and shared/fixtures/chat/cursor-display-links.json

Code — Reviewed

The full merge-base diff at 5a9eada was reviewed statically. The shell POST token closes the previously reported shell ingress, but Cursor's HTTP MCP path still lacks caller authorization. The ACP approval rule also trusts a tool name without verifying its origin.

  • [Major] Authenticate the Cursor MCP publisher — cli/src/claude/utils/startHappyServer.ts:744
  • [Major] Require trusted tool identity for ACP auto-approval — cli/src/modules/common/permission/BasePermissionHandler.ts:128
  • [Minor] Resolve accepted prefixes to the current session — scripts/tooling/hapi-display-links.mjs:191
  • [Minor] Refresh the shell endpoint when reopening Pi sessions — cli/src/pi/runPi.ts:254
  • [Minor] Give Cursor a callable URL construction example — cli/src/modules/common/displayToolDescriptions.ts:14
  • [Minor] Add a copy action to iOS link cards — ios/Hapi/Features/Chat/Blocks/DisplayLinksBlockView.swift:15

Testing

Not run (automation; PR code execution is prohibited).

  • Static review only. No PR code, tests, or builds were run locally.
  • At 5a9eada, GitHub reported passing fixture drift, core, CLI and web unit, browser, integration, wrapper parity, Windows Codex MCP, iOS package and Mac Catalyst, Android build, and Android API 36 transcript-layout checks.
  • Android API 29 transcript-layout failed in HomeScreenTest.searchExpansionAndQuerySurviveStateRestoration. The iOS simulator job was canceled, which caused the app-build aggregate to fail.
  • The PR's test plan still leaves the end-to-end Cursor ACP call and link tap unchecked. The shell tests do not exercise session discovery through both entry points.

HAPI Bot

Comment thread scripts/tooling/hapi-display-links.mjs Resolved
Comment thread cli/src/pi/runPi.ts Resolved
@github-actions github-actions Bot added the codex-review:changes HAPI Bot: review requests changes label Dec 2, 2026
Require the session display-links token on Cursor MCP paint calls (stdio
bridge injects from the local token file). Scope ACP auto-approve to the
current session tool name or trusted HAPI MCP provenance. Also refresh Pi
shell loopback on every start, resolve self-prefix via detail GET only,
clarify finished-href construction, and add iOS Copy Link.

Co-authored-by: Cursor <[email protected]>
@heavygee

heavygee commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator Author

Tip review blocked: GitHub pull_request_target default policy

Tip 253b689ba already addresses the prior tip-matched review on 5a9eadaf0 (2 Major + 4 Minor); unresolved review threads are 0.

Tip Codex PR Review cannot start jobs. Latest tip attempt: https://github.com/tiann/hapi/actions/runs/47009493160 (startup_failure, 0 jobs). Annotation:

GitHub restricts pull_request_target on public repositories by default. To allow the event trigger, configure an Actions policy.

This matches GitHub's 2026-12-02 enforcement: https://github.blog/changelog/2026-12-02-github-actions-will-block-pull-request-target-by-default-in-affected-public-repo/

Unblock: repo/org Actions event policy allowing pull_request_target for .github/workflows/codex-pr-review.yml (fork PRs still need that event for the review secret). Empty tips / body-edit retriggers only re-hit the same block.

Prepare-only babysit holding for that admin action + any subsequent tip-matched findings.

Resolve CONFLICTING/DIRTY vs main. Single content conflict in
doctorInlineMedia: keep display_links Cursor-only doctor copy; adopt
main's packaged-install shellFallbackScriptPath rename (tiann#1920).

Co-authored-by: Cursor <[email protected]>
@heavygee

heavygee commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

Merge resolution note (0455f2c0f ← upstream/main)

Conflict re-merge for CONFLICTING/DIRTY only (not to clear checks). Tip Majors/Minors semantics from 253b689ba retained (MCP display-links token auth; ACP auto-approve exact session / trustedHapiMcp; Minors).

Conflict surface: one content conflict — cli/src/ui/doctorInlineMedia.ts. Everything else auto-merged (~298 files from main).

Resolution axes:

  1. Graft, not whole-file take. Kept this PR’s Cursor-only display_links doctor copy (hapi_<sessionId>_display_links + shell POST /display-links on the Agent inline path / Cursor ACP notes). Adopted upstream #1920 packaged-install axis: shellFallbackScriptPath (null when Bun-compiled / no checkout) instead of the stale shellFallbackAvailable name from our tip.

  2. Live call sites. runDoctorInlineMedia already used shellFallbackScriptPath above the conflict (session bridge command lines + packaged “not applicable” checks from main). Resolution only aligns the Agent-inline-path branch predicate + step-1 copy so those call sites stay consistent.

  3. Tests. cli/src/ui/doctorInlineMedia.test.ts from main (packaged-install expectations) kept; focused vitest green post-resolve.

No Approach chase / body-edit / CRC / ios-Codex rerun loops on this tip. Codex PR Review remains repo-wide pull_request_target startup_failure until Actions policy allows it.

Main's reuseIdentifier switch landed without this PR's .displayLinks
case; post-merge tip failed ios-simulator and mac-catalyst compile.

Co-authored-by: Cursor <[email protected]>
@heavygee

heavygee commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

CI follow-up after re-merge (0455f2c0f)

Surprise vs expectation: conflict cleared (MERGEABLE) and tip includes 3f98c36ed, but first CI on the merge tip still red on ios-simulator / mac-catalyst / app-build — not TranscriptTypography*.

Cause (tip-owned, merge seam): ChatTranscriptView.reuseIdentifier from main’s scrolling refactor is an exhaustive switch over ChatBlock. Auto-merge kept main’s cases and dropped this PR’s .displayLinks arm → switch must be exhaustive / missing .displayLinks(_).

Fix tip: <newsha> adds case .displayLinks: return "display-links" (render path already in ChatBlockCard). No Approach chase / no ios rerun loops — waiting fresh CI on the compile tip.

Codex tip-matched still blocked on repo-wide pull_request_target Actions policy.

@heavygee

heavygee commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

CI follow-up correction

Fix tip is 21dcb9252 (not a placeholder). Same diagnosis as the prior note: merge tip 0455f2c0f was MERGEABLE + contained 3f98c36ed, but failed compile on missing .displayLinks in ChatTranscriptView.reuseIdentifier. Waiting fresh CI on 21dcb9252.

@heavygee

heavygee commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

CI follow-up on 21dcb9252 (after compile fix)

MERGEABLE yes. Present completed checks:

Check Result
mac-catalyst pass (compile seam fixed)
TranscriptTypography* all pass (creditable to re-merge + 3f98c36ed)
ios-simulator / app-build fail
other product checks pass

Remaining red is not Typography and not DisplayLinks-touched: ComposerMentionPresentationTests.testProgrammaticPrefillAndSlashCommandKeepTheCaretAtTheEnd (XCTAssertTrue @ line 133). This tip does not diff composer/mention sources vs upstream/main. No ios rerun loop (per Meta).

Codex tip-matched still blocked on repo-wide pull_request_target Actions policy.

@heavygee

heavygee commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

ios discriminator: one rerun, no code change (21dcb9252)

Controlled experiment per Meta (same SHA, --failed once) to distinguish ComposerMention flake vs merge breakage.

Attempt Run testProgrammaticPrefillAndSlashCommandKeepTheCaretAtTheEnd Job
1 https://github.com/tiann/hapi/actions/runs/47283787778 (attempt 1) FAILED (~25.8s) — XCTAssertTrue(input.isFirstResponder) ios-simulator fail
2 same run, attempt 2 PASSED (4.200s); suite ComposerMentionPresentationTests passed ios-simulator fail for a different test

Attempt 2 sole failure in the log: SessionListCoveredRefreshTests.testCoveredListKeepsItsRowsAndRefreshesOnReturn — XCTAssertEqual 5 ≠ 3 (“covered list must not rebuild”). Not DisplayLinks / not the slash-command first-responder assertion.

Conclusion for the ComposerMention first-responder hypothesis: not deterministic on this tip — timing-sensitive. No tip fix for it. No further ios rerun from this babysit unless prescribed.

@heavygee

heavygee commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

ios-simulator is flaky-ungated on tip 21dcb9252 (not unfinished DisplayLinks)

Strengthening the thread record so “your PR is red” isn’t confused with tip product debt.

Same SHA, one controlled --failed rerun (no code change): https://github.com/tiann/hapi/actions/runs/47283787778

Attempt ComposerMention testProgrammaticPrefillAndSlashCommandKeepTheCaretAtTheEnd Other
1 FAIL — XCTAssertTrue(input.isFirstResponder) (~25.8s) job fail
2 PASS (4.200s); ComposerMentionPresentationTests suite green job fail on different test: SessionListCoveredRefreshTests.testCoveredListKeepsItsRowsAndRefreshesOnReturn (5 ≠ 3)

Main comparison: ios on main @ 3f98c36ed was green (https://github.com/tiann/hapi/actions/runs/47273994100). Tip contains that commit. Tip ios delta vs merge-base is Chat/Blocks DisplayLinks (+ protocol) only — zero composer/mention/covered-list sources. Filename search doesn’t prove hierarchy focus, but the discriminator already showed the first-responder assertion is timing-sensitive (fail then pass, same SHA).

Babysit stance (Parent/Meta):

  • Do not tip-fix ComposerMention or SessionListCoveredRefresh (ghost chase / flake).
  • Do not loop ios reruns to buy all-green — suite looks timing-sensitive / ungated; a different test fails most runs.
  • Red ios-simulator / app-build ≠ unfinished DisplayLinks work. #2741 may not reach all-green by tip effort.

Product tip state otherwise: MERGEABLE; Majors/Minors on tip; threads 0; mac-catalyst + TranscriptTypography green after re-merge. Codex tip-matched still blocked on repo-wide pull_request_target Actions policy.

@heavygee

heavygee commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator Author

Merge note (4515ae4c3 ← upstream/main @ ae40b5493)

One re-merge to pick up main GREEN (includes dbce75052) so inherited unit-cli/browser/test reds from the prior main-red window can clear.

Conflicts: none — clean auto-merge (128 files). Majors/Minors tip semantics retained (MCP display-links token auth; ACP trust scoped; .displayLinks reuseIdentifier arm).

Not in scope this tip: ios-simulator flaky-ungated (ComposerMention / SessionListCoveredRefresh) — no rerun loops / no tip fixes for those. Codex tip-matched still blocked on pull_request_target Actions policy.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-review:changes HAPI Bot: review requests changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): display_links MCP to paint clickable URLs into session chat

1 participant