Co-authored-by: opencode <opencode@sst.dev> Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com> Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com> Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Co-authored-by: Victor Navarro <vn4varro@gmail.com> Co-authored-by: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Co-authored-by: Frank <frank@anoma.ly> Co-authored-by: Dax Raad <d@ironbay.co> Co-authored-by: Dax <mail@thdxr.com> Co-authored-by: Nabs <nabil@instafork.com> Co-authored-by: usrnk1 <7547651+usrnk1@users.noreply.github.com> Co-authored-by: Brendan Allan <git@brendonovich.dev> Co-authored-by: Vladimir Glafirov <vglafirov@gitlab.com> Co-authored-by: AidenGeunGeun <eastlandwyvern@gmail.com> Co-authored-by: Mark <geraint0923@users.noreply.github.com> Co-authored-by: Aiden Cline <aidenpcline@gmail.com> Co-authored-by: David Hill <1879069+iamdavidhill@users.noreply.github.com> Co-authored-by: Jay <air@live.ca> Co-authored-by: Jay <53023+jayair@users.noreply.github.com> Co-authored-by: BB84 <110078428+BB-84C@users.noreply.github.com> Co-authored-by: Dustin Deus <deusdustin@gmail.com> Co-authored-by: Jack <jack@anoma.ly> Co-authored-by: Sebastian <hasta84@gmail.com> Co-authored-by: Jérôme Benoit <jerome.benoit@sap.com> Co-authored-by: Test User <test@test.com> Co-authored-by: Simon Klee <hello@simonklee.dk> Co-authored-by: Rahul A Mistry <149420892+ProdigyRahul@users.noreply.github.com> Co-authored-by: Qiping Li <liqiping1991@gmail.com> Co-authored-by: liqiping <liqiping@msh.team> Co-authored-by: OpeOginni <107570612+OpeOginni@users.noreply.github.com> Co-authored-by: Matthias Reso <13337103+mreso@users.noreply.github.com> Co-authored-by: tobwen <1864057+tobwen@users.noreply.github.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
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
|
|
}
|