@agentprojectcontext/apx 1.15.5 → 1.16.0
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 +40 -5
- package/src/cli/commands/log.js +113 -0
- package/src/cli/commands/overlay.js +253 -0
- package/src/cli/commands/sys.js +88 -16
- package/src/cli/index.js +23 -1
- package/src/cli/terminal-chat/renderer.js +71 -56
- package/src/cli-ts/commands/agent.ts +173 -0
- package/src/cli-ts/commands/chat.ts +119 -0
- package/src/cli-ts/commands/daemon.ts +112 -0
- package/src/cli-ts/commands/exec.ts +109 -0
- package/src/cli-ts/commands/mcp.ts +235 -0
- package/src/cli-ts/commands/session.ts +224 -0
- package/src/cli-ts/commands/status.ts +61 -0
- package/src/cli-ts/http.ts +36 -0
- package/src/cli-ts/index.ts +73 -0
- package/src/cli-ts/ui.ts +107 -0
- package/src/core/logging.js +81 -0
- package/src/daemon/api.js +58 -0
- package/src/daemon/engines/anthropic.js +60 -1
- package/src/daemon/engines/index.js +2 -1
- package/src/daemon/engines/ollama.js +70 -3
- package/src/daemon/index.js +58 -0
- package/src/daemon/overlay-ws.js +40 -0
- package/src/daemon/plugins/index.js +2 -1
- package/src/daemon/plugins/overlay.js +177 -0
- package/src/daemon/plugins/telegram.js +15 -3
- package/src/daemon/super-agent.js +102 -19
- package/src/daemon/transcription.js +262 -59
- package/src/daemon/wakeup.js +14 -19
- package/src/daemon/whisper-server.py +57 -6
- package/src/overlay/index.html +44 -0
- package/src/overlay/main.js +480 -0
- package/src/overlay/package.json +3 -0
- package/src/overlay/preload.js +34 -0
- package/src/overlay/renderer.js +371 -0
- package/src/overlay/style.css +250 -0
- package/src/tui/_shims/cli-error.ts +6 -0
- package/src/tui/_shims/cli-logo.ts +18 -0
- package/src/tui/_shims/cli-ui.ts +1 -0
- package/src/tui/_shims/config-console-state.ts +7 -0
- package/src/tui/_shims/core-any.ts +30 -0
- package/src/tui/_shims/core-binary.ts +13 -0
- package/src/tui/_shims/core-flag.ts +3 -0
- package/src/tui/_shims/core-log.ts +14 -0
- package/src/tui/_shims/lsp-language.ts +1 -0
- package/src/tui/_shims/opencode-any.ts +135 -0
- package/src/tui/_shims/opencode-sdk-v2.ts +48 -0
- package/src/tui/_shims/plugin-tui.ts +13 -0
- package/src/tui/_shims/provider-provider.ts +10 -0
- package/src/tui/_shims/session-retry.ts +1 -0
- package/src/tui/_shims/session-schema.ts +15 -0
- package/src/tui/_shims/session-session.ts +3 -0
- package/src/tui/_shims/snapshot.ts +4 -0
- package/src/tui/_shims/tool-any.ts +18 -0
- package/src/tui/_shims/util-error.ts +7 -0
- package/src/tui/_shims/util-filesystem.ts +79 -0
- package/src/tui/_shims/util-format.ts +7 -0
- package/src/tui/_shims/util-iife.ts +3 -0
- package/src/tui/_shims/util-locale.ts +10 -0
- package/src/tui/_shims/util-process.ts +38 -0
- package/src/tui/app.tsx +783 -0
- package/src/tui/asset/charge.wav +0 -0
- package/src/tui/asset/pulse-a.wav +0 -0
- package/src/tui/asset/pulse-b.wav +0 -0
- package/src/tui/asset/pulse-c.wav +0 -0
- package/src/tui/attach.ts +100 -0
- package/src/tui/component/bg-pulse-render.ts +436 -0
- package/src/tui/component/bg-pulse.tsx +99 -0
- package/src/tui/component/border.tsx +21 -0
- package/src/tui/component/dialog-agent.tsx +31 -0
- package/src/tui/component/dialog-console-org.tsx +103 -0
- package/src/tui/component/dialog-mcp.tsx +85 -0
- package/src/tui/component/dialog-model.tsx +175 -0
- package/src/tui/component/dialog-provider.tsx +456 -0
- package/src/tui/component/dialog-retry-action.tsx +160 -0
- package/src/tui/component/dialog-session-delete-failed.tsx +99 -0
- package/src/tui/component/dialog-session-list.tsx +323 -0
- package/src/tui/component/dialog-session-rename.tsx +31 -0
- package/src/tui/component/dialog-skill.tsx +36 -0
- package/src/tui/component/dialog-stash.tsx +87 -0
- package/src/tui/component/dialog-status.tsx +168 -0
- package/src/tui/component/dialog-tag.tsx +44 -0
- package/src/tui/component/dialog-theme-list.tsx +50 -0
- package/src/tui/component/dialog-variant.tsx +39 -0
- package/src/tui/component/dialog-workspace-create.tsx +302 -0
- package/src/tui/component/dialog-workspace-file-changes.tsx +138 -0
- package/src/tui/component/dialog-workspace-unavailable.tsx +69 -0
- package/src/tui/component/error-component.tsx +92 -0
- package/src/tui/component/logo.tsx +896 -0
- package/src/tui/component/plugin-route-missing.tsx +14 -0
- package/src/tui/component/prompt/autocomplete.tsx +869 -0
- package/src/tui/component/prompt/cwd.ts +0 -0
- package/src/tui/component/prompt/frecency.tsx +90 -0
- package/src/tui/component/prompt/history.tsx +108 -0
- package/src/tui/component/prompt/index.tsx +1809 -0
- package/src/tui/component/prompt/part.ts +16 -0
- package/src/tui/component/prompt/stash.tsx +101 -0
- package/src/tui/component/prompt/traits.ts +35 -0
- package/src/tui/component/spinner.tsx +24 -0
- package/src/tui/component/startup-loading.tsx +63 -0
- package/src/tui/component/todo-item.tsx +32 -0
- package/src/tui/component/use-connected.tsx +9 -0
- package/src/tui/component/workspace-label.tsx +19 -0
- package/src/tui/config/cwd.ts +5 -0
- package/src/tui/config/keybind.ts +432 -0
- package/src/tui/config/tui-migrate.ts +154 -0
- package/src/tui/config/tui-schema.ts +34 -0
- package/src/tui/config/tui.ts +46 -0
- package/src/tui/context/aggregate-failures.ts +34 -0
- package/src/tui/context/args.tsx +15 -0
- package/src/tui/context/command-palette.tsx +163 -0
- package/src/tui/context/directory.ts +15 -0
- package/src/tui/context/editor-zed.ts +283 -0
- package/src/tui/context/editor.ts +468 -0
- package/src/tui/context/event-apx.ts +22 -0
- package/src/tui/context/event.ts +6 -0
- package/src/tui/context/exit.tsx +60 -0
- package/src/tui/context/helper.tsx +25 -0
- package/src/tui/context/kv.tsx +81 -0
- package/src/tui/context/local.tsx +608 -0
- package/src/tui/context/path-format.tsx +39 -0
- package/src/tui/context/project-apx.tsx +48 -0
- package/src/tui/context/project.tsx +7 -0
- package/src/tui/context/prompt.tsx +18 -0
- package/src/tui/context/route.tsx +52 -0
- package/src/tui/context/sdk-apx.tsx +185 -0
- package/src/tui/context/sdk.tsx +6 -0
- package/src/tui/context/sync-apx.tsx +178 -0
- package/src/tui/context/sync-v2.tsx +16 -0
- package/src/tui/context/sync.tsx +118 -0
- package/src/tui/context/theme/aura.json +69 -0
- package/src/tui/context/theme/ayu.json +80 -0
- package/src/tui/context/theme/carbonfox.json +248 -0
- package/src/tui/context/theme/catppuccin-frappe.json +230 -0
- package/src/tui/context/theme/catppuccin-macchiato.json +230 -0
- package/src/tui/context/theme/catppuccin.json +112 -0
- package/src/tui/context/theme/cobalt2.json +225 -0
- package/src/tui/context/theme/cursor.json +249 -0
- package/src/tui/context/theme/dracula.json +219 -0
- package/src/tui/context/theme/everforest.json +241 -0
- package/src/tui/context/theme/flexoki.json +237 -0
- package/src/tui/context/theme/github.json +233 -0
- package/src/tui/context/theme/gruvbox.json +242 -0
- package/src/tui/context/theme/kanagawa.json +77 -0
- package/src/tui/context/theme/lucent-orng.json +234 -0
- package/src/tui/context/theme/material.json +235 -0
- package/src/tui/context/theme/matrix.json +77 -0
- package/src/tui/context/theme/mercury.json +252 -0
- package/src/tui/context/theme/monokai.json +221 -0
- package/src/tui/context/theme/nightowl.json +221 -0
- package/src/tui/context/theme/nord.json +223 -0
- package/src/tui/context/theme/one-dark.json +84 -0
- package/src/tui/context/theme/opencode.json +245 -0
- package/src/tui/context/theme/orng.json +249 -0
- package/src/tui/context/theme/osaka-jade.json +93 -0
- package/src/tui/context/theme/palenight.json +222 -0
- package/src/tui/context/theme/rosepine.json +234 -0
- package/src/tui/context/theme/solarized.json +223 -0
- package/src/tui/context/theme/synthwave84.json +226 -0
- package/src/tui/context/theme/tokyonight.json +243 -0
- package/src/tui/context/theme/vercel.json +245 -0
- package/src/tui/context/theme/vesper.json +218 -0
- package/src/tui/context/theme/zenburn.json +223 -0
- package/src/tui/context/theme.tsx +1247 -0
- package/src/tui/context/tui-config.tsx +9 -0
- package/src/tui/event.ts +16 -0
- package/src/tui/feature-plugins/home/footer.tsx +94 -0
- package/src/tui/feature-plugins/home/tips-view.tsx +166 -0
- package/src/tui/feature-plugins/home/tips.tsx +59 -0
- package/src/tui/feature-plugins/sidebar/context.tsx +65 -0
- package/src/tui/feature-plugins/sidebar/files.tsx +63 -0
- package/src/tui/feature-plugins/sidebar/footer.tsx +94 -0
- package/src/tui/feature-plugins/sidebar/lsp.tsx +65 -0
- package/src/tui/feature-plugins/sidebar/mcp.tsx +97 -0
- package/src/tui/feature-plugins/sidebar/todo.tsx +49 -0
- package/src/tui/feature-plugins/system/plugins.tsx +269 -0
- package/src/tui/feature-plugins/system/session-v2.tsx +1143 -0
- package/src/tui/feature-plugins/system/which-key.tsx +608 -0
- package/src/tui/keymap.tsx +166 -0
- package/src/tui/layer.ts +6 -0
- package/src/tui/plugin/api.tsx +381 -0
- package/src/tui/plugin/command-shim.ts +109 -0
- package/src/tui/plugin/internal.ts +33 -0
- package/src/tui/plugin/runtime.ts +1069 -0
- package/src/tui/plugin/slots.tsx +60 -0
- package/src/tui/routes/home.tsx +96 -0
- package/src/tui/routes/session/dialog-fork-from-timeline.tsx +76 -0
- package/src/tui/routes/session/dialog-message.tsx +108 -0
- package/src/tui/routes/session/dialog-subagent.tsx +26 -0
- package/src/tui/routes/session/dialog-timeline.tsx +47 -0
- package/src/tui/routes/session/footer.tsx +91 -0
- package/src/tui/routes/session/index.tsx +188 -0
- package/src/tui/routes/session/permission.tsx +722 -0
- package/src/tui/routes/session/question.tsx +490 -0
- package/src/tui/routes/session/sidebar.tsx +102 -0
- package/src/tui/routes/session/subagent-footer.tsx +133 -0
- package/src/tui/run.ts +84 -0
- package/src/tui/thread.ts +261 -0
- package/src/tui/tsconfig.json +40 -0
- package/src/tui/ui/dialog-alert.tsx +66 -0
- package/src/tui/ui/dialog-confirm.tsx +108 -0
- package/src/tui/ui/dialog-export-options.tsx +217 -0
- package/src/tui/ui/dialog-help.tsx +40 -0
- package/src/tui/ui/dialog-prompt.tsx +101 -0
- package/src/tui/ui/dialog-select.tsx +553 -0
- package/src/tui/ui/dialog.tsx +211 -0
- package/src/tui/ui/link.tsx +34 -0
- package/src/tui/ui/spinner.ts +368 -0
- package/src/tui/ui/toast.tsx +111 -0
- package/src/tui/util/clipboard.ts +217 -0
- package/src/tui/util/editor.ts +37 -0
- package/src/tui/util/model.ts +23 -0
- package/src/tui/util/provider-origin.ts +7 -0
- package/src/tui/util/revert-diff.ts +18 -0
- package/src/tui/util/scroll.ts +25 -0
- package/src/tui/util/selection.ts +65 -0
- package/src/tui/util/signal.ts +41 -0
- package/src/tui/util/sound.ts +156 -0
- package/src/tui/util/transcript.ts +112 -0
- package/src/tui/validate-session.ts +29 -0
- package/src/tui/win32.ts +130 -0
- package/src/tui/worker.ts +104 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { TextAttributes } from "@opentui/core"
|
|
2
|
+
import { useKeyboard } from "@opentui/solid"
|
|
3
|
+
import type { VcsFileStatus } from "@opencode-ai/sdk/v2"
|
|
4
|
+
import { createMemo, For } from "solid-js"
|
|
5
|
+
import { createStore } from "solid-js/store"
|
|
6
|
+
import { Locale } from "@/util/locale"
|
|
7
|
+
import { useTheme } from "../context/theme"
|
|
8
|
+
import { useTuiConfig } from "../context/tui-config"
|
|
9
|
+
import { useDialog, type DialogContext } from "../ui/dialog"
|
|
10
|
+
import { getScrollAcceleration } from "../util/scroll"
|
|
11
|
+
|
|
12
|
+
const options = ["no", "yes"] as const
|
|
13
|
+
|
|
14
|
+
export type WorkspaceFileChangesChoice = (typeof options)[number]
|
|
15
|
+
|
|
16
|
+
function statusLabel(status: VcsFileStatus["status"]) {
|
|
17
|
+
if (status === "added") return "A"
|
|
18
|
+
if (status === "deleted") return "D"
|
|
19
|
+
return "M"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function changeCountWidth(file: VcsFileStatus) {
|
|
23
|
+
// The "plus 2" is for spaces
|
|
24
|
+
return `${file.additions ? `+${file.additions}` : ""}${file.deletions ? ` -${file.deletions}` : ""}`.length + 2
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function DialogWorkspaceFileChanges(props: {
|
|
28
|
+
files: VcsFileStatus[]
|
|
29
|
+
onSelect: (choice: WorkspaceFileChangesChoice) => void
|
|
30
|
+
}) {
|
|
31
|
+
const dialog = useDialog()
|
|
32
|
+
const { theme } = useTheme()
|
|
33
|
+
const tuiConfig = useTuiConfig()
|
|
34
|
+
const scrollAcceleration = createMemo(() => getScrollAcceleration(tuiConfig))
|
|
35
|
+
const [store, setStore] = createStore({ active: "yes" as WorkspaceFileChangesChoice })
|
|
36
|
+
const height = createMemo(() => Math.min(props.files.length, 8))
|
|
37
|
+
const fileNameWidth = createMemo(() => 48 - Math.max(Math.max(7, ...props.files.map(changeCountWidth)) - 7, 0))
|
|
38
|
+
|
|
39
|
+
function confirm() {
|
|
40
|
+
props.onSelect(store.active)
|
|
41
|
+
dialog.clear()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
useKeyboard((evt) => {
|
|
45
|
+
if (evt.name === "return") {
|
|
46
|
+
evt.preventDefault()
|
|
47
|
+
evt.stopPropagation()
|
|
48
|
+
confirm()
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
if (evt.name === "left") {
|
|
52
|
+
evt.preventDefault()
|
|
53
|
+
evt.stopPropagation()
|
|
54
|
+
const index = options.indexOf(store.active)
|
|
55
|
+
setStore("active", options[Math.max(index - 1, 0)])
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
if (evt.name === "right") {
|
|
59
|
+
evt.preventDefault()
|
|
60
|
+
evt.stopPropagation()
|
|
61
|
+
const index = options.indexOf(store.active)
|
|
62
|
+
setStore("active", options[Math.min(index + 1, options.length - 1)])
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<box gap={1}>
|
|
68
|
+
<box flexDirection="row" justifyContent="space-between" paddingLeft={2} paddingRight={2}>
|
|
69
|
+
<text attributes={TextAttributes.BOLD} fg={theme.text}>
|
|
70
|
+
File Changes Found
|
|
71
|
+
</text>
|
|
72
|
+
<text fg={theme.textMuted} onMouseUp={() => dialog.clear()}>
|
|
73
|
+
esc
|
|
74
|
+
</text>
|
|
75
|
+
</box>
|
|
76
|
+
<scrollbox
|
|
77
|
+
height={height()}
|
|
78
|
+
backgroundColor={theme.backgroundElement}
|
|
79
|
+
scrollbarOptions={{ visible: false }}
|
|
80
|
+
scrollAcceleration={scrollAcceleration()}
|
|
81
|
+
>
|
|
82
|
+
<For each={props.files}>
|
|
83
|
+
{(item) => (
|
|
84
|
+
<box flexDirection="row" justifyContent="space-between" paddingLeft={2} paddingRight={2}>
|
|
85
|
+
<box flexDirection="row" minWidth={0} flexShrink={1}>
|
|
86
|
+
<box width={2} flexShrink={0}>
|
|
87
|
+
<text fg={theme.textMuted}>{statusLabel(item.status)}</text>
|
|
88
|
+
</box>
|
|
89
|
+
<text fg={theme.textMuted} wrapMode="none">
|
|
90
|
+
{Locale.truncateLeft(item.file, fileNameWidth())}
|
|
91
|
+
</text>
|
|
92
|
+
</box>
|
|
93
|
+
<box flexDirection="row" gap={1} minWidth={7} flexShrink={0} justifyContent="flex-end">
|
|
94
|
+
<text>
|
|
95
|
+
{" "}
|
|
96
|
+
{item.additions ? <span style={{ fg: theme.diffAdded }}>+{item.additions}</span> : null}
|
|
97
|
+
{item.deletions ? <span style={{ fg: theme.diffRemoved }}> -{item.deletions}</span> : null}
|
|
98
|
+
</text>
|
|
99
|
+
</box>
|
|
100
|
+
</box>
|
|
101
|
+
)}
|
|
102
|
+
</For>
|
|
103
|
+
</scrollbox>
|
|
104
|
+
<box paddingLeft={2} paddingRight={2}>
|
|
105
|
+
<text fg={theme.textMuted} wrapMode="word">
|
|
106
|
+
Do you want to apply these changes after warping?
|
|
107
|
+
</text>
|
|
108
|
+
</box>
|
|
109
|
+
<box flexDirection="row" justifyContent="flex-end" paddingLeft={2} paddingRight={2} paddingBottom={1}>
|
|
110
|
+
<For each={options}>
|
|
111
|
+
{(item) => (
|
|
112
|
+
<box
|
|
113
|
+
paddingLeft={2}
|
|
114
|
+
paddingRight={2}
|
|
115
|
+
backgroundColor={item === store.active ? theme.primary : undefined}
|
|
116
|
+
onMouseUp={() => {
|
|
117
|
+
setStore("active", item)
|
|
118
|
+
props.onSelect(item)
|
|
119
|
+
dialog.clear()
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
<text fg={item === store.active ? theme.selectedListItemText : theme.textMuted}>{item}</text>
|
|
123
|
+
</box>
|
|
124
|
+
)}
|
|
125
|
+
</For>
|
|
126
|
+
</box>
|
|
127
|
+
</box>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
DialogWorkspaceFileChanges.show = (dialog: DialogContext, files: VcsFileStatus[]) => {
|
|
132
|
+
return new Promise<WorkspaceFileChangesChoice | undefined>((resolve) => {
|
|
133
|
+
dialog.replace(
|
|
134
|
+
() => <DialogWorkspaceFileChanges files={files} onSelect={resolve} />,
|
|
135
|
+
() => resolve(undefined),
|
|
136
|
+
)
|
|
137
|
+
})
|
|
138
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { TextAttributes } from "@opentui/core"
|
|
2
|
+
import { createStore } from "solid-js/store"
|
|
3
|
+
import { For } from "solid-js"
|
|
4
|
+
import { useTheme } from "../context/theme"
|
|
5
|
+
import { useDialog } from "../ui/dialog"
|
|
6
|
+
import { useBindings } from "../keymap"
|
|
7
|
+
|
|
8
|
+
export function DialogWorkspaceUnavailable(props: { onRestore?: () => boolean | void | Promise<boolean | void> }) {
|
|
9
|
+
const dialog = useDialog()
|
|
10
|
+
const { theme } = useTheme()
|
|
11
|
+
const [store, setStore] = createStore({
|
|
12
|
+
active: "restore" as "cancel" | "restore",
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
const options = ["cancel", "restore"] as const
|
|
16
|
+
|
|
17
|
+
async function confirm() {
|
|
18
|
+
if (store.active === "cancel") {
|
|
19
|
+
dialog.clear()
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
const result = await props.onRestore?.()
|
|
23
|
+
if (result === false) return
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
useBindings(() => ({
|
|
27
|
+
bindings: [
|
|
28
|
+
{ key: "return", desc: "Confirm workspace option", group: "Dialog", cmd: () => void confirm() },
|
|
29
|
+
{ key: "left", desc: "Cancel workspace restore", group: "Dialog", cmd: () => setStore("active", "cancel") },
|
|
30
|
+
{ key: "right", desc: "Restore workspace", group: "Dialog", cmd: () => setStore("active", "restore") },
|
|
31
|
+
],
|
|
32
|
+
}))
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<box paddingLeft={2} paddingRight={2} gap={1}>
|
|
36
|
+
<box flexDirection="row" justifyContent="space-between">
|
|
37
|
+
<text attributes={TextAttributes.BOLD} fg={theme.text}>
|
|
38
|
+
Workspace Unavailable
|
|
39
|
+
</text>
|
|
40
|
+
<text fg={theme.textMuted} onMouseUp={() => dialog.clear()}>
|
|
41
|
+
esc
|
|
42
|
+
</text>
|
|
43
|
+
</box>
|
|
44
|
+
<text fg={theme.textMuted} wrapMode="word">
|
|
45
|
+
This session is attached to a workspace that is no longer available.
|
|
46
|
+
</text>
|
|
47
|
+
<text fg={theme.textMuted} wrapMode="word">
|
|
48
|
+
Would you like to restore this session into a new workspace?
|
|
49
|
+
</text>
|
|
50
|
+
<box flexDirection="row" justifyContent="flex-end" paddingBottom={1} gap={1}>
|
|
51
|
+
<For each={options}>
|
|
52
|
+
{(item) => (
|
|
53
|
+
<box
|
|
54
|
+
paddingLeft={2}
|
|
55
|
+
paddingRight={2}
|
|
56
|
+
backgroundColor={item === store.active ? theme.primary : undefined}
|
|
57
|
+
onMouseUp={() => {
|
|
58
|
+
setStore("active", item)
|
|
59
|
+
void confirm()
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
<text fg={item === store.active ? theme.selectedListItemText : theme.textMuted}>{item}</text>
|
|
63
|
+
</box>
|
|
64
|
+
)}
|
|
65
|
+
</For>
|
|
66
|
+
</box>
|
|
67
|
+
</box>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { TextAttributes } from "@opentui/core"
|
|
2
|
+
import { useKeyboard, useRenderer, useTerminalDimensions } from "@opentui/solid"
|
|
3
|
+
import * as Clipboard from "@tui/util/clipboard"
|
|
4
|
+
import { createSignal } from "solid-js"
|
|
5
|
+
import { InstallationVersion } from "@opencode-ai/core/installation/version"
|
|
6
|
+
import { win32FlushInputBuffer } from "../win32"
|
|
7
|
+
import { getScrollAcceleration } from "../util/scroll"
|
|
8
|
+
|
|
9
|
+
export function ErrorComponent(props: {
|
|
10
|
+
error: Error
|
|
11
|
+
reset: () => void
|
|
12
|
+
onBeforeExit?: () => Promise<void>
|
|
13
|
+
onExit: () => Promise<void>
|
|
14
|
+
mode?: "dark" | "light"
|
|
15
|
+
}) {
|
|
16
|
+
const term = useTerminalDimensions()
|
|
17
|
+
const renderer = useRenderer()
|
|
18
|
+
|
|
19
|
+
const handleExit = async () => {
|
|
20
|
+
await props.onBeforeExit?.()
|
|
21
|
+
renderer.setTerminalTitle("")
|
|
22
|
+
renderer.destroy()
|
|
23
|
+
win32FlushInputBuffer()
|
|
24
|
+
await props.onExit()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
useKeyboard((evt) => {
|
|
28
|
+
if (evt.ctrl && evt.name === "c") {
|
|
29
|
+
void handleExit()
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
const [copied, setCopied] = createSignal(false)
|
|
33
|
+
|
|
34
|
+
const issueURL = new URL("https://github.com/anomalyco/opencode/issues/new?template=bug-report.yml")
|
|
35
|
+
|
|
36
|
+
// Choose safe fallback colors per mode since theme context may not be available
|
|
37
|
+
const isLight = props.mode === "light"
|
|
38
|
+
const colors = {
|
|
39
|
+
bg: isLight ? "#ffffff" : "#0a0a0a",
|
|
40
|
+
text: isLight ? "#1a1a1a" : "#eeeeee",
|
|
41
|
+
muted: isLight ? "#8a8a8a" : "#808080",
|
|
42
|
+
primary: isLight ? "#3b7dd8" : "#fab283",
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (props.error.message) {
|
|
46
|
+
issueURL.searchParams.set("title", `opentui: fatal: ${props.error.message}`)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (props.error.stack) {
|
|
50
|
+
issueURL.searchParams.set(
|
|
51
|
+
"description",
|
|
52
|
+
"```\n" + props.error.stack.substring(0, 6000 - issueURL.toString().length) + "...\n```",
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
issueURL.searchParams.set("opencode-version", InstallationVersion)
|
|
57
|
+
|
|
58
|
+
const copyIssueURL = () => {
|
|
59
|
+
void Clipboard.copy(issueURL.toString()).then(() => {
|
|
60
|
+
setCopied(true)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<box flexDirection="column" gap={1} backgroundColor={colors.bg}>
|
|
66
|
+
<box flexDirection="row" gap={1} alignItems="center">
|
|
67
|
+
<text attributes={TextAttributes.BOLD} fg={colors.text}>
|
|
68
|
+
Please report an issue.
|
|
69
|
+
</text>
|
|
70
|
+
<box onMouseUp={copyIssueURL} backgroundColor={colors.primary} padding={1}>
|
|
71
|
+
<text attributes={TextAttributes.BOLD} fg={colors.bg}>
|
|
72
|
+
Copy issue URL (exception info pre-filled)
|
|
73
|
+
</text>
|
|
74
|
+
</box>
|
|
75
|
+
{copied() && <text fg={colors.muted}>Successfully copied</text>}
|
|
76
|
+
</box>
|
|
77
|
+
<box flexDirection="row" gap={2} alignItems="center">
|
|
78
|
+
<text fg={colors.text}>A fatal error occurred!</text>
|
|
79
|
+
<box onMouseUp={props.reset} backgroundColor={colors.primary} padding={1}>
|
|
80
|
+
<text fg={colors.bg}>Reset TUI</text>
|
|
81
|
+
</box>
|
|
82
|
+
<box onMouseUp={handleExit} backgroundColor={colors.primary} padding={1}>
|
|
83
|
+
<text fg={colors.bg}>Exit</text>
|
|
84
|
+
</box>
|
|
85
|
+
</box>
|
|
86
|
+
<scrollbox height={Math.floor(term().height * 0.7)} scrollAcceleration={getScrollAcceleration()}>
|
|
87
|
+
<text fg={colors.muted}>{props.error.stack}</text>
|
|
88
|
+
</scrollbox>
|
|
89
|
+
<text fg={colors.text}>{props.error.message}</text>
|
|
90
|
+
</box>
|
|
91
|
+
)
|
|
92
|
+
}
|