diff --git a/packages/tui/package.json b/packages/tui/package.json
index ad7934b633..ee70ca50b0 100644
--- a/packages/tui/package.json
+++ b/packages/tui/package.json
@@ -23,7 +23,6 @@
"./context/project": "./src/context/project.tsx",
"./context/runtime": "./src/context/runtime.tsx",
"./context/sdk": "./src/context/sdk.tsx",
- "./context/sync": "./src/context/sync.tsx",
"./context/theme": "./src/context/theme.tsx",
"./context/editor": "./src/context/editor.ts",
"./context/clipboard": "./src/context/clipboard.tsx",
diff --git a/packages/tui/src/app.tsx b/packages/tui/src/app.tsx
index 0718090e10..574686ced1 100644
--- a/packages/tui/src/app.tsx
+++ b/packages/tui/src/app.tsx
@@ -44,7 +44,6 @@ import { useEvent } from "./context/event"
import { SDKProvider, useSDK } from "./context/sdk"
import { StartupLoading } from "./component/startup-loading"
import { Reconnecting } from "./component/reconnecting"
-import { SyncProvider, useSync } from "./context/sync"
import { DataProvider, useData } from "./context/data"
import { LocationProvider } from "./context/location"
import { LocalProvider, useLocal } from "./context/local"
@@ -345,8 +344,7 @@ export const run = Effect.fn("Tui.run")(function* (input: TuiInput) {
>
-
-
+
@@ -376,8 +374,7 @@ export const run = Effect.fn("Tui.run")(function* (input: TuiInput) {
-
-
+
@@ -430,7 +427,6 @@ function App(props: {
const keymap = useOpencodeKeymap()
const event = useEvent()
const sdk = useSDK()
- const sync = useSync()
const toast = useToast()
const themeState = useTheme()
const { theme, mode, setMode, locked, lock, unlock } = themeState
@@ -480,7 +476,7 @@ function App(props: {
routes: pluginRuntime.routes,
event,
sdk,
- sync,
+ project,
data,
theme: themeState,
toast,
diff --git a/packages/tui/src/context/sync.tsx b/packages/tui/src/context/sync.tsx
deleted file mode 100644
index f0133f85c0..0000000000
--- a/packages/tui/src/context/sync.tsx
+++ /dev/null
@@ -1,94 +0,0 @@
-import type {
- Agent,
- Command,
- Config,
- FormatterStatus,
- LspStatus,
- McpResource,
- McpStatus,
- Message,
- Part,
- PermissionRequest,
- Provider,
- QuestionRequest,
- Session,
- FileDiffInfo,
- VcsInfo,
-} from "@opencode-ai/sdk/v2"
-import { createStore } from "solid-js/store"
-import { createSimpleContext } from "./helper"
-import { useProject } from "./project"
-
-export const {
- context: SyncContext,
- use: useSync,
- provider: SyncProvider,
-} = createSimpleContext({
- name: "Sync",
- init: () => {
- const project = useProject()
- const [store, setStore] = createStore<{
- status: "loading" | "partial" | "complete"
- provider: Provider[]
- agent: Agent[]
- command: Command[]
- permission: Record
- question: Record
- config: Config
- session: Session[]
- session_diff: Record
- message: Record
- part: Record
- lsp: LspStatus[]
- mcp: Record
- mcp_resource: Record
- formatter: FormatterStatus[]
- vcs: VcsInfo | undefined
- }>({
- status: "complete",
- provider: [],
- agent: [],
- command: [],
- permission: {},
- question: {},
- config: {},
- session: [],
- session_diff: {},
- message: {},
- part: {},
- lsp: [],
- mcp: {},
- mcp_resource: {},
- formatter: [],
- vcs: undefined,
- })
-
- return {
- data: store,
- set: setStore,
- get status() {
- return store.status
- },
- get ready() {
- return true
- },
- get path() {
- return project.instance.path()
- },
- session: {
- get(_sessionID: string) {
- return undefined as Session | undefined
- },
- query() {
- return {} as { scope?: "project"; path?: string }
- },
- async refresh() {},
- status(_sessionID: string) {
- return "idle" as const
- },
- async sync(_sessionID: string) {},
- },
- async bootstrap(_input: { fatal?: boolean } = {}) {},
- }
- },
-})
diff --git a/packages/tui/src/plugin/adapters.tsx b/packages/tui/src/plugin/adapters.tsx
index d70d6621aa..4c27c7f9b4 100644
--- a/packages/tui/src/plugin/adapters.tsx
+++ b/packages/tui/src/plugin/adapters.tsx
@@ -3,8 +3,8 @@ import type { Config } from "../config"
import type { useEvent } from "../context/event"
import type { useRoute } from "../context/route"
import type { useSDK } from "../context/sdk"
-import type { useSync } from "../context/sync"
import type { useData } from "../context/data"
+import type { useProject } from "../context/project"
import type { useTheme } from "../context/theme"
import { Dialog as DialogUI, type useDialog } from "../ui/dialog"
import type { useOpencodeKeymap } from "../keymap"
@@ -29,7 +29,7 @@ type Input = {
routes: PluginRoutes
event: ReturnType
sdk: ReturnType
- sync: ReturnType
+ project: ReturnType
data: ReturnType
theme: ReturnType
toast: ReturnType
@@ -95,57 +95,51 @@ function mapOptionCb(cb?: (item: TuiDialogSelectOption) => void) {
return (item: SelectOption) => cb(pickOption(item))
}
-function stateApi(sync: ReturnType, data: ReturnType): TuiPluginApi["state"] {
+function stateApi(project: ReturnType, data: ReturnType): TuiPluginApi["state"] {
return {
get ready() {
return true
},
get config() {
- return sync.data.config
+ return {}
},
get provider() {
- return sync.data.provider
+ return []
},
get path() {
- return sync.path
+ return project.instance.path()
},
get vcs() {
- if (!sync.data.vcs) return
- return {
- branch: sync.data.vcs.branch,
- default_branch: sync.data.vcs.default_branch,
- }
+ return undefined
},
session: {
count() {
return data.session.list().length
},
- get(sessionID) {
- return sync.session.get(sessionID)
+ get(_sessionID) {
+ return undefined
},
- diff(sessionID) {
- return (sync.data.session_diff[sessionID] ?? []).flatMap((item) =>
- item.file === undefined ? [] : [{ ...item, file: item.file }],
- )
+ diff(_sessionID) {
+ return []
},
- messages(sessionID) {
- return sync.data.message[sessionID] ?? []
+ messages(_sessionID) {
+ return []
},
status(sessionID) {
return data.session.status(sessionID) === "running" ? { type: "busy" } : { type: "idle" }
},
- permission(sessionID) {
- return sync.data.permission[sessionID] ?? []
+ permission(_sessionID) {
+ return []
},
- question(sessionID) {
- return sync.data.question[sessionID] ?? []
+ question(_sessionID) {
+ return []
},
},
- part(messageID) {
- return sync.data.part[messageID] ?? []
+ part(_messageID) {
+ return []
},
lsp() {
- return sync.data.lsp.map((item) => ({ id: item.id, root: item.root, status: item.status }))
+ return []
},
mcp() {
return (data.location.mcp.server.list() ?? [])
@@ -297,7 +291,7 @@ export function createTuiApiAdapters(input: Input): Omit boolean, timeout = 2000) {
- const start = Date.now()
- while (!fn()) {
- if (Date.now() - start > timeout) throw new Error("timed out waiting for condition")
- await Bun.sleep(10)
- }
-}
-
-type Ctx = { project: ReturnType; sync: ReturnType }
-
-export async function mount(override?: FetchHandler, state?: string) {
- const events = createEventStream()
- const calls = createFetch(override, events)
- let sync!: ReturnType
- let project!: ReturnType
- let done!: () => void
- const ready = new Promise((resolve) => {
- done = resolve
- })
-
- function Probe() {
- const ctx: Ctx = { project: useProject(), sync: useSync() }
- onMount(() => {
- sync = ctx.sync
- project = ctx.project
- done()
- })
- return
- }
-
- const app = await testRender(() => (
-
-
-
-
-
- {}}>
-
-
-
-
-
-
-
-
-
- ))
-
- await ready
- await wait(() => sync.status === "complete")
- return { app, emit: events.emit, project, sync, session: calls.session }
-}
diff --git a/packages/tui/test/cli/cmd/tui/sync.test.tsx b/packages/tui/test/cli/cmd/tui/sync.test.tsx
deleted file mode 100644
index e93c81f091..0000000000
--- a/packages/tui/test/cli/cmd/tui/sync.test.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-/** @jsxImportSource @opentui/solid */
-import { expect, test } from "bun:test"
-import { mount } from "./sync-fixture"
-
-test("legacy sync is an inert compatibility context", async () => {
- const { app, session, sync } = await mount()
-
- try {
- expect(sync.status).toBe("complete")
- expect(sync.ready).toBe(true)
- expect(sync.data.session).toEqual([])
- expect(sync.data.message).toEqual({})
- expect(sync.data.provider).toEqual([])
- expect(sync.session.get("ses_test")).toBeUndefined()
-
- await sync.bootstrap()
- await sync.session.refresh()
- await sync.session.sync("ses_test")
-
- expect(session).toEqual([])
- } finally {
- app.renderer.destroy()
- }
-})