chad-code 1.3.1 → 1.3.2
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/README.md +55 -6
- package/package.json +36 -98
- package/AGENTS.md +0 -27
- package/Dockerfile +0 -18
- package/README.npm.md +0 -64
- package/bunfig.toml +0 -7
- package/eslint.config.js +0 -29
- package/parsers-config.ts +0 -253
- package/script/build.ts +0 -167
- package/script/publish-registries.ts +0 -187
- package/script/publish.ts +0 -93
- package/script/schema.ts +0 -47
- package/src/acp/README.md +0 -164
- package/src/acp/agent.ts +0 -1086
- package/src/acp/session.ts +0 -101
- package/src/acp/types.ts +0 -22
- package/src/agent/agent.ts +0 -253
- package/src/agent/generate.txt +0 -75
- package/src/agent/prompt/compaction.txt +0 -12
- package/src/agent/prompt/explore.txt +0 -18
- package/src/agent/prompt/summary.txt +0 -11
- package/src/agent/prompt/title.txt +0 -36
- package/src/auth/index.ts +0 -70
- package/src/bun/index.ts +0 -130
- package/src/bus/bus-event.ts +0 -43
- package/src/bus/global.ts +0 -10
- package/src/bus/index.ts +0 -105
- package/src/cli/bootstrap.ts +0 -17
- package/src/cli/cmd/acp.ts +0 -69
- package/src/cli/cmd/agent.ts +0 -257
- package/src/cli/cmd/auth.ts +0 -132
- package/src/cli/cmd/cmd.ts +0 -7
- package/src/cli/cmd/debug/agent.ts +0 -28
- package/src/cli/cmd/debug/config.ts +0 -15
- package/src/cli/cmd/debug/file.ts +0 -91
- package/src/cli/cmd/debug/index.ts +0 -45
- package/src/cli/cmd/debug/lsp.ts +0 -48
- package/src/cli/cmd/debug/ripgrep.ts +0 -83
- package/src/cli/cmd/debug/scrap.ts +0 -15
- package/src/cli/cmd/debug/skill.ts +0 -15
- package/src/cli/cmd/debug/snapshot.ts +0 -48
- package/src/cli/cmd/export.ts +0 -88
- package/src/cli/cmd/generate.ts +0 -38
- package/src/cli/cmd/github.ts +0 -32
- package/src/cli/cmd/import.ts +0 -98
- package/src/cli/cmd/mcp.ts +0 -670
- package/src/cli/cmd/models.ts +0 -42
- package/src/cli/cmd/pr.ts +0 -112
- package/src/cli/cmd/run.ts +0 -374
- package/src/cli/cmd/serve.ts +0 -16
- package/src/cli/cmd/session.ts +0 -135
- package/src/cli/cmd/stats.ts +0 -402
- package/src/cli/cmd/tui/app.tsx +0 -705
- package/src/cli/cmd/tui/attach.ts +0 -32
- package/src/cli/cmd/tui/component/border.tsx +0 -21
- package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
- package/src/cli/cmd/tui/component/dialog-command.tsx +0 -124
- package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
- package/src/cli/cmd/tui/component/dialog-model.tsx +0 -232
- package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -228
- package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -115
- package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
- package/src/cli/cmd/tui/component/dialog-stash.tsx +0 -86
- package/src/cli/cmd/tui/component/dialog-status.tsx +0 -162
- package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
- package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
- package/src/cli/cmd/tui/component/did-you-know.tsx +0 -85
- package/src/cli/cmd/tui/component/logo.tsx +0 -43
- package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -654
- package/src/cli/cmd/tui/component/prompt/history.tsx +0 -108
- package/src/cli/cmd/tui/component/prompt/index.tsx +0 -1078
- package/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
- package/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
- package/src/cli/cmd/tui/component/tips.ts +0 -92
- package/src/cli/cmd/tui/component/todo-item.tsx +0 -32
- package/src/cli/cmd/tui/context/args.tsx +0 -14
- package/src/cli/cmd/tui/context/directory.ts +0 -13
- package/src/cli/cmd/tui/context/exit.tsx +0 -23
- package/src/cli/cmd/tui/context/helper.tsx +0 -25
- package/src/cli/cmd/tui/context/keybind.tsx +0 -101
- package/src/cli/cmd/tui/context/kv.tsx +0 -49
- package/src/cli/cmd/tui/context/local.tsx +0 -392
- package/src/cli/cmd/tui/context/prompt.tsx +0 -18
- package/src/cli/cmd/tui/context/route.tsx +0 -46
- package/src/cli/cmd/tui/context/sdk.tsx +0 -75
- package/src/cli/cmd/tui/context/sync.tsx +0 -384
- package/src/cli/cmd/tui/context/theme/aura.json +0 -69
- package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
- package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
- package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
- package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
- package/src/cli/cmd/tui/context/theme/chad.json +0 -245
- package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
- package/src/cli/cmd/tui/context/theme/cursor.json +0 -249
- package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
- package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
- package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
- package/src/cli/cmd/tui/context/theme/github.json +0 -233
- package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -95
- package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
- package/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -227
- package/src/cli/cmd/tui/context/theme/material.json +0 -235
- package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
- package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
- package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
- package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
- package/src/cli/cmd/tui/context/theme/nord.json +0 -223
- package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
- package/src/cli/cmd/tui/context/theme/orng.json +0 -245
- package/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
- package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
- package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
- package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
- package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
- package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
- package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
- package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
- package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
- package/src/cli/cmd/tui/context/theme.tsx +0 -1137
- package/src/cli/cmd/tui/event.ts +0 -46
- package/src/cli/cmd/tui/routes/home.tsx +0 -138
- package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -64
- package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -109
- package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
- package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
- package/src/cli/cmd/tui/routes/session/footer.tsx +0 -88
- package/src/cli/cmd/tui/routes/session/header.tsx +0 -125
- package/src/cli/cmd/tui/routes/session/index.tsx +0 -1814
- package/src/cli/cmd/tui/routes/session/permission.tsx +0 -416
- package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -318
- package/src/cli/cmd/tui/spawn.ts +0 -48
- package/src/cli/cmd/tui/thread.ts +0 -111
- package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -57
- package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -83
- package/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -204
- package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -38
- package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -77
- package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -345
- package/src/cli/cmd/tui/ui/dialog.tsx +0 -171
- package/src/cli/cmd/tui/ui/link.tsx +0 -28
- package/src/cli/cmd/tui/ui/spinner.ts +0 -368
- package/src/cli/cmd/tui/ui/toast.tsx +0 -100
- package/src/cli/cmd/tui/util/clipboard.ts +0 -127
- package/src/cli/cmd/tui/util/editor.ts +0 -32
- package/src/cli/cmd/tui/util/signal.ts +0 -7
- package/src/cli/cmd/tui/util/terminal.ts +0 -114
- package/src/cli/cmd/tui/util/transcript.ts +0 -98
- package/src/cli/cmd/tui/worker.ts +0 -68
- package/src/cli/cmd/uninstall.ts +0 -344
- package/src/cli/cmd/upgrade.ts +0 -67
- package/src/cli/cmd/web.ts +0 -73
- package/src/cli/error.ts +0 -56
- package/src/cli/network.ts +0 -53
- package/src/cli/ui.ts +0 -87
- package/src/cli/upgrade.ts +0 -25
- package/src/command/index.ts +0 -131
- package/src/command/template/initialize.txt +0 -10
- package/src/command/template/review.txt +0 -97
- package/src/config/config.ts +0 -1124
- package/src/config/markdown.ts +0 -41
- package/src/env/index.ts +0 -26
- package/src/file/ignore.ts +0 -83
- package/src/file/index.ts +0 -411
- package/src/file/ripgrep.ts +0 -402
- package/src/file/time.ts +0 -64
- package/src/file/watcher.ts +0 -117
- package/src/flag/flag.ts +0 -52
- package/src/format/formatter.ts +0 -359
- package/src/format/index.ts +0 -137
- package/src/global/index.ts +0 -55
- package/src/id/id.ts +0 -73
- package/src/ide/index.ts +0 -77
- package/src/index.ts +0 -159
- package/src/installation/index.ts +0 -198
- package/src/lsp/client.ts +0 -252
- package/src/lsp/index.ts +0 -485
- package/src/lsp/language.ts +0 -119
- package/src/lsp/server.ts +0 -2023
- package/src/mcp/auth.ts +0 -135
- package/src/mcp/index.ts +0 -874
- package/src/mcp/oauth-callback.ts +0 -200
- package/src/mcp/oauth-provider.ts +0 -154
- package/src/patch/index.ts +0 -622
- package/src/permission/arity.ts +0 -163
- package/src/permission/index.ts +0 -210
- package/src/permission/next.ts +0 -268
- package/src/plugin/index.ts +0 -106
- package/src/project/bootstrap.ts +0 -31
- package/src/project/instance.ts +0 -78
- package/src/project/project.ts +0 -263
- package/src/project/state.ts +0 -65
- package/src/project/vcs.ts +0 -76
- package/src/provider/auth.ts +0 -143
- package/src/provider/models-macro.ts +0 -4
- package/src/provider/models.ts +0 -77
- package/src/provider/provider.ts +0 -516
- package/src/provider/transform.ts +0 -114
- package/src/pty/index.ts +0 -212
- package/src/server/error.ts +0 -36
- package/src/server/mdns.ts +0 -57
- package/src/server/project.ts +0 -79
- package/src/server/server.ts +0 -2866
- package/src/server/tui.ts +0 -71
- package/src/session/compaction.ts +0 -225
- package/src/session/index.ts +0 -469
- package/src/session/llm.ts +0 -213
- package/src/session/message-v2.ts +0 -742
- package/src/session/message.ts +0 -189
- package/src/session/processor.ts +0 -402
- package/src/session/prompt/anthropic-20250930.txt +0 -166
- package/src/session/prompt/anthropic.txt +0 -105
- package/src/session/prompt/anthropic_spoof.txt +0 -1
- package/src/session/prompt/beast.txt +0 -147
- package/src/session/prompt/build-switch.txt +0 -5
- package/src/session/prompt/codex.txt +0 -318
- package/src/session/prompt/copilot-gpt-5.txt +0 -143
- package/src/session/prompt/gemini.txt +0 -155
- package/src/session/prompt/max-steps.txt +0 -16
- package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
- package/src/session/prompt/plan.txt +0 -26
- package/src/session/prompt/qwen.txt +0 -109
- package/src/session/prompt.ts +0 -1621
- package/src/session/retry.ts +0 -90
- package/src/session/revert.ts +0 -108
- package/src/session/status.ts +0 -76
- package/src/session/summary.ts +0 -194
- package/src/session/system.ts +0 -108
- package/src/session/todo.ts +0 -37
- package/src/share/share-next.ts +0 -194
- package/src/share/share.ts +0 -23
- package/src/shell/shell.ts +0 -67
- package/src/skill/index.ts +0 -1
- package/src/skill/skill.ts +0 -124
- package/src/snapshot/index.ts +0 -197
- package/src/storage/storage.ts +0 -226
- package/src/tool/bash.ts +0 -262
- package/src/tool/bash.txt +0 -116
- package/src/tool/batch.ts +0 -175
- package/src/tool/batch.txt +0 -24
- package/src/tool/codesearch.ts +0 -132
- package/src/tool/codesearch.txt +0 -12
- package/src/tool/edit.ts +0 -655
- package/src/tool/edit.txt +0 -10
- package/src/tool/glob.ts +0 -75
- package/src/tool/glob.txt +0 -6
- package/src/tool/grep.ts +0 -132
- package/src/tool/grep.txt +0 -8
- package/src/tool/invalid.ts +0 -17
- package/src/tool/ls.ts +0 -119
- package/src/tool/ls.txt +0 -1
- package/src/tool/lsp.ts +0 -94
- package/src/tool/lsp.txt +0 -19
- package/src/tool/multiedit.ts +0 -46
- package/src/tool/multiedit.txt +0 -41
- package/src/tool/patch.ts +0 -210
- package/src/tool/patch.txt +0 -1
- package/src/tool/read.ts +0 -191
- package/src/tool/read.txt +0 -12
- package/src/tool/registry.ts +0 -137
- package/src/tool/skill.ts +0 -77
- package/src/tool/task.ts +0 -167
- package/src/tool/task.txt +0 -60
- package/src/tool/todo.ts +0 -53
- package/src/tool/todoread.txt +0 -14
- package/src/tool/todowrite.txt +0 -167
- package/src/tool/tool.ts +0 -73
- package/src/tool/webfetch.ts +0 -182
- package/src/tool/webfetch.txt +0 -13
- package/src/tool/websearch.ts +0 -144
- package/src/tool/websearch.txt +0 -11
- package/src/tool/write.ts +0 -84
- package/src/tool/write.txt +0 -8
- package/src/util/archive.ts +0 -16
- package/src/util/color.ts +0 -19
- package/src/util/context.ts +0 -25
- package/src/util/defer.ts +0 -12
- package/src/util/eventloop.ts +0 -20
- package/src/util/filesystem.ts +0 -83
- package/src/util/fn.ts +0 -11
- package/src/util/iife.ts +0 -3
- package/src/util/keybind.ts +0 -102
- package/src/util/lazy.ts +0 -18
- package/src/util/locale.ts +0 -81
- package/src/util/lock.ts +0 -98
- package/src/util/log.ts +0 -180
- package/src/util/queue.ts +0 -32
- package/src/util/rpc.ts +0 -42
- package/src/util/scrap.ts +0 -10
- package/src/util/signal.ts +0 -12
- package/src/util/timeout.ts +0 -14
- package/src/util/token.ts +0 -7
- package/src/util/wildcard.ts +0 -54
- package/src/worktree/index.ts +0 -217
- package/sst-env.d.ts +0 -9
- package/test/agent/agent.test.ts +0 -448
- package/test/bun.test.ts +0 -53
- package/test/cli/github-action.test.ts +0 -129
- package/test/cli/github-remote.test.ts +0 -80
- package/test/cli/tui/transcript.test.ts +0 -297
- package/test/config/agent-color.test.ts +0 -66
- package/test/config/config.test.ts +0 -870
- package/test/config/markdown.test.ts +0 -89
- package/test/file/ignore.test.ts +0 -10
- package/test/file/path-traversal.test.ts +0 -115
- package/test/fixture/fixture.ts +0 -45
- package/test/fixture/lsp/fake-lsp-server.js +0 -77
- package/test/ide/ide.test.ts +0 -82
- package/test/keybind.test.ts +0 -421
- package/test/lsp/client.test.ts +0 -95
- package/test/mcp/headers.test.ts +0 -153
- package/test/patch/patch.test.ts +0 -348
- package/test/permission/arity.test.ts +0 -33
- package/test/permission/next.test.ts +0 -652
- package/test/preload.ts +0 -63
- package/test/project/project.test.ts +0 -120
- package/test/provider/amazon-bedrock.test.ts +0 -236
- package/test/provider/provider.test.ts +0 -2127
- package/test/provider/transform.test.ts +0 -980
- package/test/server/session-select.test.ts +0 -78
- package/test/session/compaction.test.ts +0 -251
- package/test/session/message-v2.test.ts +0 -570
- package/test/session/retry.test.ts +0 -131
- package/test/session/revert-compact.test.ts +0 -285
- package/test/session/session.test.ts +0 -71
- package/test/skill/skill.test.ts +0 -185
- package/test/snapshot/snapshot.test.ts +0 -939
- package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
- package/test/tool/bash.test.ts +0 -232
- package/test/tool/grep.test.ts +0 -109
- package/test/tool/patch.test.ts +0 -261
- package/test/tool/read.test.ts +0 -167
- package/test/util/iife.test.ts +0 -36
- package/test/util/lazy.test.ts +0 -50
- package/test/util/timeout.test.ts +0 -21
- package/test/util/wildcard.test.ts +0 -55
- package/tsconfig.json +0 -16
- /package/{script/postinstall.mjs → postinstall.mjs} +0 -0
package/src/cli/cmd/tui/app.tsx
DELETED
|
@@ -1,705 +0,0 @@
|
|
|
1
|
-
import { render, useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/solid"
|
|
2
|
-
import { Clipboard } from "@tui/util/clipboard"
|
|
3
|
-
import { TextAttributes } from "@opentui/core"
|
|
4
|
-
import { RouteProvider, useRoute } from "@tui/context/route"
|
|
5
|
-
import { Switch, Match, createEffect, untrack, ErrorBoundary, createSignal, onMount, batch, Show, on } from "solid-js"
|
|
6
|
-
import { Installation } from "@/installation"
|
|
7
|
-
import { Flag } from "@/flag/flag"
|
|
8
|
-
import { DialogProvider, useDialog } from "@tui/ui/dialog"
|
|
9
|
-
import { DialogProvider as DialogProviderList } from "@tui/component/dialog-provider"
|
|
10
|
-
import { SDKProvider, useSDK } from "@tui/context/sdk"
|
|
11
|
-
import { SyncProvider, useSync } from "@tui/context/sync"
|
|
12
|
-
import { LocalProvider, useLocal } from "@tui/context/local"
|
|
13
|
-
import { DialogModel, useConnected } from "@tui/component/dialog-model"
|
|
14
|
-
import { DialogMcp } from "@tui/component/dialog-mcp"
|
|
15
|
-
import { DialogStatus } from "@tui/component/dialog-status"
|
|
16
|
-
import { DialogThemeList } from "@tui/component/dialog-theme-list"
|
|
17
|
-
import { DialogHelp } from "./ui/dialog-help"
|
|
18
|
-
import { CommandProvider, useCommandDialog } from "@tui/component/dialog-command"
|
|
19
|
-
import { DialogAgent } from "@tui/component/dialog-agent"
|
|
20
|
-
import { DialogSessionList } from "@tui/component/dialog-session-list"
|
|
21
|
-
import { KeybindProvider } from "@tui/context/keybind"
|
|
22
|
-
import { ThemeProvider, useTheme } from "@tui/context/theme"
|
|
23
|
-
import { Home } from "@tui/routes/home"
|
|
24
|
-
import { Session } from "@tui/routes/session"
|
|
25
|
-
import { PromptHistoryProvider } from "./component/prompt/history"
|
|
26
|
-
import { PromptStashProvider } from "./component/prompt/stash"
|
|
27
|
-
import { DialogAlert } from "./ui/dialog-alert"
|
|
28
|
-
import { ToastProvider, useToast } from "./ui/toast"
|
|
29
|
-
import { ExitProvider, useExit } from "./context/exit"
|
|
30
|
-
import { Session as SessionApi } from "@/session"
|
|
31
|
-
import { TuiEvent } from "./event"
|
|
32
|
-
import { KVProvider, useKV } from "./context/kv"
|
|
33
|
-
import { Provider } from "@/provider/provider"
|
|
34
|
-
import { ArgsProvider, useArgs, type Args } from "./context/args"
|
|
35
|
-
import open from "open"
|
|
36
|
-
import { writeHeapSnapshot } from "v8"
|
|
37
|
-
import { PromptRefProvider, usePromptRef } from "./context/prompt"
|
|
38
|
-
|
|
39
|
-
async function getTerminalBackgroundColor(): Promise<"dark" | "light"> {
|
|
40
|
-
// can't set raw mode if not a TTY
|
|
41
|
-
if (!process.stdin.isTTY) return "dark"
|
|
42
|
-
|
|
43
|
-
return new Promise((resolve) => {
|
|
44
|
-
let timeout: NodeJS.Timeout
|
|
45
|
-
|
|
46
|
-
const cleanup = () => {
|
|
47
|
-
process.stdin.setRawMode(false)
|
|
48
|
-
process.stdin.removeListener("data", handler)
|
|
49
|
-
clearTimeout(timeout)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const handler = (data: Buffer) => {
|
|
53
|
-
const str = data.toString()
|
|
54
|
-
const match = str.match(/\x1b]11;([^\x07\x1b]+)/)
|
|
55
|
-
if (match) {
|
|
56
|
-
cleanup()
|
|
57
|
-
const color = match[1]
|
|
58
|
-
// Parse RGB values from color string
|
|
59
|
-
// Formats: rgb:RR/GG/BB or #RRGGBB or rgb(R,G,B)
|
|
60
|
-
let r = 0,
|
|
61
|
-
g = 0,
|
|
62
|
-
b = 0
|
|
63
|
-
|
|
64
|
-
if (color.startsWith("rgb:")) {
|
|
65
|
-
const parts = color.substring(4).split("/")
|
|
66
|
-
r = parseInt(parts[0], 16) >> 8 // Convert 16-bit to 8-bit
|
|
67
|
-
g = parseInt(parts[1], 16) >> 8 // Convert 16-bit to 8-bit
|
|
68
|
-
b = parseInt(parts[2], 16) >> 8 // Convert 16-bit to 8-bit
|
|
69
|
-
} else if (color.startsWith("#")) {
|
|
70
|
-
r = parseInt(color.substring(1, 3), 16)
|
|
71
|
-
g = parseInt(color.substring(3, 5), 16)
|
|
72
|
-
b = parseInt(color.substring(5, 7), 16)
|
|
73
|
-
} else if (color.startsWith("rgb(")) {
|
|
74
|
-
const parts = color.substring(4, color.length - 1).split(",")
|
|
75
|
-
r = parseInt(parts[0])
|
|
76
|
-
g = parseInt(parts[1])
|
|
77
|
-
b = parseInt(parts[2])
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Calculate luminance using relative luminance formula
|
|
81
|
-
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255
|
|
82
|
-
|
|
83
|
-
// Determine if dark or light based on luminance threshold
|
|
84
|
-
resolve(luminance > 0.5 ? "light" : "dark")
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
process.stdin.setRawMode(true)
|
|
89
|
-
process.stdin.on("data", handler)
|
|
90
|
-
process.stdout.write("\x1b]11;?\x07")
|
|
91
|
-
|
|
92
|
-
timeout = setTimeout(() => {
|
|
93
|
-
cleanup()
|
|
94
|
-
resolve("dark")
|
|
95
|
-
}, 1000)
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function tui(input: { url: string; args: Args; directory?: string; onExit?: () => Promise<void> }) {
|
|
100
|
-
// promise to prevent immediate exit
|
|
101
|
-
return new Promise<void>(async (resolve) => {
|
|
102
|
-
const mode = await getTerminalBackgroundColor()
|
|
103
|
-
const onExit = async () => {
|
|
104
|
-
await input.onExit?.()
|
|
105
|
-
resolve()
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
render(
|
|
109
|
-
() => {
|
|
110
|
-
return (
|
|
111
|
-
<ErrorBoundary
|
|
112
|
-
fallback={(error, reset) => <ErrorComponent error={error} reset={reset} onExit={onExit} mode={mode} />}
|
|
113
|
-
>
|
|
114
|
-
<ArgsProvider {...input.args}>
|
|
115
|
-
<ExitProvider onExit={onExit}>
|
|
116
|
-
<KVProvider>
|
|
117
|
-
<ToastProvider>
|
|
118
|
-
<RouteProvider>
|
|
119
|
-
<SDKProvider url={input.url} directory={input.directory}>
|
|
120
|
-
<SyncProvider>
|
|
121
|
-
<ThemeProvider mode={mode}>
|
|
122
|
-
<LocalProvider>
|
|
123
|
-
<KeybindProvider>
|
|
124
|
-
<PromptStashProvider>
|
|
125
|
-
<DialogProvider>
|
|
126
|
-
<CommandProvider>
|
|
127
|
-
<PromptHistoryProvider>
|
|
128
|
-
<PromptRefProvider>
|
|
129
|
-
<App />
|
|
130
|
-
</PromptRefProvider>
|
|
131
|
-
</PromptHistoryProvider>
|
|
132
|
-
</CommandProvider>
|
|
133
|
-
</DialogProvider>
|
|
134
|
-
</PromptStashProvider>
|
|
135
|
-
</KeybindProvider>
|
|
136
|
-
</LocalProvider>
|
|
137
|
-
</ThemeProvider>
|
|
138
|
-
</SyncProvider>
|
|
139
|
-
</SDKProvider>
|
|
140
|
-
</RouteProvider>
|
|
141
|
-
</ToastProvider>
|
|
142
|
-
</KVProvider>
|
|
143
|
-
</ExitProvider>
|
|
144
|
-
</ArgsProvider>
|
|
145
|
-
</ErrorBoundary>
|
|
146
|
-
)
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
targetFps: 60,
|
|
150
|
-
gatherStats: false,
|
|
151
|
-
exitOnCtrlC: false,
|
|
152
|
-
useKittyKeyboard: {},
|
|
153
|
-
consoleOptions: {
|
|
154
|
-
keyBindings: [{ name: "y", ctrl: true, action: "copy-selection" }],
|
|
155
|
-
onCopySelection: (text) => {
|
|
156
|
-
Clipboard.copy(text).catch((error) => {
|
|
157
|
-
console.error(`Failed to copy console selection to clipboard: ${error}`)
|
|
158
|
-
})
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
)
|
|
163
|
-
})
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function App() {
|
|
167
|
-
const route = useRoute()
|
|
168
|
-
const dimensions = useTerminalDimensions()
|
|
169
|
-
const renderer = useRenderer()
|
|
170
|
-
renderer.disableStdoutInterception()
|
|
171
|
-
const dialog = useDialog()
|
|
172
|
-
const local = useLocal()
|
|
173
|
-
const kv = useKV()
|
|
174
|
-
const command = useCommandDialog()
|
|
175
|
-
const sdk = useSDK()
|
|
176
|
-
const toast = useToast()
|
|
177
|
-
const { theme, mode, setMode } = useTheme()
|
|
178
|
-
const sync = useSync()
|
|
179
|
-
const exit = useExit()
|
|
180
|
-
const promptRef = usePromptRef()
|
|
181
|
-
|
|
182
|
-
// Wire up console copy-to-clipboard via opentui's onCopySelection callback
|
|
183
|
-
renderer.console.onCopySelection = async (text: string) => {
|
|
184
|
-
if (!text || text.length === 0) return
|
|
185
|
-
|
|
186
|
-
const base64 = Buffer.from(text).toString("base64")
|
|
187
|
-
const osc52 = `\x1b]52;c;${base64}\x07`
|
|
188
|
-
const finalOsc52 = process.env["TMUX"] ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52
|
|
189
|
-
// @ts-expect-error writeOut is not in type definitions
|
|
190
|
-
renderer.writeOut(finalOsc52)
|
|
191
|
-
await Clipboard.copy(text)
|
|
192
|
-
.then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
|
|
193
|
-
.catch(toast.error)
|
|
194
|
-
renderer.clearSelection()
|
|
195
|
-
}
|
|
196
|
-
const [terminalTitleEnabled, setTerminalTitleEnabled] = createSignal(kv.get("terminal_title_enabled", true))
|
|
197
|
-
|
|
198
|
-
createEffect(() => {
|
|
199
|
-
console.log(JSON.stringify(route.data))
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
// Update terminal window title based on current route and session
|
|
203
|
-
createEffect(() => {
|
|
204
|
-
if (!terminalTitleEnabled() || Flag.OPENCODE_DISABLE_TERMINAL_TITLE) return
|
|
205
|
-
|
|
206
|
-
if (route.data.type === "home") {
|
|
207
|
-
renderer.setTerminalTitle("Chad Code")
|
|
208
|
-
return
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (route.data.type === "session") {
|
|
212
|
-
const session = sync.session.get(route.data.sessionID)
|
|
213
|
-
if (!session || SessionApi.isDefaultTitle(session.title)) {
|
|
214
|
-
renderer.setTerminalTitle("Chad Code")
|
|
215
|
-
return
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// Truncate title to 40 chars max
|
|
219
|
-
const title = session.title.length > 40 ? session.title.slice(0, 37) + "..." : session.title
|
|
220
|
-
renderer.setTerminalTitle(`CT | ${title}`)
|
|
221
|
-
}
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
const args = useArgs()
|
|
225
|
-
onMount(() => {
|
|
226
|
-
batch(() => {
|
|
227
|
-
if (args.agent) local.agent.set(args.agent)
|
|
228
|
-
if (args.model) {
|
|
229
|
-
const { providerID, modelID } = Provider.parseModel(args.model)
|
|
230
|
-
if (!providerID || !modelID)
|
|
231
|
-
return toast.show({
|
|
232
|
-
variant: "warning",
|
|
233
|
-
message: `Invalid model format: ${args.model}`,
|
|
234
|
-
duration: 3000,
|
|
235
|
-
})
|
|
236
|
-
local.model.set({ providerID, modelID }, { recent: true })
|
|
237
|
-
}
|
|
238
|
-
if (args.sessionID) {
|
|
239
|
-
route.navigate({
|
|
240
|
-
type: "session",
|
|
241
|
-
sessionID: args.sessionID,
|
|
242
|
-
})
|
|
243
|
-
}
|
|
244
|
-
})
|
|
245
|
-
})
|
|
246
|
-
|
|
247
|
-
let continued = false
|
|
248
|
-
createEffect(() => {
|
|
249
|
-
// When using -c, session list is loaded in blocking phase, so we can navigate at "partial"
|
|
250
|
-
if (continued || sync.status === "loading" || !args.continue) return
|
|
251
|
-
const match = sync.data.session
|
|
252
|
-
.toSorted((a, b) => b.time.updated - a.time.updated)
|
|
253
|
-
.find((x) => x.parentID === undefined)?.id
|
|
254
|
-
if (match) {
|
|
255
|
-
continued = true
|
|
256
|
-
route.navigate({ type: "session", sessionID: match })
|
|
257
|
-
}
|
|
258
|
-
})
|
|
259
|
-
|
|
260
|
-
createEffect(
|
|
261
|
-
on(
|
|
262
|
-
() => sync.status === "complete" && sync.data.provider.length === 0,
|
|
263
|
-
(isEmpty, wasEmpty) => {
|
|
264
|
-
// only trigger when we transition into an empty-provider state
|
|
265
|
-
if (!isEmpty || wasEmpty) return
|
|
266
|
-
dialog.replace(() => <DialogProviderList />)
|
|
267
|
-
},
|
|
268
|
-
),
|
|
269
|
-
)
|
|
270
|
-
|
|
271
|
-
const connected = useConnected()
|
|
272
|
-
command.register(() => [
|
|
273
|
-
{
|
|
274
|
-
title: "Switch session",
|
|
275
|
-
value: "session.list",
|
|
276
|
-
keybind: "session_list",
|
|
277
|
-
category: "Session",
|
|
278
|
-
suggested: sync.data.session.length > 0,
|
|
279
|
-
onSelect: () => {
|
|
280
|
-
dialog.replace(() => <DialogSessionList />)
|
|
281
|
-
},
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
title: "New session",
|
|
285
|
-
suggested: route.data.type === "session",
|
|
286
|
-
value: "session.new",
|
|
287
|
-
keybind: "session_new",
|
|
288
|
-
category: "Session",
|
|
289
|
-
onSelect: () => {
|
|
290
|
-
const current = promptRef.current
|
|
291
|
-
// Don't require focus - if there's any text, preserve it
|
|
292
|
-
const currentPrompt = current?.current?.input ? current.current : undefined
|
|
293
|
-
route.navigate({
|
|
294
|
-
type: "home",
|
|
295
|
-
initialPrompt: currentPrompt,
|
|
296
|
-
})
|
|
297
|
-
dialog.clear()
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
title: "Switch model",
|
|
302
|
-
value: "model.list",
|
|
303
|
-
keybind: "model_list",
|
|
304
|
-
suggested: true,
|
|
305
|
-
category: "Agent",
|
|
306
|
-
onSelect: () => {
|
|
307
|
-
dialog.replace(() => <DialogModel />)
|
|
308
|
-
},
|
|
309
|
-
},
|
|
310
|
-
{
|
|
311
|
-
title: "Model cycle",
|
|
312
|
-
disabled: true,
|
|
313
|
-
value: "model.cycle_recent",
|
|
314
|
-
keybind: "model_cycle_recent",
|
|
315
|
-
category: "Agent",
|
|
316
|
-
onSelect: () => {
|
|
317
|
-
local.model.cycle(1)
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
title: "Model cycle reverse",
|
|
322
|
-
disabled: true,
|
|
323
|
-
value: "model.cycle_recent_reverse",
|
|
324
|
-
keybind: "model_cycle_recent_reverse",
|
|
325
|
-
category: "Agent",
|
|
326
|
-
onSelect: () => {
|
|
327
|
-
local.model.cycle(-1)
|
|
328
|
-
},
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
title: "Favorite cycle",
|
|
332
|
-
value: "model.cycle_favorite",
|
|
333
|
-
keybind: "model_cycle_favorite",
|
|
334
|
-
category: "Agent",
|
|
335
|
-
onSelect: () => {
|
|
336
|
-
local.model.cycleFavorite(1)
|
|
337
|
-
},
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
title: "Favorite cycle reverse",
|
|
341
|
-
value: "model.cycle_favorite_reverse",
|
|
342
|
-
keybind: "model_cycle_favorite_reverse",
|
|
343
|
-
category: "Agent",
|
|
344
|
-
onSelect: () => {
|
|
345
|
-
local.model.cycleFavorite(-1)
|
|
346
|
-
},
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
title: "Switch agent",
|
|
350
|
-
value: "agent.list",
|
|
351
|
-
keybind: "agent_list",
|
|
352
|
-
category: "Agent",
|
|
353
|
-
onSelect: () => {
|
|
354
|
-
dialog.replace(() => <DialogAgent />)
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
title: "Toggle MCPs",
|
|
359
|
-
value: "mcp.list",
|
|
360
|
-
category: "Agent",
|
|
361
|
-
onSelect: () => {
|
|
362
|
-
dialog.replace(() => <DialogMcp />)
|
|
363
|
-
},
|
|
364
|
-
},
|
|
365
|
-
{
|
|
366
|
-
title: "Agent cycle",
|
|
367
|
-
value: "agent.cycle",
|
|
368
|
-
keybind: "agent_cycle",
|
|
369
|
-
category: "Agent",
|
|
370
|
-
disabled: true,
|
|
371
|
-
onSelect: () => {
|
|
372
|
-
local.agent.move(1)
|
|
373
|
-
},
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
title: "Variant cycle",
|
|
377
|
-
value: "variant.cycle",
|
|
378
|
-
keybind: "variant_cycle",
|
|
379
|
-
category: "Agent",
|
|
380
|
-
onSelect: () => {
|
|
381
|
-
local.model.variant.cycle()
|
|
382
|
-
},
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
title: "Agent cycle reverse",
|
|
386
|
-
value: "agent.cycle.reverse",
|
|
387
|
-
keybind: "agent_cycle_reverse",
|
|
388
|
-
category: "Agent",
|
|
389
|
-
disabled: true,
|
|
390
|
-
onSelect: () => {
|
|
391
|
-
local.agent.move(-1)
|
|
392
|
-
},
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
title: "Enter Chadcode API key",
|
|
396
|
-
value: "provider.connect",
|
|
397
|
-
suggested: !connected(),
|
|
398
|
-
onSelect: () => {
|
|
399
|
-
dialog.replace(() => <DialogProviderList />)
|
|
400
|
-
},
|
|
401
|
-
category: "Chad",
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
title: "View status",
|
|
405
|
-
keybind: "status_view",
|
|
406
|
-
value: "opencode.status",
|
|
407
|
-
onSelect: () => {
|
|
408
|
-
dialog.replace(() => <DialogStatus />)
|
|
409
|
-
},
|
|
410
|
-
category: "System",
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
title: "Switch theme",
|
|
414
|
-
value: "theme.switch",
|
|
415
|
-
keybind: "theme_list",
|
|
416
|
-
onSelect: () => {
|
|
417
|
-
dialog.replace(() => <DialogThemeList />)
|
|
418
|
-
},
|
|
419
|
-
category: "System",
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
title: "Toggle appearance",
|
|
423
|
-
value: "theme.switch_mode",
|
|
424
|
-
onSelect: (dialog) => {
|
|
425
|
-
setMode(mode() === "dark" ? "light" : "dark")
|
|
426
|
-
dialog.clear()
|
|
427
|
-
},
|
|
428
|
-
category: "System",
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
title: "Help",
|
|
432
|
-
value: "help.show",
|
|
433
|
-
onSelect: () => {
|
|
434
|
-
dialog.replace(() => <DialogHelp />)
|
|
435
|
-
},
|
|
436
|
-
category: "System",
|
|
437
|
-
},
|
|
438
|
-
{
|
|
439
|
-
title: "Open docs",
|
|
440
|
-
value: "docs.open",
|
|
441
|
-
onSelect: () => {
|
|
442
|
-
open("https://corethink.ai/docs").catch(() => {})
|
|
443
|
-
dialog.clear()
|
|
444
|
-
},
|
|
445
|
-
category: "System",
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
title: "Open WebUI",
|
|
449
|
-
value: "webui.open",
|
|
450
|
-
onSelect: () => {
|
|
451
|
-
open(sdk.url).catch(() => {})
|
|
452
|
-
dialog.clear()
|
|
453
|
-
},
|
|
454
|
-
category: "System",
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
title: "Exit the app",
|
|
458
|
-
value: "app.exit",
|
|
459
|
-
onSelect: () => exit(),
|
|
460
|
-
category: "System",
|
|
461
|
-
},
|
|
462
|
-
{
|
|
463
|
-
title: "Toggle debug panel",
|
|
464
|
-
category: "System",
|
|
465
|
-
value: "app.debug",
|
|
466
|
-
onSelect: (dialog) => {
|
|
467
|
-
renderer.toggleDebugOverlay()
|
|
468
|
-
dialog.clear()
|
|
469
|
-
},
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
title: "Toggle console",
|
|
473
|
-
category: "System",
|
|
474
|
-
value: "app.console",
|
|
475
|
-
onSelect: (dialog) => {
|
|
476
|
-
renderer.console.toggle()
|
|
477
|
-
dialog.clear()
|
|
478
|
-
},
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
title: "Write heap snapshot",
|
|
482
|
-
category: "System",
|
|
483
|
-
value: "app.heap_snapshot",
|
|
484
|
-
onSelect: (dialog) => {
|
|
485
|
-
const path = writeHeapSnapshot()
|
|
486
|
-
toast.show({
|
|
487
|
-
variant: "info",
|
|
488
|
-
message: `Heap snapshot written to ${path}`,
|
|
489
|
-
duration: 5000,
|
|
490
|
-
})
|
|
491
|
-
dialog.clear()
|
|
492
|
-
},
|
|
493
|
-
},
|
|
494
|
-
{
|
|
495
|
-
title: "Suspend terminal",
|
|
496
|
-
value: "terminal.suspend",
|
|
497
|
-
keybind: "terminal_suspend",
|
|
498
|
-
category: "System",
|
|
499
|
-
onSelect: () => {
|
|
500
|
-
process.once("SIGCONT", () => {
|
|
501
|
-
renderer.resume()
|
|
502
|
-
})
|
|
503
|
-
|
|
504
|
-
renderer.suspend()
|
|
505
|
-
// pid=0 means send the signal to all processes in the process group
|
|
506
|
-
process.kill(0, "SIGTSTP")
|
|
507
|
-
},
|
|
508
|
-
},
|
|
509
|
-
{
|
|
510
|
-
title: terminalTitleEnabled() ? "Disable terminal title" : "Enable terminal title",
|
|
511
|
-
value: "terminal.title.toggle",
|
|
512
|
-
keybind: "terminal_title_toggle",
|
|
513
|
-
category: "System",
|
|
514
|
-
onSelect: (dialog) => {
|
|
515
|
-
setTerminalTitleEnabled((prev) => {
|
|
516
|
-
const next = !prev
|
|
517
|
-
kv.set("terminal_title_enabled", next)
|
|
518
|
-
if (!next) renderer.setTerminalTitle("")
|
|
519
|
-
return next
|
|
520
|
-
})
|
|
521
|
-
dialog.clear()
|
|
522
|
-
},
|
|
523
|
-
},
|
|
524
|
-
])
|
|
525
|
-
|
|
526
|
-
// OpenRouter warning removed - CoreThink is the only provider
|
|
527
|
-
|
|
528
|
-
sdk.event.on(TuiEvent.CommandExecute.type, (evt) => {
|
|
529
|
-
command.trigger(evt.properties.command)
|
|
530
|
-
})
|
|
531
|
-
|
|
532
|
-
sdk.event.on(TuiEvent.ToastShow.type, (evt) => {
|
|
533
|
-
toast.show({
|
|
534
|
-
title: evt.properties.title,
|
|
535
|
-
message: evt.properties.message,
|
|
536
|
-
variant: evt.properties.variant,
|
|
537
|
-
duration: evt.properties.duration,
|
|
538
|
-
})
|
|
539
|
-
})
|
|
540
|
-
|
|
541
|
-
sdk.event.on(TuiEvent.SessionSelect.type, (evt) => {
|
|
542
|
-
route.navigate({
|
|
543
|
-
type: "session",
|
|
544
|
-
sessionID: evt.properties.sessionID,
|
|
545
|
-
})
|
|
546
|
-
})
|
|
547
|
-
|
|
548
|
-
sdk.event.on(SessionApi.Event.Deleted.type, (evt) => {
|
|
549
|
-
if (route.data.type === "session" && route.data.sessionID === evt.properties.info.id) {
|
|
550
|
-
route.navigate({ type: "home" })
|
|
551
|
-
toast.show({
|
|
552
|
-
variant: "info",
|
|
553
|
-
message: "The current session was deleted",
|
|
554
|
-
})
|
|
555
|
-
}
|
|
556
|
-
})
|
|
557
|
-
|
|
558
|
-
sdk.event.on(SessionApi.Event.Error.type, (evt) => {
|
|
559
|
-
const error = evt.properties.error
|
|
560
|
-
const message = (() => {
|
|
561
|
-
if (!error) return "An error occurred"
|
|
562
|
-
|
|
563
|
-
if (typeof error === "object") {
|
|
564
|
-
const data = error.data
|
|
565
|
-
if ("message" in data && typeof data.message === "string") {
|
|
566
|
-
return data.message
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
return String(error)
|
|
570
|
-
})()
|
|
571
|
-
|
|
572
|
-
toast.show({
|
|
573
|
-
variant: "error",
|
|
574
|
-
message,
|
|
575
|
-
duration: 5000,
|
|
576
|
-
})
|
|
577
|
-
})
|
|
578
|
-
|
|
579
|
-
sdk.event.on(Installation.Event.Updated.type, (evt) => {
|
|
580
|
-
toast.show({
|
|
581
|
-
variant: "success",
|
|
582
|
-
title: "Update Complete",
|
|
583
|
-
message: `Chad Code updated to v${evt.properties.version}`,
|
|
584
|
-
duration: 5000,
|
|
585
|
-
})
|
|
586
|
-
})
|
|
587
|
-
|
|
588
|
-
sdk.event.on(Installation.Event.UpdateAvailable.type, (evt) => {
|
|
589
|
-
toast.show({
|
|
590
|
-
variant: "info",
|
|
591
|
-
title: "Update Available",
|
|
592
|
-
message: `Chad Code v${evt.properties.version} is available. Run 'chad-code upgrade' to update manually.`,
|
|
593
|
-
duration: 10000,
|
|
594
|
-
})
|
|
595
|
-
})
|
|
596
|
-
|
|
597
|
-
return (
|
|
598
|
-
<box
|
|
599
|
-
width={dimensions().width}
|
|
600
|
-
height={dimensions().height}
|
|
601
|
-
backgroundColor={theme.background}
|
|
602
|
-
onMouseUp={async () => {
|
|
603
|
-
if (Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) {
|
|
604
|
-
renderer.clearSelection()
|
|
605
|
-
return
|
|
606
|
-
}
|
|
607
|
-
const text = renderer.getSelection()?.getSelectedText()
|
|
608
|
-
if (text && text.length > 0) {
|
|
609
|
-
const base64 = Buffer.from(text).toString("base64")
|
|
610
|
-
const osc52 = `\x1b]52;c;${base64}\x07`
|
|
611
|
-
const finalOsc52 = process.env["TMUX"] ? `\x1bPtmux;\x1b${osc52}\x1b\\` : osc52
|
|
612
|
-
/* @ts-expect-error */
|
|
613
|
-
renderer.writeOut(finalOsc52)
|
|
614
|
-
await Clipboard.copy(text)
|
|
615
|
-
.then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
|
|
616
|
-
.catch(toast.error)
|
|
617
|
-
renderer.clearSelection()
|
|
618
|
-
}
|
|
619
|
-
}}
|
|
620
|
-
>
|
|
621
|
-
<Switch>
|
|
622
|
-
<Match when={route.data.type === "home"}>
|
|
623
|
-
<Home />
|
|
624
|
-
</Match>
|
|
625
|
-
<Match when={route.data.type === "session"}>
|
|
626
|
-
<Session />
|
|
627
|
-
</Match>
|
|
628
|
-
</Switch>
|
|
629
|
-
</box>
|
|
630
|
-
)
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
function ErrorComponent(props: {
|
|
634
|
-
error: Error
|
|
635
|
-
reset: () => void
|
|
636
|
-
onExit: () => Promise<void>
|
|
637
|
-
mode?: "dark" | "light"
|
|
638
|
-
}) {
|
|
639
|
-
const term = useTerminalDimensions()
|
|
640
|
-
useKeyboard((evt) => {
|
|
641
|
-
if (evt.ctrl && evt.name === "c") {
|
|
642
|
-
props.onExit()
|
|
643
|
-
}
|
|
644
|
-
})
|
|
645
|
-
const [copied, setCopied] = createSignal(false)
|
|
646
|
-
|
|
647
|
-
const issueURL = new URL("https://github.com/corethink-ai/chad-code/issues/new?template=bug-report.yml")
|
|
648
|
-
|
|
649
|
-
// Choose safe fallback colors per mode since theme context may not be available
|
|
650
|
-
const isLight = props.mode === "light"
|
|
651
|
-
const colors = {
|
|
652
|
-
bg: isLight ? "#ffffff" : "#0a0a0a",
|
|
653
|
-
text: isLight ? "#1a1a1a" : "#eeeeee",
|
|
654
|
-
muted: isLight ? "#8a8a8a" : "#808080",
|
|
655
|
-
primary: isLight ? "#3b7dd8" : "#fab283",
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
if (props.error.message) {
|
|
659
|
-
issueURL.searchParams.set("title", `opentui: fatal: ${props.error.message}`)
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
if (props.error.stack) {
|
|
663
|
-
issueURL.searchParams.set(
|
|
664
|
-
"description",
|
|
665
|
-
"```\n" + props.error.stack.substring(0, 6000 - issueURL.toString().length) + "...\n```",
|
|
666
|
-
)
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
issueURL.searchParams.set("opencode-version", Installation.VERSION)
|
|
670
|
-
|
|
671
|
-
const copyIssueURL = () => {
|
|
672
|
-
Clipboard.copy(issueURL.toString()).then(() => {
|
|
673
|
-
setCopied(true)
|
|
674
|
-
})
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
return (
|
|
678
|
-
<box flexDirection="column" gap={1} backgroundColor={colors.bg}>
|
|
679
|
-
<box flexDirection="row" gap={1} alignItems="center">
|
|
680
|
-
<text attributes={TextAttributes.BOLD} fg={colors.text}>
|
|
681
|
-
Please report an issue.
|
|
682
|
-
</text>
|
|
683
|
-
<box onMouseUp={copyIssueURL} backgroundColor={colors.primary} padding={1}>
|
|
684
|
-
<text attributes={TextAttributes.BOLD} fg={colors.bg}>
|
|
685
|
-
Copy issue URL (exception info pre-filled)
|
|
686
|
-
</text>
|
|
687
|
-
</box>
|
|
688
|
-
{copied() && <text fg={colors.muted}>Successfully copied</text>}
|
|
689
|
-
</box>
|
|
690
|
-
<box flexDirection="row" gap={2} alignItems="center">
|
|
691
|
-
<text fg={colors.text}>A fatal error occurred!</text>
|
|
692
|
-
<box onMouseUp={props.reset} backgroundColor={colors.primary} padding={1}>
|
|
693
|
-
<text fg={colors.bg}>Reset TUI</text>
|
|
694
|
-
</box>
|
|
695
|
-
<box onMouseUp={props.onExit} backgroundColor={colors.primary} padding={1}>
|
|
696
|
-
<text fg={colors.bg}>Exit</text>
|
|
697
|
-
</box>
|
|
698
|
-
</box>
|
|
699
|
-
<scrollbox height={Math.floor(term().height * 0.7)}>
|
|
700
|
-
<text fg={colors.muted}>{props.error.stack}</text>
|
|
701
|
-
</scrollbox>
|
|
702
|
-
<text fg={colors.text}>{props.error.message}</text>
|
|
703
|
-
</box>
|
|
704
|
-
)
|
|
705
|
-
}
|