/** @jsxImportSource @opentui/solid */ import { describe, expect, test } from "bun:test" import { Global } from "@opencode-ai/core/global" import { tmpdir } from "../../../fixture/fixture" import { mount } from "./sync-fixture" describe("tui sync", () => { test("refresh scopes sessions by default and lists project sessions when disabled", async () => { const previous = Global.Path.state await using tmp = await tmpdir() Global.Path.state = tmp.path await Bun.write(`${tmp.path}/kv.json`, "{}") const { app, kv, sync, session } = await mount() try { expect(kv.get("session_directory_filter_enabled", true)).toBe(true) expect(session.at(-1)?.searchParams.get("scope")).toBeNull() expect(session.at(-1)?.searchParams.get("path")).toBe("packages/opencode") kv.set("session_directory_filter_enabled", false) await sync.session.refresh() expect(session.at(-1)?.searchParams.get("scope")).toBe("project") expect(session.at(-1)?.searchParams.get("path")).toBeNull() } finally { app.renderer.destroy() Global.Path.state = previous } }) })