From 7de746fade519119e8d47f4ce00bedc36d5ee6de Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Wed, 10 Jun 2026 19:11:35 -0400 Subject: [PATCH] refactor(tui): rename v2 sync context to data --- packages/tui/src/app.tsx | 6 +- .../tui/src/component/prompt/autocomplete.tsx | 4 +- .../tui/src/context/{sync-v2.tsx => data.tsx} | 4 +- .../src/feature-plugins/system/session-v2.tsx | 6 +- .../tui/{sync-v2.test.tsx => data.test.tsx} | 66 +++++++++---------- 5 files changed, 43 insertions(+), 43 deletions(-) rename packages/tui/src/context/{sync-v2.tsx => data.tsx} (99%) rename packages/tui/test/cli/tui/{sync-v2.test.tsx => data.test.tsx} (94%) diff --git a/packages/tui/src/app.tsx b/packages/tui/src/app.tsx index edf9085ae8..a05dda1b4b 100644 --- a/packages/tui/src/app.tsx +++ b/packages/tui/src/app.tsx @@ -34,7 +34,7 @@ import { useEvent } from "./context/event" import { SDKProvider, useSDK } from "./context/sdk" import { StartupLoading } from "./component/startup-loading" import { SyncProvider, useSync } from "./context/sync" -import { SyncProviderV2 } from "./context/sync-v2" +import { DataProvider } from "./context/data" import { LocalProvider, useLocal } from "./context/local" import { DialogModel } from "./component/dialog-model" import { useConnected } from "./component/use-connected" @@ -294,7 +294,7 @@ export const run = Effect.fn("Tui.run")(function* (input: TuiInput) { > - + @@ -315,7 +315,7 @@ export const run = Effect.fn("Tui.run")(function* (input: TuiInput) { - + diff --git a/packages/tui/src/component/prompt/autocomplete.tsx b/packages/tui/src/component/prompt/autocomplete.tsx index b543d7c38e..42656d320a 100644 --- a/packages/tui/src/component/prompt/autocomplete.tsx +++ b/packages/tui/src/component/prompt/autocomplete.tsx @@ -9,7 +9,7 @@ import { useEditorContext } from "../../context/editor" import { useProject } from "../../context/project" import { useSDK } from "../../context/sdk" import { useSync } from "../../context/sync" -import { useSyncV2 } from "../../context/sync-v2" +import { useData } from "../../context/data" import { getScrollAcceleration } from "../../util/scroll" import { useTuiPaths } from "../../context/runtime" import { useTuiConfig } from "../../config" @@ -85,7 +85,7 @@ export function Autocomplete(props: { const editor = useEditorContext() const sdk = useSDK() const sync = useSync() - const syncV2 = useSyncV2() + const syncV2 = useData() const project = useProject() const slashes = useCommandSlashes() const modeStack = useOpencodeModeStack() diff --git a/packages/tui/src/context/sync-v2.tsx b/packages/tui/src/context/data.tsx similarity index 99% rename from packages/tui/src/context/sync-v2.tsx rename to packages/tui/src/context/data.tsx index c3102d2517..fed7a2fb2e 100644 --- a/packages/tui/src/context/sync-v2.tsx +++ b/packages/tui/src/context/data.tsx @@ -56,8 +56,8 @@ function prepend(messages: SessionMessage[], message: SessionMessage) { messages.unshift(message) } -export const { use: useSyncV2, provider: SyncProviderV2 } = createSimpleContext({ - name: "SyncV2", +export const { use: useData, provider: DataProvider } = createSimpleContext({ + name: "Data", init: () => { const [store, setStore] = createStore<{ messages: { diff --git a/packages/tui/src/feature-plugins/system/session-v2.tsx b/packages/tui/src/feature-plugins/system/session-v2.tsx index 8a03ec5dd0..adc2131a69 100644 --- a/packages/tui/src/feature-plugins/system/session-v2.tsx +++ b/packages/tui/src/feature-plugins/system/session-v2.tsx @@ -1,6 +1,6 @@ import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui" import type { BuiltinTuiPlugin } from "../builtins" -import { useSyncV2 } from "../../context/sync-v2" +import { useData } from "../../context/data" import { SplitBorder } from "../../ui/border" import { Spinner } from "../../component/spinner" import { useTheme } from "../../context/theme" @@ -44,7 +44,7 @@ function currentSessionID(api: TuiPluginApi) { } function View(props: { api: TuiPluginApi; sessionID: string }) { - const sync = useSyncV2() + const sync = useData() const dimensions = useTerminalDimensions() const { theme, syntax, subtleSyntax } = useTheme() const messages = createMemo(() => sync.data.messages[props.sessionID] ?? []) @@ -85,7 +85,7 @@ function View(props: { api: TuiPluginApi; sessionID: string }) { > - + {(message, index) => ( diff --git a/packages/tui/test/cli/tui/sync-v2.test.tsx b/packages/tui/test/cli/tui/data.test.tsx similarity index 94% rename from packages/tui/test/cli/tui/sync-v2.test.tsx rename to packages/tui/test/cli/tui/data.test.tsx index 7d6ba5f835..6b0c2925de 100644 --- a/packages/tui/test/cli/tui/sync-v2.test.tsx +++ b/packages/tui/test/cli/tui/data.test.tsx @@ -5,7 +5,7 @@ import type { Event, GlobalEvent } from "@opencode-ai/sdk/v2" import { onMount } from "solid-js" import { ProjectProvider } from "../../../src/context/project" import { SDKProvider } from "../../../src/context/sdk" -import { SyncProviderV2, useSyncV2 } from "../../../src/context/sync-v2" +import { DataProvider, useData } from "../../../src/context/data" import { createEventSource, createFetch, directory, json } from "../../fixture/tui-sdk" import { TestTuiContexts } from "../../fixture/tui-environment" @@ -38,14 +38,14 @@ test("sync v2 refreshes references after updates", async () => { data: requests === 1 ? [] : [{ name: "docs", path: "/docs", source: { type: "local", path: "/docs" } }], }) }) - let sync!: ReturnType + let sync!: ReturnType let ready!: () => void const mounted = new Promise((resolve) => { ready = resolve }) function Probe() { - sync = useSyncV2() + sync = useData() onMount(ready) return } @@ -54,9 +54,9 @@ test("sync v2 refreshes references after updates", async () => { - + - + @@ -76,14 +76,14 @@ test("sync v2 refreshes references after updates", async () => { test("sync v2 settles pending tools when a live failure arrives", async () => { const events = createEventSource() const calls = createFetch() - let sync!: ReturnType + let sync!: ReturnType let ready!: () => void const mounted = new Promise((resolve) => { ready = resolve }) function Probe() { - sync = useSyncV2() + sync = useData() onMount(ready) return } @@ -92,9 +92,9 @@ test("sync v2 settles pending tools when a live failure arrives", async () => { - + - + @@ -205,14 +205,14 @@ test("sync v2 settles pending tools when a live failure arrives", async () => { test("sync v2 renders admitted prompts only after promotion", async () => { const events = createEventSource() const calls = createFetch() - let sync!: ReturnType + let sync!: ReturnType let ready!: () => void const mounted = new Promise((resolve) => { ready = resolve }) function Probe() { - sync = useSyncV2() + sync = useData() onMount(ready) return } @@ -221,9 +221,9 @@ test("sync v2 renders admitted prompts only after promotion", async () => { - + - + @@ -269,14 +269,14 @@ test("sync v2 renders admitted prompts only after promotion", async () => { test("sync v2 renders a promoted prompt when admission was missed", async () => { const events = createEventSource() const calls = createFetch() - let sync!: ReturnType + let sync!: ReturnType let ready!: () => void const mounted = new Promise((resolve) => { ready = resolve }) function Probe() { - sync = useSyncV2() + sync = useData() onMount(ready) return } @@ -285,9 +285,9 @@ test("sync v2 renders a promoted prompt when admission was missed", async () => - + - + @@ -317,14 +317,14 @@ test("sync v2 renders a promoted prompt when admission was missed", async () => test("sync v2 projects live context updates with their message ID", async () => { const events = createEventSource() const calls = createFetch() - let sync!: ReturnType + let sync!: ReturnType let ready!: () => void const mounted = new Promise((resolve) => { ready = resolve }) function Probe() { - sync = useSyncV2() + sync = useData() onMount(ready) return } @@ -333,9 +333,9 @@ test("sync v2 projects live context updates with their message ID", async () => - + - + @@ -372,14 +372,14 @@ test("sync v2 preserves live events while snapshot hydration is in flight", asyn if (url.pathname === "/api/session/session-1/message") return response.promise return undefined }) - let sync!: ReturnType + let sync!: ReturnType let ready!: () => void const mounted = new Promise((resolve) => { ready = resolve }) function Probe() { - sync = useSyncV2() + sync = useData() onMount(ready) return } @@ -388,9 +388,9 @@ test("sync v2 preserves live events while snapshot hydration is in flight", asyn - + - + @@ -422,14 +422,14 @@ test("sync v2 replaces stale cached rows while preserving in-flight live rows", if (url.pathname === "/api/session/session-1/message") return response.promise return undefined }) - let sync!: ReturnType + let sync!: ReturnType let ready!: () => void const mounted = new Promise((resolve) => { ready = resolve }) function Probe() { - sync = useSyncV2() + sync = useData() onMount(ready) return } @@ -438,9 +438,9 @@ test("sync v2 replaces stale cached rows while preserving in-flight live rows", - + - + @@ -491,14 +491,14 @@ test("sync v2 preserves snapshot order and metadata for in-flight updates", asyn if (url.pathname === "/api/session/session-1/message") return response.promise return undefined }) - let sync!: ReturnType + let sync!: ReturnType let ready!: () => void const mounted = new Promise((resolve) => { ready = resolve }) function Probe() { - sync = useSyncV2() + sync = useData() onMount(ready) return } @@ -507,9 +507,9 @@ test("sync v2 preserves snapshot order and metadata for in-flight updates", asyn - + - +