summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-01-08 07:41:20 -0600
committerAdam <[email protected]>2026-01-08 17:48:15 -0600
commitbe9b2bab156d3eccaf1c8ea4fce2523407833fdd (patch)
tree0fddff15d81bfd0e5dd8c88d55ac2948f56878d8 /packages/ui/src
parentc949e5b390814348a2a86802d4c350e964864da6 (diff)
downloadopencode-be9b2bab156d3eccaf1c8ea4fce2523407833fdd.tar.gz
opencode-be9b2bab156d3eccaf1c8ea4fce2523407833fdd.zip
feat(app): cache session-scoped stores, optional context gating
Diffstat (limited to 'packages/ui/src')
-rw-r--r--packages/ui/src/context/helper.tsx7
1 files changed, 7 insertions, 0 deletions
diff --git a/packages/ui/src/context/helper.tsx b/packages/ui/src/context/helper.tsx
index 53f987945..86684c876 100644
--- a/packages/ui/src/context/helper.tsx
+++ b/packages/ui/src/context/helper.tsx
@@ -3,12 +3,19 @@ import { createContext, createMemo, Show, useContext, type ParentProps, type Acc
export function createSimpleContext<T, Props extends Record<string, any>>(input: {
name: string
init: ((input: Props) => T) | (() => T)
+ gate?: boolean
}) {
const ctx = createContext<T>()
return {
provider: (props: ParentProps<Props>) => {
const init = input.init(props)
+ const gate = input.gate ?? true
+
+ if (!gate) {
+ return <ctx.Provider value={init}>{props.children}</ctx.Provider>
+ }
+
// Access init.ready inside the memo to make it reactive for getter properties
const isReady = createMemo(() => {
// @ts-expect-error