Browse Source

refactor(tui): group tab settings

Dax Raad 1 week ago
parent
commit
139c9febe4

+ 3 - 3
packages/tui/src/component/dialog-config.tsx

@@ -94,9 +94,9 @@ export const settings: Setting[] = [
     keywords: ["transcript", "messages"],
   },
   {
-    title: "Tabs",
-    category: "Session",
-    path: ["session", "tabs"],
+    title: "Enabled",
+    category: "Tabs",
+    path: ["tabs", "enabled"],
     default: false,
     values: [false, true],
     labels: ["off", "on"],

+ 6 - 2
packages/tui/src/config/index.tsx

@@ -120,11 +120,15 @@ export const Info = Schema.Struct({
       markdown: Schema.optional(Schema.Literals(["source", "rendered"])).annotate({
         description: "Show Markdown syntax markers or conceal them in rendered transcript content",
       }),
-      tabs: Schema.optional(Schema.Boolean).annotate({
+    }),
+  ).annotate({ description: "Session transcript presentation settings" }),
+  tabs: Schema.optional(
+    Schema.Struct({
+      enabled: Schema.optional(Schema.Boolean).annotate({
         description: "Use a persistent session tab strip instead of pinned quick-switch sessions",
       }),
     }),
-  ).annotate({ description: "Session transcript presentation settings" }),
+  ).annotate({ description: "Session tab settings" }),
   mini: Schema.optional(
     Schema.Struct({
       thinking: Schema.optional(Schema.Literals(["show", "hide"])).annotate({

+ 1 - 1
packages/tui/src/context/session-tabs.tsx

@@ -34,7 +34,7 @@ export const { use: useSessionTabs, provider: SessionTabsProvider } = createSimp
     const event = useEvent()
     const config = useConfig().data
     const filePath = path.join(useTuiPaths().state, "session-tabs.json")
-    const enabled = () => config.session?.tabs ?? false
+    const enabled = () => config.tabs?.enabled ?? false
     const state: {
       pending: boolean
       saving: boolean

+ 2 - 2
packages/tui/test/config-v2.test.tsx

@@ -17,8 +17,8 @@ test("validates mini replay settings", () => {
 test("validates the session tabs setting", () => {
   const decode = Schema.decodeUnknownSync(Info)
 
-  expect(decode({ session: { tabs: true } })).toEqual({ session: { tabs: true } })
-  expect(() => decode({ session: { tabs: "on" } })).toThrow()
+  expect(decode({ tabs: { enabled: true } })).toEqual({ tabs: { enabled: true } })
+  expect(() => decode({ tabs: { enabled: "on" } })).toThrow()
 })
 
 test("resolves nested config and keybind defaults", () => {