refactor(tui): migrate v2 calls to new client
This commit is contained in:
parent
9ff7ef3fb0
commit
e2eed76101
17 changed files with 2834 additions and 3590 deletions
|
|
@ -25,9 +25,8 @@ export function DialogPair(props: { credentials?: DialogPairCredentials }) {
|
|||
dialog.setCentered(true)
|
||||
|
||||
const [server] = createResource(() =>
|
||||
sdk.client.v2.server
|
||||
.get({ throwOnError: true })
|
||||
.then((result) => result.data)
|
||||
sdk.api.server
|
||||
.get()
|
||||
.catch((error) => {
|
||||
setLoadError(error)
|
||||
return undefined
|
||||
|
|
|
|||
|
|
@ -44,8 +44,7 @@ export function DialogSessionList() {
|
|||
directory: location.directory,
|
||||
workspace: location.workspaceID,
|
||||
})
|
||||
// oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- generated client output is readonly; session list UI reuses legacy mutable session types.
|
||||
return { query, sessions: structuredClone(response.data) as SessionInfo[] }
|
||||
return { query, sessions: response.data }
|
||||
} catch (error) {
|
||||
// A transient transport failure must degrade search, not crash the TUI
|
||||
// through the root ErrorBoundary when the errored resource is read.
|
||||
|
|
@ -141,7 +140,7 @@ export function DialogSessionList() {
|
|||
setToDelete(option.value)
|
||||
return
|
||||
}
|
||||
void sdk.client.v2.session.remove({ sessionID: option.value }, { throwOnError: true }).catch((error) => {
|
||||
void sdk.api.session.remove({ sessionID: option.value }).catch((error) => {
|
||||
setToDelete(undefined)
|
||||
toast.show({
|
||||
message: `Failed to delete session: ${errorMessage(error)}`,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import { usePromptStash } from "../../prompt/stash"
|
|||
import { DialogStash } from "../dialog-stash"
|
||||
import { type AutocompleteRef, Autocomplete } from "./autocomplete"
|
||||
import { useRenderer, useTerminalDimensions, type JSX } from "@opentui/solid"
|
||||
import type { SessionInfo, UserMessage } from "@opencode-ai/sdk/v2"
|
||||
import type { UserMessage } from "@opencode-ai/sdk/v2"
|
||||
import { Locale } from "../../util/locale"
|
||||
import { errorMessage } from "../../util/error"
|
||||
import { createColors, createFrames } from "../../ui/spinner"
|
||||
|
|
@ -1027,8 +1027,7 @@ export function Prompt(props: PromptProps) {
|
|||
}
|
||||
|
||||
sessionID = created.id
|
||||
// oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- generated client output is readonly; prompt state still uses legacy mutable session types.
|
||||
session = structuredClone(created) as SessionInfo
|
||||
session = created
|
||||
}
|
||||
|
||||
const inputText = expandTrackedPastedText(
|
||||
|
|
@ -1064,7 +1063,7 @@ export function Prompt(props: PromptProps) {
|
|||
|
||||
if (store.mode === "shell") {
|
||||
move.startSubmit()
|
||||
void sdk.client.v2.session.shell({
|
||||
void sdk.api.session.shell({
|
||||
sessionID,
|
||||
command: inputText,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue