Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 48 additions & 65 deletions apps/zgx/ui/screens/chat/lane_tab.luau
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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")

Expand Down Expand Up @@ -97,75 +97,58 @@ function M.icon(_tab: any): string
return "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<string?>): 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,
project = function(): string?
local p = project_of(tab, picked)
return if p then p.id 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
Expand Down
2 changes: 1 addition & 1 deletion apps/zgx/ui/screens/panel/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,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)
Expand Down
4 changes: 2 additions & 2 deletions apps/zgx/ui/templates/zeron-v2/.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"ds/sidebar.luau": "6d5d8113d5768620",
"ds/tokens.luau": "0575770327f5e5f2",
"screens/chat/composer.luau": "a451ec6aaa53a23a",
"screens/chat/lane_tab.luau": "d9bfbad1abf57f73",
"screens/panel/init.luau": "a0df0db6e977845f",
"screens/chat/lane_tab.luau": "7d1819d6ea01cb9f",
"screens/panel/init.luau": "620a8cc06d30c897",
"screens/shell/init.luau": "302aa5fc3350cd0a",
"screens/shell/page.luau": "c60a2e8010d8068e",
"screens/shell/view.luau": "95dec891b31add1d"
Expand Down
35 changes: 28 additions & 7 deletions apps/zgx/ui/tests/side_chat_parity.test.luau
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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()
Expand Down
Loading