feat(plugin): expose app metadata (#38179)
This commit is contained in:
parent
2ed8fe5960
commit
8de40be6ea
71 changed files with 477 additions and 286 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import { TextAttributes } from "@opentui/core"
|
||||
import { createMemo, createSignal, For } from "solid-js"
|
||||
import { InstallationChannel, InstallationVersion } from "@opencode-ai/util/installation/version"
|
||||
import { Keymap } from "../context/keymap"
|
||||
import { useTheme } from "../context/theme"
|
||||
import { useDialog } from "../ui/dialog"
|
||||
|
|
@ -9,6 +8,7 @@ import { useLocal } from "../context/local"
|
|||
import { useClipboard } from "../context/clipboard"
|
||||
import { useToast } from "../ui/toast"
|
||||
import { describeOS, describeTerminal } from "../util/system"
|
||||
import { useTuiApp } from "../context/runtime"
|
||||
|
||||
export function DialogDebug() {
|
||||
const { themeV2 } = useTheme()
|
||||
|
|
@ -17,6 +17,7 @@ export function DialogDebug() {
|
|||
const local = useLocal()
|
||||
const clipboard = useClipboard()
|
||||
const toast = useToast()
|
||||
const app = useTuiApp()
|
||||
const [copied, setCopied] = createSignal(false)
|
||||
|
||||
dialog.setSize("large")
|
||||
|
|
@ -24,7 +25,7 @@ export function DialogDebug() {
|
|||
const entries = createMemo(() => {
|
||||
const model = local.model.current()
|
||||
return [
|
||||
{ label: "Version", value: `${InstallationVersion} (${InstallationChannel})` },
|
||||
{ label: "Version", value: `${app.version} (${app.channel})` },
|
||||
{ label: "Date", value: new Date().toISOString() },
|
||||
{ label: "OS", value: describeOS() },
|
||||
{ label: "Terminal", value: describeTerminal() },
|
||||
|
|
|
|||
|
|
@ -3,14 +3,15 @@ import { useKeyboard, useTerminalDimensions } from "@opentui/solid"
|
|||
import { createSignal, For, Show } from "solid-js"
|
||||
import { getScrollAcceleration } from "../util/scroll"
|
||||
import { useClipboard } from "../context/clipboard"
|
||||
import { InstallationVersion } from "@opencode-ai/util/installation/version"
|
||||
import { useExit } from "../context/exit"
|
||||
import { useTuiApp } from "../context/runtime"
|
||||
import { describeOS, describeTerminal } from "../util/system"
|
||||
|
||||
export function ErrorComponent(props: { error: Error; reset: () => void; mode?: "dark" | "light" }) {
|
||||
const term = useTerminalDimensions()
|
||||
const exit = useExit()
|
||||
const clipboard = useClipboard()
|
||||
const app = useTuiApp()
|
||||
const [copied, setCopied] = createSignal(false)
|
||||
|
||||
// Safe fallback palette per mode (mirrors theme/assets/opencode.json) since the
|
||||
|
|
@ -42,7 +43,7 @@ export function ErrorComponent(props: { error: Error; reset: () => void; mode?:
|
|||
|
||||
const message = props.error.message || "An unknown error occurred."
|
||||
const stack = props.error.stack || "No stack trace available."
|
||||
const issueURL = buildIssueURL(message, stack)
|
||||
const issueURL = buildIssueURL(message, stack, app.version)
|
||||
|
||||
const copyReport = () => {
|
||||
void clipboard.write?.(issueURL.toString()).then(() => setCopied(true))
|
||||
|
|
@ -192,7 +193,7 @@ export function ErrorComponent(props: { error: Error; reset: () => void; mode?:
|
|||
? "Report copied — paste it into a new GitHub issue."
|
||||
: "Copy the report and open a GitHub issue to help us fix this."}
|
||||
</text>
|
||||
<text fg={colors.muted}>OpenCode {InstallationVersion}</text>
|
||||
<text fg={colors.muted}>OpenCode {app.version}</text>
|
||||
</box>
|
||||
</Show>
|
||||
</box>
|
||||
|
|
@ -200,13 +201,13 @@ export function ErrorComponent(props: { error: Error; reset: () => void; mode?:
|
|||
)
|
||||
}
|
||||
|
||||
function buildIssueURL(message: string, stack: string) {
|
||||
function buildIssueURL(message: string, stack: string, version: string) {
|
||||
// Field keys match the ids in .github/ISSUE_TEMPLATE/bug-report.yml so the issue
|
||||
// form opens pre-filled. Populating os/terminal/reproduce keeps the report past
|
||||
// the contributing-guidelines compliance check, which pushes for system info.
|
||||
const url = new URL("https://github.com/anomalyco/opencode/issues/new?template=bug-report.yml")
|
||||
url.searchParams.set("title", `TUI crash: ${message}`)
|
||||
url.searchParams.set("opencode-version", InstallationVersion)
|
||||
url.searchParams.set("opencode-version", version)
|
||||
url.searchParams.set("os", describeOS())
|
||||
url.searchParams.set("terminal", describeTerminal())
|
||||
url.searchParams.set(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue