mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-10 07:08:28 +00:00
refactor(tui): simplify located form name
This commit is contained in:
parent
96ad51dd93
commit
0070a657ab
3 changed files with 9 additions and 9 deletions
|
|
@ -37,7 +37,7 @@ const messageIDFromEvent = (eventID: string) => eventID.replace(/^evt_/, "msg_")
|
|||
// Global MCP elicitations temporarily use "global" instead of a real session ID, so the
|
||||
// server cannot recover their Location when settling them. Preserve the event Location
|
||||
// until MCP elicitations carry session ownership.
|
||||
export type FormInfoWithLocation = FormInfo & { readonly location?: LocationRef }
|
||||
export type FormWithLocation = FormInfo & { readonly location?: LocationRef }
|
||||
|
||||
type LocationData = {
|
||||
agent?: AgentInfo[]
|
||||
|
|
@ -65,7 +65,7 @@ type Data = {
|
|||
input: Record<string, string[]>
|
||||
permission: Record<string, PermissionV2Request[]>
|
||||
// Pending forms keyed by owner: a session ID or the temporary "global" elicitation sentinel.
|
||||
form: Record<string, FormInfoWithLocation[]>
|
||||
form: Record<string, FormWithLocation[]>
|
||||
}
|
||||
project: {
|
||||
permission: Record<string, PermissionSavedInfo[]>
|
||||
|
|
@ -1032,7 +1032,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
|
|||
directory: response.location.directory,
|
||||
workspaceID: response.location.workspaceID,
|
||||
}
|
||||
const forms = response.data.reduce<Record<string, FormInfoWithLocation[]>>(
|
||||
const forms = response.data.reduce<Record<string, FormWithLocation[]>>(
|
||||
(result, form) => ({
|
||||
...result,
|
||||
[form.sessionID]: [
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import type { ScrollBoxRenderable, TextareaRenderable } from "@opentui/core"
|
|||
import open from "open"
|
||||
import { selectedForeground, tint, useTheme } from "../../context/theme"
|
||||
import type { FormField, FormValue } from "@opencode-ai/sdk/v2"
|
||||
import type { FormInfoWithLocation } from "../../context/data"
|
||||
import type { FormWithLocation } from "../../context/data"
|
||||
import { useSDK } from "../../context/sdk"
|
||||
import { useClipboard } from "../../context/clipboard"
|
||||
import { SplitBorder } from "../../ui/border"
|
||||
|
|
@ -141,7 +141,7 @@ function display(field: Field, value: FormValue | undefined) {
|
|||
return label(value)
|
||||
}
|
||||
|
||||
function requestOptions(form: FormInfoWithLocation) {
|
||||
function requestOptions(form: FormWithLocation) {
|
||||
if (form.sessionID !== "global" || !form.location) return undefined
|
||||
return {
|
||||
headers: {
|
||||
|
|
@ -151,11 +151,11 @@ function requestOptions(form: FormInfoWithLocation) {
|
|||
}
|
||||
}
|
||||
|
||||
export function FormPrompt(props: { form: FormInfoWithLocation }) {
|
||||
export function FormPrompt(props: { form: FormWithLocation }) {
|
||||
return <FieldsPrompt form={props.form} />
|
||||
}
|
||||
|
||||
function FieldsPrompt(props: { form: FormInfoWithLocation }) {
|
||||
function FieldsPrompt(props: { form: FormWithLocation }) {
|
||||
const sdk = useSDK()
|
||||
const { theme } = useTheme()
|
||||
const renderer = useRenderer()
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { mkdir } from "node:fs/promises"
|
|||
import path from "node:path"
|
||||
import { onCleanup } from "solid-js"
|
||||
import { ClipboardProvider } from "../../../src/context/clipboard"
|
||||
import type { FormInfoWithLocation } from "../../../src/context/data"
|
||||
import type { FormWithLocation } from "../../../src/context/data"
|
||||
import { KVProvider } from "../../../src/context/kv"
|
||||
import { SDKProvider } from "../../../src/context/sdk"
|
||||
import { ThemeProvider } from "../../../src/context/theme"
|
||||
|
|
@ -75,7 +75,7 @@ async function mountForm(width = 80) {
|
|||
title: "Authorize access",
|
||||
},
|
||||
],
|
||||
} satisfies FormInfoWithLocation
|
||||
} satisfies FormWithLocation
|
||||
const { FormPrompt } = await import("../../../src/routes/session/form")
|
||||
|
||||
function Harness() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue