Download packages/app/src/components/prompt-input/transient-state.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/components/prompt-input/transient-state.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/app/src/components/prompt-input/transient-state.ts
-
curl -L -o transient-state.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/components/prompt-input/transient-state.ts
1.3 kB
| import { createComputed, on, type Accessor } from "solid-js" | |
| import { createStore, type SetStoreFunction } from "solid-js/store" | |
| import type { PromptHistoryEntry } from "./history" | |
| export type PromptInputTransientState = { | |
| popover: "at" | "slash" | null | |
| slashMenu: boolean | |
| slashMenuQuery: string | |
| historyIndex: number | |
| savedPrompt: PromptHistoryEntry | null | |
| placeholder: number | |
| draggingType: "image" | "@mention" | null | |
| mode: "normal" | "shell" | |
| applyingHistory: boolean | |
| } | |
| function resetPromptInputTransientState(setStore: SetStoreFunction<PromptInputTransientState>) { | |
| setStore({ | |
| popover: null, | |
| slashMenu: false, | |
| slashMenuQuery: "", | |
| historyIndex: -1, | |
| savedPrompt: null, | |
| draggingType: null, | |
| mode: "normal", | |
| applyingHistory: false, | |
| }) | |
| } | |
| export function createPromptInputTransientState(identity: Accessor<unknown>, placeholder: number) { | |
| const [store, setStore] = createStore<PromptInputTransientState>({ | |
| popover: null, | |
| slashMenu: false, | |
| slashMenuQuery: "", | |
| historyIndex: -1, | |
| savedPrompt: null, | |
| placeholder, | |
| draggingType: null, | |
| mode: "normal", | |
| applyingHistory: false, | |
| }) | |
| createComputed(on(identity, () => resetPromptInputTransientState(setStore), { defer: true })) | |
| return [store, setStore] as const | |
| } | |