Skip to content

fix(terminal): let an explicit Actions link-click choice win over the legacy flag - #25596

Closed
ggbdpq wants to merge 2 commits into
stablyai:mainfrom
ggbdpq:fix/link-click-actions-legacy-override
Closed

ggbdpq wants to merge 2 commits into
stablyai:mainfrom
ggbdpq:fix/link-click-actions-legacy-override

Conversation

@ggbdpq

@ggbdpq ggbdpq commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

ELI5

If an old Orca profile had the link popover turned off, choosing Actions for plain-click in Settings would immediately snap back to Leave to terminal, and plain-clicking links did nothing. The old off-switch was overriding the brand-new choice. Now an explicit choice always wins; the old flag only answers for profiles that never chose.

What Changed

terminalLinkClickBehaviorFor treated only 'open' and 'none' as explicit values of the new terminalLinkClickBehavior field; 'actions' fell through to the legacy terminalLinkActionPopoverEnabled check and resolved to 'none' when that flag was false. All three enum values are explicit user choices now — the legacy flag is consulted only when the new field is unset, which is the exact condition the function's docstring ("keeping older profiles behaviorally identical") was written for. Settings control and click handling read the same shared function, so the control no longer bounces and plain click works.

Why

The new field is the user's explicit intent in all three of its values; the legacy flag predates it and was only ever meant to answer for profiles that never set the new field. A read-side fix treats every consumer at once (the settings control, click handling, and the native-chat path all route through this function), rather than compensating at each write site. Older profiles (new field absent) resolve exactly as before, verified by the untouched existing cases.

Linked Issue

Fixes #25576

Transparency note

#25591 addresses the same issue from the write side (writing the legacy flag alongside the explicit choice, plus a loaded-settings migration). Both PRs were opened independently within the same window; this one fixes the resolution semantics at the shared read so every consumer and every write path is covered, and leaves the legacy flag untouched for profiles that never chose. Happy to defer to whichever approach the maintainers prefer.

Visual Proof

N/A for attached media in this environment (headless run). Behavior is pinned by tests: the new case (terminalLinkClickBehavior: 'actions' + terminalLinkActionPopoverEnabled: false → 'actions') was red before the change (expected 'none' to be 'actions'); the pre-existing explicit-open and legacy-only cases are untouched and still pass, pinning both the override and the old-profile behavior.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Commands actually run locally (macOS): target test file red→green (1 failed → 3 passed); adjacent link-click suites 36 passed total; pnpm tc exit 0; oxlint/oxfmt --check clean on both touched files. The settings-control bounce itself was not exercised in a running app — the control and the click path share this resolver, which is what the tests pin.

AI Disclosure

