Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions packages/opencode/src/cli/cmd/tui/routes/home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Prompt, type PromptRef } from "@tui/component/prompt"
import { createEffect, createSignal } from "solid-js"
import { createEffect, createSignal, onCleanup } from "solid-js"
import { Logo } from "../component/logo"
import { useProject } from "../context/project"
import { useSync } from "../context/sync"
Expand All @@ -10,7 +10,6 @@ import { usePromptRef } from "../context/prompt"
import { useLocal } from "../context/local"
import { TuiPluginRuntime } from "@/cli/cmd/tui/plugin/runtime"

let once = false
const placeholder = {
normal: ["Fix a TODO in the codebase", "What is the tech stack of this project?", "Fix broken tests"],
shell: ["ls -la", "git status", "pwd"],
Expand All @@ -25,20 +24,30 @@ export function Home() {
const args = useArgs()
const local = useLocal()
let sent = false
let restored = false

const bind = (r: PromptRef | undefined) => {
setRef(r)
promptRef.set(r)
if (once || !r) return
}

createEffect(() => {
const r = ref()
if (!r || restored) return
if (route.prompt) {
r.set(route.prompt)
once = true
restored = true
return
}
if (!args.prompt) return
r.set({ input: args.prompt, parts: [] })
once = true
}
if (args.prompt) {
r.set({ input: args.prompt, parts: [] })
restored = true
}
})

onCleanup(() => {
restored = false
})

// Wait for sync and model store to be ready before auto-submitting --prompt
createEffect(() => {
Expand Down