Skip to content

Align OSC 52 behavior with terminal norms: default term:osc52=always, focus gating only in focus mode#2975

Open
Copilot wants to merge 3 commits intomainfrom
copilot/add-global-config-option-osc52
Open

Align OSC 52 behavior with terminal norms: default term:osc52=always, focus gating only in focus mode#2975
Copilot wants to merge 3 commits intomainfrom
copilot/add-global-config-option-osc52

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

This updates OSC 52 clipboard behavior to match common terminal defaults. term:osc52 now defaults to always, and focus checks are only enforced when mode is explicitly focus.

  • Behavior change in OSC 52 handler

    • handleOsc52Command now treats always as unrestricted with respect to window/block focus.
    • Focus gating (document.hasFocus() + block focus) is applied only when term:osc52 === "focus".
    • Default fallback in handler changed from "focus" to "always".
  • Configuration defaults

    • Updated default settings:
      • pkg/wconfig/defaultconfig/settings.json: "term:osc52": "always"
  • Docs alignment

    • Updated docs/docs/config.mdx to reflect:
      • default is always
      • always allows writes anytime
      • focus requires focused window + focused block
    • Updated default config example accordingly.
  • Targeted test coverage

    • Expanded frontend/app/view/term/osc-handlers.test.ts:
      • verifies focus still rejects unfocused block
      • verifies always allows unfocused block
      • verifies always allows writes when window is unfocused
      • verifies unset value defaults to always
const osc52Mode = globalStore.get(getOverrideConfigAtom(blockId, "term:osc52")) ?? "always";

if (osc52Mode === "focus") {
    const isBlockFocused = termWrap.nodeModel ? globalStore.get(termWrap.nodeModel.isFocused) : false;
    if (!document.hasFocus() || !isBlockFocused) {
        return true;
    }
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 4, 2026

Deploying waveterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: ac855da
Status: ✅  Deploy successful!
Preview URL: https://db99c71b.waveterm.pages.dev
Branch Preview URL: https://copilot-add-global-config-op.waveterm.pages.dev

View logs

Copilot AI changed the title [WIP] Add global config option for term:osc52 handling Add configurable OSC 52 focus policy (term:osc52) with block-level override support Mar 4, 2026
Copilot finished work on behalf of sawka March 4, 2026 06:45
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Copilot AI changed the title Add configurable OSC 52 focus policy (term:osc52) with block-level override support Align OSC 52 behavior with terminal norms: default term:osc52=always, focus gating only in focus mode Mar 4, 2026
Copilot finished work on behalf of sawka March 4, 2026 18:53
@sawka sawka marked this pull request as ready for review March 4, 2026 22:35
return false;
});

handleOsc52Command("c;SGVsbG8=", "block-1", true, { nodeModel: { isFocused: {} } } as any);
Copy link
Contributor

Choose a reason for hiding this comment

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

WARNING: Test mock may not accurately represent the actual atom behavior

The isFocused field is being set to an empty object {}, but in the actual implementation (line 127 of osc-handlers.ts), globalStore.get(termWrap.nodeModel.isFocused) expects an atom. The test currently passes because the mock's default return value is false, not because it's properly testing an unfocused atom.

Consider creating a proper mock atom that explicitly returns false when accessed via globalStore.get() to make the test more robust and clear about what it's testing.

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 4, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
frontend/app/view/term/osc-handlers.test.ts 53 Test mock may not accurately represent actual atom behavior - isFocused should be a proper atom mock
Files Reviewed (10 files)
  • docs/docs/config.mdx - Documentation updated correctly
  • frontend/app/view/term/osc-handlers.test.ts - 1 issue (test mock accuracy)
  • frontend/app/view/term/osc-handlers.ts - Implementation looks correct
  • frontend/types/gotypes.d.ts - Type definitions properly generated
  • pkg/waveobj/metaconsts.go - Constant added correctly
  • pkg/waveobj/wtypemeta.go - Type metadata added correctly
  • pkg/wconfig/defaultconfig/settings.json - Default value set correctly
  • pkg/wconfig/metaconsts.go - Config constant added correctly
  • pkg/wconfig/settingsconfig.go - Settings type with proper enum validation
  • schema/settings.json - Schema correctly defines enum values

Fix these issues in Kilo Cloud

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.

2 participants