mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 20:35:07 +03:00
* sidebar-manager * storage keys * tests * more ai spots * test fix * revert to default * remove ref * Update apps/studio/state/sidebar-manager-state.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update apps/studio/components/ui/AIAssistantPanel/AIAssistant.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix ts * fix * fux * fux query param * clean * fix * more * mock local storage * simplify * remove provider test * remve useopensidebar * fix(new homepage): open ai assistant on advisor card button clicks * Update apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * Update apps/studio/state/sidebar-manager-state.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * refine * editor sidebar manager * reset results * Update apps/studio/components/ui/EditorPanel/EditorPanel.tsx Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> * connect hotkey * initial prompt * fix(editor sidebar): disable hotkey based on user preference * cleanup(inline editor): add migration for hotkey local storage key --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import { proxy, snapshot, useSnapshot } from 'valtio'
|
|
|
|
type Template = {
|
|
name: string
|
|
description: string
|
|
content: string
|
|
}
|
|
|
|
type EditorPanelState = {
|
|
value: string
|
|
templates: Template[]
|
|
results: any[] | undefined
|
|
error: any
|
|
initialPrompt: string
|
|
onChange: ((value: string) => void) | undefined
|
|
}
|
|
|
|
const initialState: EditorPanelState = {
|
|
value: '',
|
|
templates: [],
|
|
results: undefined,
|
|
error: undefined,
|
|
initialPrompt: '',
|
|
onChange: undefined,
|
|
}
|
|
|
|
export const editorPanelState = proxy({
|
|
...initialState,
|
|
setValue(value: string) {
|
|
editorPanelState.value = value
|
|
editorPanelState.onChange?.(value)
|
|
editorPanelState.setResults(undefined)
|
|
editorPanelState.setError(undefined)
|
|
},
|
|
setTemplates(templates: Template[]) {
|
|
editorPanelState.templates = templates
|
|
},
|
|
setResults(results: any[] | undefined) {
|
|
editorPanelState.results = results
|
|
},
|
|
setError(error: any) {
|
|
editorPanelState.error = error
|
|
},
|
|
setInitialPrompt(initialPrompt: string) {
|
|
editorPanelState.initialPrompt = initialPrompt
|
|
},
|
|
reset() {
|
|
Object.assign(editorPanelState, initialState)
|
|
},
|
|
})
|
|
|
|
export const getEditorPanelStateSnapshot = () => snapshot(editorPanelState)
|
|
|
|
export const useEditorPanelStateSnapshot = (options?: Parameters<typeof useSnapshot>[1]) =>
|
|
useSnapshot(editorPanelState, options)
|