mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-13 15:44:56 +00:00
ui cleanup
This commit is contained in:
@@ -50,8 +50,6 @@ import { WorkspaceLabel, type WorkspaceStatus } from "../workspace-label"
|
||||
export type PromptProps = {
|
||||
sessionID?: string
|
||||
workspaceID?: string
|
||||
workspaceSelection?: WorkspaceSelection
|
||||
onWorkspaceSelectionChange?: (selection: WorkspaceSelection | undefined) => void
|
||||
onWorkspaceCreatingChange?: (creating: boolean) => void
|
||||
visible?: boolean
|
||||
disabled?: boolean
|
||||
@@ -161,11 +159,9 @@ export function Prompt(props: PromptProps) {
|
||||
const [warpNotice, setWarpNotice] = createSignal<string>()
|
||||
const currentProviderLabel = createMemo(() => local.model.parsed().provider)
|
||||
const hasRightContent = createMemo(() => Boolean(props.right))
|
||||
const selectedWorkspace = () => props.workspaceSelection ?? workspaceSelection()
|
||||
|
||||
function selectWorkspace(selection: WorkspaceSelection | undefined) {
|
||||
setWorkspaceSelection(selection)
|
||||
props.onWorkspaceSelectionChange?.(selection)
|
||||
}
|
||||
|
||||
function setCreatingWorkspace(creating: boolean) {
|
||||
@@ -782,6 +778,7 @@ export function Prompt(props: PromptProps) {
|
||||
|
||||
async function submit() {
|
||||
setWarpNotice(undefined)
|
||||
|
||||
// IME: double-defer may fire before onContentChange flushes the last
|
||||
// composed character (e.g. Korean hangul) to the store, so read
|
||||
// plainText directly and sync before any downstream reads.
|
||||
@@ -891,7 +888,7 @@ export function Prompt(props: PromptProps) {
|
||||
|
||||
let sessionID = props.sessionID
|
||||
if (sessionID == null) {
|
||||
const workspace = selectedWorkspace()
|
||||
const workspace = workspaceSelection()
|
||||
const workspaceID = iife(() => {
|
||||
if (!workspace) return undefined
|
||||
if (workspace.type === "none") return undefined
|
||||
@@ -1125,7 +1122,7 @@ export function Prompt(props: PromptProps) {
|
||||
| { type: "existing"; workspaceType: string; workspaceName: string; status?: WorkspaceStatus }
|
||||
| undefined
|
||||
>(() => {
|
||||
const selected = selectedWorkspace()
|
||||
const selected = workspaceSelection()
|
||||
if (!selected) return
|
||||
if (selected.type === "none") return
|
||||
if (props.sessionID && !workspaceCreating()) return
|
||||
|
||||
@@ -9,7 +9,6 @@ import { useRouteData } from "@tui/context/route"
|
||||
import { usePromptRef } from "../context/prompt"
|
||||
import { useLocal } from "../context/local"
|
||||
import { TuiPluginRuntime } from "@/cli/cmd/tui/plugin/runtime"
|
||||
import type { WorkspaceSelection } from "../component/dialog-workspace-create"
|
||||
|
||||
let once = false
|
||||
const placeholder = {
|
||||
@@ -23,28 +22,10 @@ export function Home() {
|
||||
const route = useRouteData("home")
|
||||
const promptRef = usePromptRef()
|
||||
const [ref, setRef] = createSignal<PromptRef | undefined>()
|
||||
const [workspaceSelection, setWorkspaceSelection] = createSignal<WorkspaceSelection>()
|
||||
const args = useArgs()
|
||||
const local = useLocal()
|
||||
let sent = false
|
||||
|
||||
const currentWorkspaceSelection = (): WorkspaceSelection | undefined => {
|
||||
const workspaceID = project.workspace.current()
|
||||
if (!workspaceID) return { type: "none" }
|
||||
const workspace = project.workspace.get(workspaceID)
|
||||
return {
|
||||
type: "existing",
|
||||
workspaceID,
|
||||
workspaceType: workspace?.type ?? "unknown",
|
||||
workspaceName: workspace?.name ?? workspaceID,
|
||||
}
|
||||
}
|
||||
|
||||
createEffect(() => {
|
||||
if (workspaceSelection()) return
|
||||
setWorkspaceSelection(currentWorkspaceSelection())
|
||||
})
|
||||
|
||||
const bind = (r: PromptRef | undefined) => {
|
||||
setRef(r)
|
||||
promptRef.set(r)
|
||||
@@ -92,8 +73,6 @@ export function Home() {
|
||||
<Prompt
|
||||
ref={bind}
|
||||
workspaceID={project.workspace.current()}
|
||||
workspaceSelection={workspaceSelection()}
|
||||
onWorkspaceSelectionChange={setWorkspaceSelection}
|
||||
right={<TuiPluginRuntime.Slot name="home_prompt_right" workspace_id={project.workspace.current()} />}
|
||||
placeholders={placeholder}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user