From a1766e45ccbcbebd4c5f53414c8864f7a77aee60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gurruchaga?= Date: Fri, 13 Nov 2026 12:43:35 -0300 Subject: [PATCH] feat(zgx): show harness icons in side chat tabs --- apps/zgx/ui/screens/chat/lane_tab.luau | 109 ++++++++----------- apps/zgx/ui/screens/panel/init.luau | 2 +- apps/zgx/ui/templates/zeron-v2/.base.json | 4 +- apps/zgx/ui/tests/side_chat_parity.test.luau | 35 ++++-- 4 files changed, 79 insertions(+), 71 deletions(-) diff --git a/apps/zgx/ui/screens/chat/lane_tab.luau b/apps/zgx/ui/screens/chat/lane_tab.luau index 357698a326..d4157ea02a 100644 --- a/apps/zgx/ui/screens/chat/lane_tab.luau +++ b/apps/zgx/ui/screens/chat/lane_tab.luau @@ -31,7 +31,7 @@ local Completions = require("@app/screens/chat/completions") local Find = require("@app/screens/chat/find") local Invocations = require("@app/screens/chat/invocations") local ZeronCommands = require("@app/screens/chat/zeron_commands") -local look = require("@app/screens/shell/project_look") +local SessionRow = require("@ds/session_row") local Appshots = require("@app/screens/chat/appshots") local DropOverlay = require("@ds/drop_overlay") @@ -90,71 +90,58 @@ function M.icon(tab: any): string return if tab.kind == "subagent" then "bot" else "side-chat" end --- A side chat's project: where its composer has it before its first message, --- then its chat's; its parent's while neither is known. -local function project_of(tab: any, picked: State): any - local chat = tab.chat - local parent = lanes.unsent:get()[chat] - local id: string? = nil - if parent then - id = picked:get() - else - local s = lanes.view(tab.id).session:get() - if s and s.id == chat and s.harness then - id = s.project - parent = nil - else - local row = row_of(chat) - parent = if row then row.parent else nil +-- The same harness mark as the sidebar, in the tab's existing 20pt slot. +-- Follow the composer's pick even before the chat's first message; while +-- loading, the session list (or an unsent chat's parent) supplies its mark. +function M.tile(tab: any): Node + local picked = ui.state(`chat_lane_model_{tab.chat}`, nil :: string?) + local function current(): any + local row = row_of(tab.chat) + local session = lanes.view(tab.id).session:get() + local harness = if session and session.id == tab.chat then session.harness else nil + harness = harness or (if row then row.harness else nil) + local parent = lanes.unsent:get()[tab.chat] + if not harness and parent then + local open = store.session:get() + if open and open.id == parent then + harness = open.harness + end + for _, c in sessions.now:get().chats do + if c.id == parent then + row = c + harness = harness or c.harness + break + end + end end - end - local now = sessions.now:get() - if not id and parent then - for _, c in now.chats do - if c.id == parent then - id = c.project + local catalog = store.catalog:get() + for _, m in catalog.models do + if m.value == picked:get() then + harness = m.harness + break end end - end - for _, p in now.projects do - if p.id == id then - return p + local agent = if row and (not harness or row.harness == harness) then row.agent else nil + local icon = if row and row.harness == harness then row.agent_icon else nil + for _, h in catalog.harnesses do + if h.id == harness then + agent = h.mark or agent + icon = h.icon or icon + break + end end + return { harness = harness, agent = agent, agent_icon = icon } end - return nil -end - --- A side chat's tile in its tab: its project's, as a chat's on the top bar (one --- with no project, the side chat's glyph, there too). -function M.tile(tab: any): Node - local picked = ui.state(`chat_lane_project_{tab.chat}`, nil :: string?) - return ui.presence(function(): string - local p = project_of(tab, picked) - return if p then p.id else "" - end, function(which: string): Node - if which == "" then - return ds.Tile { size = 20, inside = ds.Icon { name = "side-chat", size = 14 } } - end - return ds.Tile { - size = 20, - label = function(): string? - local p = project_of(tab, picked) - return if p then p.name else nil - end, - hue = function(): string? - local p = project_of(tab, picked) - return if p then look.of(p).hue else nil - end, - src = function(): string? - local p = project_of(tab, picked) - return if p then look.of(p).src else nil - end, - emoji = function(): string? - local p = project_of(tab, picked) - return if p then look.of(p).emoji else nil - end, - } - end, { w = 20, h = 20, shrink = 0 }) + return ui.div { + w = 20, + h = 20, + shrink = 0, + items = "center", + justify = "center", + SessionRow.mark(current, function(): boolean + return true + end), + } end -- What a side chat's tab says at its end: whether it awaits a person or is at diff --git a/apps/zgx/ui/screens/panel/init.luau b/apps/zgx/ui/screens/panel/init.luau index a9f4ed24b8..42f8be4c1f 100644 --- a/apps/zgx/ui/screens/panel/init.luau +++ b/apps/zgx/ui/screens/panel/init.luau @@ -818,7 +818,7 @@ M.Panel = ui.component(function(props: Props): Node return FileIcon { name = name, size = 14 } end) end - -- Its tile: a side chat's its project's, as a chat's on the top bar. + -- A side chat's harness mark; other tabs keep their kind's icon. local function make_tile(): Node if tab.kind == "side_chat" and Lanes then return Lanes.tile(tab) diff --git a/apps/zgx/ui/templates/zeron-v2/.base.json b/apps/zgx/ui/templates/zeron-v2/.base.json index b9f5bdd82a..b3d10f95de 100644 --- a/apps/zgx/ui/templates/zeron-v2/.base.json +++ b/apps/zgx/ui/templates/zeron-v2/.base.json @@ -2,8 +2,8 @@ "ds/sidebar.luau": "fe41bd32634d1aba", "ds/tokens.luau": "1e102d44820a2e42", "screens/chat/composer.luau": "d8d9cbd4198bfb90", - "screens/chat/lane_tab.luau": "782ebff9bc222ad8", - "screens/panel/init.luau": "999e58c827c6c9ff", + "screens/chat/lane_tab.luau": "0902f145c0ea718f", + "screens/panel/init.luau": "ef054a0e9ed3e3e3", "screens/shell/init.luau": "0e12bb5577822cf5", "screens/shell/page.luau": "375949a60d75b00f", "screens/shell/view.luau": "b7657fb888747ebc" diff --git a/apps/zgx/ui/tests/side_chat_parity.test.luau b/apps/zgx/ui/tests/side_chat_parity.test.luau index c99b1194a9..29ea7ed15e 100644 --- a/apps/zgx/ui/tests/side_chat_parity.test.luau +++ b/apps/zgx/ui/tests/side_chat_parity.test.luau @@ -1,7 +1,7 @@ -- A side chat does what the chat page does, as far as the two can: what `@`, -- `/` and `$` offer, ⌘F and ⌘/, Escape and what sends, its Fast and plan mode, -- Retry, a passage quoted, its device gone. And its tab reads as a tab on the --- top bar: its project's tile, its live name, what it's at, every inset even. +-- top bar: its live name, what it's at, every inset even; its harness mark. -- On the page in ui/lanes_fixture.luau. local BOX = ".side-chat-tab >> role:textbox" @@ -32,22 +32,43 @@ end -- Its tab ------------------------------------------------------------------ -test("a side chat's tab shows its project's tile, not the side chat's glyph", function() +test("a side chat's tab shows its harness mark and follows a different agent picked", function() local app = open() - -- (Its project's, "atlas": its first letter, on its hue.) - expect(app:tree("#panel-tab-tab1")).to_contain('"A"') + expect(app:has("#panel-tab-tab1 >> role:img")).to_be(true) + expect(app:tree("#panel-tab-tab1")).never.to_contain('"A"') app:command("side_no_project") app:frames(10) - expect(app:tree("#panel-tab-tab1")).never.to_contain('"A"') + expect(app:has("#panel-tab-tab1 >> role:img")).to_be(true) + + -- The existing chat runs Codex. A new pick is reflected in the tab + -- before sending, including a registry agent whose icon arrives later. + local catalog = table.clone(app:state("chat.catalog")) + catalog.harnesses = table.clone(catalog.harnesses) + catalog.models = table.clone(catalog.models) + table.insert(catalog.harnesses, { id = "acp.factory-droid", label = "Factory Droid", mark = "acp.factory-droid" }) + table.insert(catalog.models, { value = "acp.factory-droid/auto", label = "Auto", harness = "acp.factory-droid" }) + app:set_state("chat.catalog", catalog) + app:set_state("chat_lane_model_side-a", "acp.factory-droid/auto") + app:frames(10) + expect(app:has("#panel-tab-tab1 >> .registry-mark-glyph")).to_be(true) + app:command("side_on_registry") + app:frames(10) + expect(app:has("#panel-tab-tab1 >> .registry-mark")).to_be(true) + expect(app:has("#panel-tab-tab1 >> .registry-mark-glyph")).to_be(false) + app:set_state("chat_lane_model_side-a", "codex/gpt-6.1") + app:frames(10) + expect(app:has("#panel-tab-tab1 >> .registry-mark")).to_be(false) + expect(app:has("#panel-tab-tab1 >> role:img")).to_be(true) end) -test("a new side chat's tile is its parent's project until it's moved", function() +test("a new side chat's tile starts with its parent's harness mark", function() local app = mount("lanes_fixture.luau") app:resize(1200, 900) app:frames(30) app:click('#session-lanes >> role:button "New side chat"') app:frames(30) - expect(app:tree("#panel-tab-tab1")).to_contain('"A"') + expect(app:has("#panel-tab-tab1 >> role:img")).to_be(true) + expect(app:tree("#panel-tab-tab1")).never.to_contain('"A"') end) test("a side chat's tab follows its chat's name", function()