snow-flow 10.0.113 → 10.0.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli/cmd/tui/app.tsx +12 -7
- package/src/pty/index.ts +25 -4
- package/src/server/routes/tui-ws.ts +18 -14
package/package.json
CHANGED
package/src/cli/cmd/tui/app.tsx
CHANGED
|
@@ -115,11 +115,17 @@ export function tui(input: {
|
|
|
115
115
|
onUpgrade?: () => Promise<{ success: boolean; version?: string; error?: string }>
|
|
116
116
|
}) {
|
|
117
117
|
_onUpgrade = input.onUpgrade
|
|
118
|
+
const skipThemeDetection = !!process.env.OPENCODE_SKIP_THEME_DETECTION || !!process.env.OPENCODE_REMOTE_TUI
|
|
118
119
|
// promise to prevent immediate exit
|
|
119
120
|
return new Promise<void>(async (resolve) => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
let mode: "dark" | "light" = "dark"
|
|
122
|
+
if (skipThemeDetection) {
|
|
123
|
+
console.log("[snow-flow] skipping theme detection")
|
|
124
|
+
} else {
|
|
125
|
+
console.log("[snow-flow] detecting theme...")
|
|
126
|
+
mode = await getTerminalBackgroundColor()
|
|
127
|
+
console.log(`[snow-flow] theme: ${mode}`)
|
|
128
|
+
}
|
|
123
129
|
const onExit = async () => {
|
|
124
130
|
await input.onExit?.()
|
|
125
131
|
resolve()
|
|
@@ -178,6 +184,7 @@ export function tui(input: {
|
|
|
178
184
|
targetFps: 60,
|
|
179
185
|
gatherStats: false,
|
|
180
186
|
exitOnCtrlC: false,
|
|
187
|
+
// No remote: true — let opentui render normally to the PTY
|
|
181
188
|
useKittyKeyboard: process.env.OPENCODE_DISABLE_KITTY_KEYBOARD ? undefined : {},
|
|
182
189
|
consoleOptions: {
|
|
183
190
|
keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }],
|
|
@@ -187,7 +194,7 @@ export function tui(input: {
|
|
|
187
194
|
})
|
|
188
195
|
},
|
|
189
196
|
},
|
|
190
|
-
},
|
|
197
|
+
} as Parameters<typeof render>[1],
|
|
191
198
|
)
|
|
192
199
|
} catch (e) {
|
|
193
200
|
console.error("[snow-flow] render failed:", e instanceof Error ? e.message : e)
|
|
@@ -668,9 +675,7 @@ function App() {
|
|
|
668
675
|
kv.set("telemetry_enabled", !enabled)
|
|
669
676
|
await Config.updateGlobal({ telemetry: !enabled }).catch(() => {})
|
|
670
677
|
toast.show({
|
|
671
|
-
message: enabled
|
|
672
|
-
? "Telemetry disabled. Takes effect next session."
|
|
673
|
-
: "Telemetry enabled. Thank you!",
|
|
678
|
+
message: enabled ? "Telemetry disabled. Takes effect next session." : "Telemetry enabled. Thank you!",
|
|
674
679
|
variant: "info",
|
|
675
680
|
})
|
|
676
681
|
dialog.clear()
|
package/src/pty/index.ts
CHANGED
|
@@ -40,6 +40,7 @@ export namespace Pty {
|
|
|
40
40
|
cwd: z.string().optional(),
|
|
41
41
|
title: z.string().optional(),
|
|
42
42
|
env: z.record(z.string(), z.string()).optional(),
|
|
43
|
+
mode: z.enum(["shell", "tui"]).optional(),
|
|
43
44
|
})
|
|
44
45
|
|
|
45
46
|
export type CreateInput = z.infer<typeof CreateInput>
|
|
@@ -95,15 +96,35 @@ export namespace Pty {
|
|
|
95
96
|
|
|
96
97
|
export async function create(input: CreateInput) {
|
|
97
98
|
const id = Identifier.create("pty", false)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
let command = input.command || Shell.preferred()
|
|
100
|
+
let args = input.args || []
|
|
101
|
+
let cwd = input.cwd || Instance.directory
|
|
102
|
+
let extraEnv: Record<string, string> = {}
|
|
103
|
+
|
|
104
|
+
if (input.mode === "tui") {
|
|
105
|
+
const packageRoot = new URL("../../", import.meta.url).pathname.replace(/\/$/, "")
|
|
106
|
+
command = "bun"
|
|
107
|
+
args = [
|
|
108
|
+
"run",
|
|
109
|
+
"--conditions=browser",
|
|
110
|
+
"src/index.ts",
|
|
111
|
+
"--connect",
|
|
112
|
+
`http://127.0.0.1:${process.env.PORT || "4096"}`,
|
|
113
|
+
]
|
|
114
|
+
cwd = packageRoot
|
|
115
|
+
extraEnv = {
|
|
116
|
+
OPENCODE_SKIP_THEME_DETECTION: "1",
|
|
117
|
+
OPENCODE_DISABLE_KITTY_KEYBOARD: "1",
|
|
118
|
+
COLORTERM: "truecolor",
|
|
119
|
+
FORCE_COLOR: "3",
|
|
120
|
+
}
|
|
121
|
+
} else if (command.endsWith("sh")) {
|
|
101
122
|
args.push("-l")
|
|
102
123
|
}
|
|
103
124
|
|
|
104
|
-
const cwd = input.cwd || Instance.directory
|
|
105
125
|
const env = {
|
|
106
126
|
...process.env,
|
|
127
|
+
...extraEnv,
|
|
107
128
|
...input.env,
|
|
108
129
|
TERM: "xterm-256color",
|
|
109
130
|
SNOW_CODE_TERMINAL: "1",
|
|
@@ -40,21 +40,25 @@ async function spawnTui(cols: number, rows: number, env?: Record<string, string>
|
|
|
40
40
|
const { spawn } = await import("bun-pty")
|
|
41
41
|
const id = crypto.randomUUID()
|
|
42
42
|
|
|
43
|
-
const ptyProcess = spawn(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
43
|
+
const ptyProcess = spawn(
|
|
44
|
+
"bun",
|
|
45
|
+
["run", "--conditions=browser", "src/index.ts", "--connect", "http://localhost:4096"],
|
|
46
|
+
{
|
|
47
|
+
name: "xterm-256color",
|
|
48
|
+
cols,
|
|
49
|
+
rows,
|
|
50
|
+
cwd: new URL("../../../", import.meta.url).pathname.replace(/\/$/, ""),
|
|
51
|
+
env: {
|
|
52
|
+
...process.env,
|
|
53
|
+
...env,
|
|
54
|
+
TERM: "xterm-256color",
|
|
55
|
+
COLORTERM: "truecolor",
|
|
56
|
+
FORCE_COLOR: "3",
|
|
57
|
+
OPENCODE_SKIP_THEME_DETECTION: "1",
|
|
58
|
+
OPENCODE_DISABLE_KITTY_KEYBOARD: "1",
|
|
59
|
+
},
|
|
56
60
|
},
|
|
57
|
-
|
|
61
|
+
)
|
|
58
62
|
|
|
59
63
|
const session: TuiSession = { pty: ptyProcess, lastActivity: Date.now() }
|
|
60
64
|
sessions.set(id, session)
|