summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMani Sundararajan <[email protected]>2026-01-11 01:20:04 -0500
committerGitHub <[email protected]>2026-01-11 00:20:04 -0600
commit9280db3297ae0e87ef44eb5538784bb94e4ab206 (patch)
tree3459da4f48355edcda1ec41294e901de3e4f19fa
parent0cc3c3bc78ca4534578c96da89bdd31f5c357f9e (diff)
downloadopencode-9280db3297ae0e87ef44eb5538784bb94e4ab206.tar.gz
opencode-9280db3297ae0e87ef44eb5538784bb94e4ab206.zip
fix(tui): move props.ref to onMount (#7702)
-rw-r--r--packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx65
1 files changed, 32 insertions, 33 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
index 4558914cb..1463c813e 100644
--- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
+++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
@@ -317,6 +317,38 @@ export function Prompt(props: PromptProps) {
onMount(() => {
promptPartTypeId = input.extmarks.registerType("prompt-part")
+ props.ref?.({
+ get focused() {
+ return input.focused
+ },
+ get current() {
+ return store.prompt
+ },
+ focus() {
+ input.focus()
+ },
+ blur() {
+ input.blur()
+ },
+ set(prompt) {
+ input.setText(prompt.input)
+ setStore("prompt", prompt)
+ restoreExtmarksFromParts(prompt.parts)
+ input.gotoBufferEnd()
+ },
+ reset() {
+ input.clear()
+ input.extmarks.clear()
+ setStore("prompt", {
+ input: "",
+ parts: [],
+ })
+ setStore("extmarkToPartIndex", new Map())
+ },
+ submit() {
+ submit()
+ },
+ })
})
function restoreExtmarksFromParts(parts: PromptInfo["parts"]) {
@@ -452,39 +484,6 @@ export function Prompt(props: PromptProps) {
},
])
- props.ref?.({
- get focused() {
- return input.focused
- },
- get current() {
- return store.prompt
- },
- focus() {
- input.focus()
- },
- blur() {
- input.blur()
- },
- set(prompt) {
- input.setText(prompt.input)
- setStore("prompt", prompt)
- restoreExtmarksFromParts(prompt.parts)
- input.gotoBufferEnd()
- },
- reset() {
- input.clear()
- input.extmarks.clear()
- setStore("prompt", {
- input: "",
- parts: [],
- })
- setStore("extmarkToPartIndex", new Map())
- },
- submit() {
- submit()
- },
- })
-
async function submit() {
if (props.disabled) return
if (autocomplete?.visible) return