diff --git a/docs/docs/config.mdx b/docs/docs/config.mdx
index 6cdd59cdfa..cd29f8a7f4 100644
--- a/docs/docs/config.mdx
+++ b/docs/docs/config.mdx
@@ -73,6 +73,7 @@ wsh editconfig
| term:cursorblink | bool | when enabled, terminal cursor blinks (default false) |
| term:bellsound | bool | when enabled, plays the system beep sound when the terminal bell (BEL character) is received (default false) |
| term:bellindicator | bool | when enabled, shows a visual indicator in the tab when the terminal bell is received (default false) |
+| term:osc52 | string | controls OSC 52 clipboard behavior: `always` (default, allows OSC 52 at any time) or `focus` (requires focused window and focused block) |
| term:durable | bool | makes remote terminal sessions durable across network disconnects (defaults to false) |
| editor:minimapenabled | bool | set to false to disable editor minimap |
| editor:stickyscrollenabled | bool | enables monaco editor's stickyScroll feature (pinning headers of current context, e.g. class names, method names, etc.), defaults to false |
@@ -147,6 +148,7 @@ For reference, this is the current default configuration (v0.14.0):
"telemetry:enabled": true,
"term:bellsound": false,
"term:bellindicator": false,
+ "term:osc52": "always",
"term:cursor": "block",
"term:cursorblink": false,
"term:copyonselect": true,
diff --git a/frontend/app/view/term/osc-handlers.ts b/frontend/app/view/term/osc-handlers.ts
index dd8021ae1d..25fdf0e89b 100644
--- a/frontend/app/view/term/osc-handlers.ts
+++ b/frontend/app/view/term/osc-handlers.ts
@@ -3,7 +3,15 @@
import { RpcApi } from "@/app/store/wshclientapi";
import { TabRpcClient } from "@/app/store/wshrpcutil";
-import { getApi, getBlockMetaKeyAtom, getBlockTermDurableAtom, globalStore, recordTEvent, WOS } from "@/store/global";
+import {
+ getApi,
+ getBlockMetaKeyAtom,
+ getBlockTermDurableAtom,
+ getOverrideConfigAtom,
+ globalStore,
+ recordTEvent,
+ WOS,
+} from "@/store/global";
import * as services from "@/store/services";
import { base64ToString, fireAndForget, isSshConnName, isWslConnName } from "@/util/util";
import debug from "debug";
@@ -114,10 +122,13 @@ export function handleOsc52Command(data: string, blockId: string, loaded: boolea
if (!loaded) {
return true;
}
- const isBlockFocused = termWrap.nodeModel ? globalStore.get(termWrap.nodeModel.isFocused) : false;
- if (!document.hasFocus() || !isBlockFocused) {
- console.log("OSC 52: rejected, window or block not focused");
- return true;
+ 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) {
+ console.log("OSC 52: rejected, window or block not focused");
+ return true;
+ }
}
if (!data || data.length === 0) {
console.log("OSC 52: empty data received");
diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts
index 2d155a919c..6070f46bef 100644
--- a/frontend/types/gotypes.d.ts
+++ b/frontend/types/gotypes.d.ts
@@ -1119,6 +1119,7 @@ declare global {
"term:conndebug"?: string;
"term:bellsound"?: boolean;
"term:bellindicator"?: boolean;
+ "term:osc52"?: string;
"term:durable"?: boolean;
"web:zoom"?: number;
"web:hidenav"?: boolean;
@@ -1313,6 +1314,7 @@ declare global {
"term:cursorblink"?: boolean;
"term:bellsound"?: boolean;
"term:bellindicator"?: boolean;
+ "term:osc52"?: string;
"term:durable"?: boolean;
"editor:minimapenabled"?: boolean;
"editor:stickyscrollenabled"?: boolean;
diff --git a/pkg/waveobj/metaconsts.go b/pkg/waveobj/metaconsts.go
index 8399340cfe..873732de9d 100644
--- a/pkg/waveobj/metaconsts.go
+++ b/pkg/waveobj/metaconsts.go
@@ -121,6 +121,7 @@ const (
MetaKey_TermConnDebug = "term:conndebug"
MetaKey_TermBellSound = "term:bellsound"
MetaKey_TermBellIndicator = "term:bellindicator"
+ MetaKey_TermOsc52 = "term:osc52"
MetaKey_TermDurable = "term:durable"
MetaKey_WebZoom = "web:zoom"
diff --git a/pkg/waveobj/wtypemeta.go b/pkg/waveobj/wtypemeta.go
index da73892365..8cd5ed1d9b 100644
--- a/pkg/waveobj/wtypemeta.go
+++ b/pkg/waveobj/wtypemeta.go
@@ -125,6 +125,7 @@ type MetaTSType struct {
TermConnDebug string `json:"term:conndebug,omitempty"` // null, info, debug
TermBellSound *bool `json:"term:bellsound,omitempty"`
TermBellIndicator *bool `json:"term:bellindicator,omitempty"`
+ TermOsc52 string `json:"term:osc52,omitempty"`
TermDurable *bool `json:"term:durable,omitempty"`
WebZoom float64 `json:"web:zoom,omitempty"`
diff --git a/pkg/wconfig/defaultconfig/settings.json b/pkg/wconfig/defaultconfig/settings.json
index aead19efbe..2de1974716 100644
--- a/pkg/wconfig/defaultconfig/settings.json
+++ b/pkg/wconfig/defaultconfig/settings.json
@@ -30,6 +30,7 @@
"telemetry:enabled": true,
"term:bellsound": false,
"term:bellindicator": false,
+ "term:osc52": "always",
"term:cursor": "block",
"term:cursorblink": false,
"term:copyonselect": true,
diff --git a/pkg/wconfig/metaconsts.go b/pkg/wconfig/metaconsts.go
index 52dfa4514c..e031a493ea 100644
--- a/pkg/wconfig/metaconsts.go
+++ b/pkg/wconfig/metaconsts.go
@@ -56,6 +56,7 @@ const (
ConfigKey_TermCursorBlink = "term:cursorblink"
ConfigKey_TermBellSound = "term:bellsound"
ConfigKey_TermBellIndicator = "term:bellindicator"
+ ConfigKey_TermOsc52 = "term:osc52"
ConfigKey_TermDurable = "term:durable"
ConfigKey_EditorMinimapEnabled = "editor:minimapenabled"
diff --git a/pkg/wconfig/settingsconfig.go b/pkg/wconfig/settingsconfig.go
index 387598e899..69c531eb77 100644
--- a/pkg/wconfig/settingsconfig.go
+++ b/pkg/wconfig/settingsconfig.go
@@ -107,6 +107,7 @@ type SettingsType struct {
TermCursorBlink *bool `json:"term:cursorblink,omitempty"`
TermBellSound *bool `json:"term:bellsound,omitempty"`
TermBellIndicator *bool `json:"term:bellindicator,omitempty"`
+ TermOsc52 string `json:"term:osc52,omitempty" jsonschema:"enum=focus,enum=always"`
TermDurable *bool `json:"term:durable,omitempty"`
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
diff --git a/schema/settings.json b/schema/settings.json
index ad4cd83155..d60367bea3 100644
--- a/schema/settings.json
+++ b/schema/settings.json
@@ -151,6 +151,13 @@
"term:bellindicator": {
"type": "boolean"
},
+ "term:osc52": {
+ "type": "string",
+ "enum": [
+ "focus",
+ "always"
+ ]
+ },
"term:durable": {
"type": "boolean"
},