refactor(tui): rename link concept to pair
This commit is contained in:
@@ -209,7 +209,7 @@ export const Commands = Spec.make(typeof OPENCODE_CLI_NAME === "string" ? OPENCO
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
Spec.make("link", { description: "Show server connection information" }),
|
Spec.make("pair", { description: "Show server pairing information" }),
|
||||||
Spec.make("serve", {
|
Spec.make("serve", {
|
||||||
description: "Start the v2 API server",
|
description: "Start the v2 API server",
|
||||||
params: {
|
params: {
|
||||||
|
|||||||
+3
-3
@@ -8,8 +8,8 @@ import { Runtime } from "../../framework/runtime"
|
|||||||
import { ServiceConfig } from "../../services/service-config"
|
import { ServiceConfig } from "../../services/service-config"
|
||||||
|
|
||||||
export default Runtime.handler(
|
export default Runtime.handler(
|
||||||
Commands.commands.link,
|
Commands.commands.pair,
|
||||||
Effect.fn("cli.link")(function* () {
|
Effect.fn("cli.pair")(function* () {
|
||||||
const endpoint = yield* Service.start(yield* ServiceConfig.options())
|
const endpoint = yield* Service.start(yield* ServiceConfig.options())
|
||||||
const password = yield* ServiceConfig.password()
|
const password = yield* ServiceConfig.password()
|
||||||
const server = yield* Effect.tryPromise(() =>
|
const server = yield* Effect.tryPromise(() =>
|
||||||
@@ -24,7 +24,7 @@ export default Runtime.handler(
|
|||||||
` Username ${info.username}`,
|
` Username ${info.username}`,
|
||||||
` Password ${info.password}`,
|
` Password ${info.password}`,
|
||||||
"",
|
"",
|
||||||
" Scan to connect",
|
" Scan to pair",
|
||||||
"",
|
"",
|
||||||
renderUnicodeCompact(JSON.stringify(info), { border: 2 })
|
renderUnicodeCompact(JSON.stringify(info), { border: 2 })
|
||||||
.split(EOL)
|
.split(EOL)
|
||||||
@@ -36,7 +36,7 @@ const Handlers = Runtime.handlers(Commands, {
|
|||||||
migrate: () => import("./commands/handlers/migrate"),
|
migrate: () => import("./commands/handlers/migrate"),
|
||||||
mini: () => import("./commands/handlers/mini"),
|
mini: () => import("./commands/handlers/mini"),
|
||||||
run: () => import("./commands/handlers/run"),
|
run: () => import("./commands/handlers/run"),
|
||||||
link: () => import("./commands/handlers/link"),
|
pair: () => import("./commands/handlers/pair"),
|
||||||
service: {
|
service: {
|
||||||
start: () => import("./commands/handlers/service/start"),
|
start: () => import("./commands/handlers/service/start"),
|
||||||
restart: () => import("./commands/handlers/service/restart"),
|
restart: () => import("./commands/handlers/service/restart"),
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ import { useConnected } from "./component/use-connected"
|
|||||||
import { DialogMcp } from "./component/dialog-mcp"
|
import { DialogMcp } from "./component/dialog-mcp"
|
||||||
import { DialogStatus } from "./component/dialog-status"
|
import { DialogStatus } from "./component/dialog-status"
|
||||||
import { DialogDebug } from "./component/dialog-debug"
|
import { DialogDebug } from "./component/dialog-debug"
|
||||||
import { DialogLink, type DialogLinkCredentials } from "./component/dialog-link"
|
import { DialogPair, type DialogPairCredentials } from "./component/dialog-pair"
|
||||||
import { createOpencodeClient } from "@opencode-ai/sdk/v2/client"
|
import { createOpencodeClient } from "@opencode-ai/sdk/v2/client"
|
||||||
import { DialogThemeList } from "./component/dialog-theme-list"
|
import { DialogThemeList } from "./component/dialog-theme-list"
|
||||||
import { DialogHelp } from "./ui/dialog-help"
|
import { DialogHelp } from "./ui/dialog-help"
|
||||||
@@ -123,7 +123,7 @@ const appBindingCommands = [
|
|||||||
"provider.connect",
|
"provider.connect",
|
||||||
"console.org.switch",
|
"console.org.switch",
|
||||||
"opencode.status",
|
"opencode.status",
|
||||||
"server.link",
|
"server.pair",
|
||||||
"opencode.debug",
|
"opencode.debug",
|
||||||
"theme.switch",
|
"theme.switch",
|
||||||
"theme.switch_mode",
|
"theme.switch_mode",
|
||||||
@@ -358,7 +358,7 @@ export const run = Effect.fn("Tui.run")(function* (input: TuiInput) {
|
|||||||
<App
|
<App
|
||||||
onSnapshot={input.onSnapshot}
|
onSnapshot={input.onSnapshot}
|
||||||
pluginHost={input.pluginHost}
|
pluginHost={input.pluginHost}
|
||||||
link={
|
pair={
|
||||||
input.server.endpoint.auth
|
input.server.endpoint.auth
|
||||||
? input.server.endpoint.auth
|
? input.server.endpoint.auth
|
||||||
: {
|
: {
|
||||||
@@ -414,7 +414,7 @@ export const run = Effect.fn("Tui.run")(function* (input: TuiInput) {
|
|||||||
function App(props: {
|
function App(props: {
|
||||||
onSnapshot?: () => Promise<string[]>
|
onSnapshot?: () => Promise<string[]>
|
||||||
pluginHost: TuiPluginHost
|
pluginHost: TuiPluginHost
|
||||||
link?: DialogLinkCredentials
|
pair?: DialogPairCredentials
|
||||||
}) {
|
}) {
|
||||||
const log = useLog({ component: "app" })
|
const log = useLog({ component: "app" })
|
||||||
const startup = useTuiStartup()
|
const startup = useTuiStartup()
|
||||||
@@ -849,11 +849,11 @@ function App(props: {
|
|||||||
category: "System",
|
category: "System",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "server.link",
|
name: "server.pair",
|
||||||
title: "Show server info",
|
title: "Pair device",
|
||||||
slashName: "link",
|
slashName: "pair",
|
||||||
run: () => {
|
run: () => {
|
||||||
dialog.replace(() => <DialogLink credentials={props.link} />)
|
dialog.replace(() => <DialogPair credentials={props.pair} />)
|
||||||
},
|
},
|
||||||
category: "System",
|
category: "System",
|
||||||
},
|
},
|
||||||
|
|||||||
+3
-3
@@ -7,12 +7,12 @@ import { useTheme } from "../context/theme"
|
|||||||
import { useDialog } from "../ui/dialog"
|
import { useDialog } from "../ui/dialog"
|
||||||
import { errorMessage } from "../util/error"
|
import { errorMessage } from "../util/error"
|
||||||
|
|
||||||
export type DialogLinkCredentials = {
|
export type DialogPairCredentials = {
|
||||||
readonly username: string
|
readonly username: string
|
||||||
readonly password: string
|
readonly password: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function DialogLink(props: { credentials?: DialogLinkCredentials }) {
|
export function DialogPair(props: { credentials?: DialogPairCredentials }) {
|
||||||
const sdk = useSDK()
|
const sdk = useSDK()
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
const dimensions = useTerminalDimensions()
|
const dimensions = useTerminalDimensions()
|
||||||
@@ -97,7 +97,7 @@ export function DialogLink(props: { credentials?: DialogLinkCredentials }) {
|
|||||||
<box paddingLeft={2} paddingRight={2} paddingBottom={1} gap={1}>
|
<box paddingLeft={2} paddingRight={2} paddingBottom={1} gap={1}>
|
||||||
<box flexDirection="row" justifyContent="space-between">
|
<box flexDirection="row" justifyContent="space-between">
|
||||||
<text fg={theme.text} attributes={TextAttributes.BOLD}>
|
<text fg={theme.text} attributes={TextAttributes.BOLD}>
|
||||||
Link
|
Pair
|
||||||
</text>
|
</text>
|
||||||
<text fg={theme.textMuted} onMouseUp={() => dialog.clear()}>
|
<text fg={theme.textMuted} onMouseUp={() => dialog.clear()}>
|
||||||
esc
|
esc
|
||||||
Reference in New Issue
Block a user