Investigation scoping and coding by GLM-5.3-Flash (ZCode agent); orchestrated, reviewed and committed by a main agent with the same model, human overseeing.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Two-line resolution change plus a test; no wire/compat impact (the setting's stored shape is untouched), no platform-specific paths, SSH unaffected.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
Walkthrough

The default settings no longer set terminalLinkClickBehavior to actions. The resolver returns explicit actions, open, and none preferences directly. Tests cover an explicit actions preference with the legacy flag disabled and the legacy fallback when the preference is absent.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Low · up to d0a23

The preference behavior is consistent with the intended change. The stale test description does not affect current behavior, but should be corrected to avoid confusion about the contract.

Architecture risk: Low · up to d0a23

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (ui) was modified; 3 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in src/renderer/src/components/terminal-pane/terminal-link-click-behavior.ts: terminalLinkClickBehaviorFor now returns 'actions' directly when selected, alongside the existing 'open' and 'none' cases; previously, 'actions' fell through to the legacy setting.
  • observed — Modified behavior in src/renderer/src/components/terminal-pane/terminal-link-click-behavior.test.ts: Imports getDefaultSettings for use in the added settings test.
  • observed — Modified behavior in src/renderer/src/components/terminal-pane/terminal-link-click-behavior.test.ts: Adds expectations that explicit 'actions' wins over a false legacy flag, and that a profile built by spreading defaults then setting the legacy flag to false resolves to 'none'. The accompanying comment describes the intended loaded-profile scenario.
  • observed — Modified behavior in src/shared/default-global-settings.ts: Removed the terminalLinkClickBehavior default set to 'actions'; the adjacent link-action popover and URL middle-click defaults remain.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: an explicit Actions choice takes precedence over the legacy flag.
Description check ✅ Passed The description explains the user impact, changes, rationale, linked issue, testing, and compatibility considerations. It addresses the required visual-proof section and includes the repository checkl…
Linked Issues check ✅ Passed Issue #25576 requires an explicit 'actions' choice to override terminalLinkActionPopoverEnabled: false, while profiles without the new field retain the legacy fallback. `terminalLinkClickBehaviorF…
Out of Scope Changes check ✅ Passed The resolver, default-setting change, and tests all support issue #25576. Removing the injected default is needed to distinguish an explicit user choice from a legacy profile with no choice. No unrela…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Resolver now honors every explicit choice — terminalLinkClickBehaviorFor returns 'actions', 'open', or 'none' directly and consults the legacy terminalLinkActionPopoverEnabled flag only when the new field is unset, so an explicit 'actions' is no longer clobbered to 'none' by a legacy false.
  • Regression test added — pins { terminalLinkActionPopoverEnabled: false, terminalLinkClickBehavior: 'actions' } → 'actions'. I confirmed this case is red against the pre-change resolver, so it is real coverage rather than theatre.

I traced the shared resolver's consumers (terminal-pane-mount-preparation.ts, BrowserTerminalLinkActionsSetting.tsx, and use-native-chat-link-actions.ts). The settings control and terminal click handling read the shared function and are fixed; the native-chat path's duplicate branch only handles the undefined legacy case, and its explicit-value path routes through the same resolver, so it is covered too. Legacy-only profiles resolve exactly as before, as the untouched existing cases pin. The unit test file passes locally (3/3).

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog

pullfrog Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Correction to the review above. I approved before tracing the load path; that was wrong. This change reintroduces the popover for legacy profiles that explicitly turned it off.

Why the read-side fix is not sufficient

terminalLinkClickBehaviorFor can only keep legacy behavior if the new field is genuinely undefined for a profile that never chose. But the persisted settings the renderer consumes are passed through normalizeLoadedGlobalSettings, which returns { ...defaults.settings, ... } (src/main/persistence/loading-store/normalize-loaded-global-settings.ts:58). The default settings set terminalLinkClickBehavior: 'actions' (src/shared/default-global-settings.ts:133). Nothing in src/main migrates or deletes this field, so for a legacy profile (new field absent on disk) the merge injects 'actions' — the undefined sentinel the fallback relied on no longer exists by the time the resolver runs.

Before this PR, that injected 'actions' did not match the 'open'/'none' checks, so the resolver fell through to terminalLinkActionPopoverEnabled === false ? 'none' : 'actions' and correctly honored the legacy opt-out. With the new early return (src/renderer/src/components/terminal-pane/terminal-link-click-behavior.ts:12-14), the injected 'actions' wins and the legacy opt-out is ignored.

Evidence

A scratch probe run through the real load path (prepareLoadedTerminalSettings → prepareLoadedProfileSettings → normalizeLoadedGlobalSettings) on a settings object with terminalLinkActionPopoverEnabled: false and no terminalLinkClickBehavior:

NORMALIZED { legacy: false, behavior: 'actions', resolved: 'actions' }

Expected 'none'. The added unit test passes only because it calls the resolver with an un-normalized object where the field is truly absent; it does not model what the store hands the renderer.

Path forward

The resolution semantics can't be fixed at the read layer alone, because an explicit 'actions' and the injected default are indistinguishable there. The load path needs to derive terminalLinkClickBehavior from terminalLinkActionPopoverEnabled for profiles that never set the new field (legacy false → 'none', true → 'actions'), or the 'actions' default must not be injected for profiles lacking the field. This is the migration carried by the sibling PR #25591; the two need to land together, or this PR needs to include that normalization.

Manual verification: the settings control's bounce is fixed, but the legacy opt-out regression is the more serious effect.

Pullfrog  | View workflow run | via Pullfrog | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@ggbdpq

ggbdpq commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

The self-correction was right and the follow-up ✅ was not — the defaults-injection path is exactly as described, and it defeated the read-side fix for silent legacy profiles. Confirmed by a red test through the real load shape ({ ...getDefaultSettings(home), terminalLinkActionPopoverEnabled: false } resolved to 'actions' before the fix). Fixed in d0a235133c: the default no longer carries terminalLinkClickBehavior at all — the resolver's own ': actions' fallback already owns default behavior, so the injected value was pure redundancy that erased the undefined sentinel the legacy opt-out depends on. Explicit choices from #25576 still win; silent legacy profiles keep their opt-out. Thank you for tracing the load path.

@pullfrog pullfrog 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.

ℹ️ No critical issues — the default removal is correct and necessary; one documentation nit in the new test.

Reviewed changes

  • Removed the injected terminalLinkClickBehavior default — buildDefaultSettings no longer seeds 'actions'. This is required for the resolver fix to preserve a legacy opt-out: normalizeLoadedGlobalSettings spreads defaults.settings beneath the parsed profile, so a default here would arrive indistinguishable from an explicit choice and the resolver would return 'actions' instead of the legacy 'none'.
  • Resolver honors all three explicit values — unchanged from the prior commit; the settings control, terminal click handling, and explicit-value native-chat path all route through it.
  • Added a stored-legacy-profile test — spreads getDefaultSettings under terminalLinkActionPopoverEnabled: false and pins 'none'.

I traced the default's source into the real load chain (prepareLoadedTerminalSettings builds defaults.settings from getDefaultSettings) and confirmed terminalLinkClickBehavior is not a retired key, so explicit writes persist. The focused test file plus constants, normalize-loaded-global-settings, and native-chat link-action suites all pass (50 tests).

ℹ️ Nitpicks

  • The new test's name and comment describe a state this commit removes: "keeps the legacy opt-out when defaults inject actions" and "arrives here with the default injected". After this commit getDefaultSettings no longer injects terminalLinkClickBehavior, so nothing is injected — and if an 'actions' default were injected, the resolver's explicit-value branch returns 'actions', so the test's 'none' assertion would fail. The test is a good guard against re-adding that default; just reword the name/comment to say so (e.g. "resolves a stored legacy profile to the legacy opt-out").

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@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.

🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-link-click-behavior.test.ts (1)

31-42: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Fix the stale comment in the new test.

The comment in lines 32-36 says that defaults inject actions into the profile. This PR removes that default, so the comment is now wrong. The test still checks the correct behavior. It guards against a defaults regression that would re-add terminalLinkClickBehavior.

Update the comment to say that defaults must not set terminalLinkClickBehavior. Update the test title in the same way.

📝 Proposed fix
-  it('keeps the legacy opt-out when defaults inject actions into a stored profile', () => {
-    // Mirrors the real load chain: normalize-loaded-global-settings spreads
-    // defaults.settings beneath the parsed profile, so a legacy profile that
-    // stored only terminalLinkActionPopoverEnabled: false (no
-    // terminalLinkClickBehavior on disk) arrives here with the default
-    // injected. The legacy opt-out must still win.
+  it('keeps the legacy opt-out when a stored profile is merged over defaults', () => {
+    // Mirrors the real load chain: defaults are spread beneath the parsed
+    // profile. Defaults must not set terminalLinkClickBehavior, or a legacy
+    // profile with only terminalLinkActionPopoverEnabled: false would lose
+    // its opt-out.

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ed44d6f0-f63f-4c09-bafd-7738b1050ad6
📥 Commits

Reviewing files that changed from the base of the PR and between 490271fcf6e9ea33a1d53fae566e9770360b09c4 and d0a235133c231947e59125f8e160b6a87a4704e0.

📒 Files selected for processing (2)
  • src/renderer/src/components/terminal-pane/terminal-link-click-behavior.test.ts
  • src/shared/default-global-settings.ts
💤 Files with no reviewable changes (1)
  • src/shared/default-global-settings.ts

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

@ggbdpq
ggbdpq force-pushed the fix/link-click-actions-legacy-override branch from d0a2351 to 52653ca Compare October 25, 2026 13:48
@ggbdpq

ggbdpq commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (1661c3c) and force-pushed — clean rebase, no semantic drift; upstream activity near this area (browser-side link tabs, connectors settings, permission refactor) doesn't touch the legacy-flag precedence path. Threads remain resolved; the targeted suite passes 4/4 and typecheck:node is clean on the new head. The re-push should surface the review bots for a fresh pass as well.

@nwparker gentle ping whenever you get a chance — happy to adjust anything.

… legacy flag

terminalLinkClickBehaviorFor only treated 'open' and 'none' as explicit,
so a profile with the legacy terminalLinkActionPopoverEnabled: false
snapped an explicit 'actions' choice back to 'none' — the settings
control bounced and plain-clicking links did nothing until the legacy
flag was hand-edited. All three values of the enum are explicit user
choices now; the legacy flag only answers for profiles that never set
the new field, which is what kept older profiles behaviorally identical
in the first place.

Fixes stablyai#25576

Generated-by: GLM-5.3-Flash (ZCode)
Follow-up to the resolver fix: normalizeLoadedGlobalSettings spreads
DEFAULT settings under every loaded profile, and the defaults carried
terminalLinkClickBehavior: 'actions' — so a legacy profile that opted
out via terminalLinkActionPopoverEnabled: false (and never set the new
field) reached the resolver as an explicit 'actions' and the new
early-return flipped its opt-out back on. The resolver's own ': actions'
fallback already owns the default behavior, so the injected value was
redundant; dropping the key restores genuine absence, and the explicit
choices from stablyai#25576 still win. Spotted by pullfrog's self-correction on
the PR.

Generated-by: GLM-5.3-Flash (ZCode)
@nwparker

Copy link
Copy Markdown
Contributor

Thanks @ggbdpq for the fix and the clear explanation of both approaches. #25576 is already fixed on main by #26853 (56d25b0). updateSettings now writes the legacy terminalLinkActionPopoverEnabled flag along with any explicit terminalLinkClickBehavior choice, so choosing Actions on a profile that opted out earlier sticks and doesn't snap back to Leave to terminal. If you can still reproduce it on the latest build, please comment or reopen.

@nwparker nwparker closed this Oct 26, 2026
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.

Plain-click "Actions" setting can't be re-enabled when legacy terminalLinkActionPopoverEnabled is false

2 participants