Skip to content

Commit 4a87b5c

Browse files
dr0uleaucodex
andauthored
Expose ordinary chats without workspace headings (#3530)
## Why A Solo region plugin can include ordinary chats with `ui.Chats`, but including chats from named workspaces also adds their workspace headings and frames. A source that groups its own content by status or time cannot show those chats as a plain list without losing access to filed chats. ## What Add optional `ui.ChatList` for sources that compose workspaces. It shows filed and unfiled ordinary chats without workspace chrome. Menus, rename editors, pending saves, saved assignments, workspace order, and per-workspace pagination stay with the host. ## How Reuse the existing row portals. Focus recovery uses the row’s current layout, then surviving list rows and the region heading. The list ignores saved collapse state for display and preserves that state when the source returns to workspaces. Existing `ui.Chats` behavior is unchanged. Plugins can detect `ui.ChatList` and use `ui.Chats({ all: true })` on older hosts. ## Risk The new API is inert unless a source uses it. Row focus and neighbor selection now account for the plain-list placement. The feature adds no relay reads or persistence writes. ## Testing The final head was checked in the actual shell with simulated data, using headless Chromium on macOS. Chromium checks cover filed and unfiled chats, Show more/Show less, row menus, rename/save, row identity across layouts, saved collapse state, and the older-host fallback. Visual inspection covers light and dark themes, narrow and wide widths, and 200% interface size. The shipping review ran. The focus regression fails on the prior implementation and passes after the repair. The author approved the shown preview with “LGTM”. No separate hands-on human run was reported. The final browser check also covers keyboard row menus and Escape focus recovery. It reported no page errors. Native and real-relay validation are outside this presentation-only change. Browser cases added/removed: none; mounted component coverage owns the membership, pagination, and editor lifecycle contracts. | Existing `ui.Chats({ all: true })` | Optional `ui.ChatList` | | --- | --- | | ![Existing workspace headings and framed ordinary chats](https://github.com/user-attachments/assets/e5020191-fbba-47ea-b5bd-00577aa717f7) | ![Plain host-owned ordinary chats](https://github.com/user-attachments/assets/68f94022-f34d-4b01-8017-867c09d2a49d) | buzz-review-completed Generated with Codex --------- Signed-off-by: Daniel Rouleau <[email protected]> Co-authored-by: Codex <[email protected]>
1 parent 5507827 commit 4a87b5c

9 files changed

Lines changed: 237 additions & 27 deletions

File tree

‎docs/buzz-help.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ and are asked to sign in again in Buzz.
481481
Plugins can also group tasks under joined channels. On supported hosts, each
482482
channel group keeps the native channel actions and details. New task appears
483483
only when the channel permits starting a chat.
484+
Plugins can show ordinary chats in a plain list without workspace headings.
485+
Their saved workspace assignments stay in place.
484486
With Nexus enabled, each workspace also contains its tasks and can have a Lead
485487
task. Nexus saves and chooses Leads, so they exist only while Nexus is enabled.
486488
Creating a workspace selects it so you can start a conversation with its Lead.

‎docs/solo-regions.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,23 @@ audience. Keep the previous presentation as a fallback when the component is abs
157157

158158
## Personal workspaces
159159

160+
A source with `composeWorkspaces: true` receives optional `ui.Workspace`,
161+
`ui.Chats`, and `ui.ChatList` components. `ui.Chats` shows unfiled ordinary
162+
chats. Passing `all` includes named workspaces with their headers and frames.
163+
`ui.ChatList` includes the same ordinary chats without workspace headers or
164+
frames, even when their saved workspace is collapsed. It keeps workspace order
165+
and each workspace's Show more / Show less controls. It does not change saved
166+
assignments or collapse preferences. Region-owned chats remain with the source.
167+
168+
The host retains row identity, menus, rename editors, and pending saves when a
169+
source switches between these presentations. Render each ordinary inventory
170+
once: use `ui.ChatList` alone, `ui.Chats` with `all`, or `ui.Workspace` for each
171+
named workspace plus `ui.Chats` for unfiled chats.
172+
173+
Feature-detect `ui.ChatList` before use. On older hosts, fall back to `ui.Chats`
174+
with `all: true` to keep named-workspace chats reachable. That fallback retains
175+
workspace chrome. Existing `ui.Chats` behavior is unchanged.
176+
160177
`ctx.soloNavigation.workspaces` exposes the bound user's Solo workspace catalog.
161178
Pass the current region binding to `snapshot`, `subscribe`, `refresh`, and
162179
`create({id, name})`. The snapshot contains IDs, names, status, creation

‎src/app/shell/PrimarySidebar.test.tsx‎

Lines changed: 91 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,73 @@ it.each(["New"])(
13741374
},
13751375
);
13761376

1377-
it("keeps an ordinary chat editor and pending save through task-source recovery", async () => {
1377+
it.each(["neighbor", "heading", "moved"])(
1378+
"recovers plain-list focus after the last chat in a workspace disappears (%s)",
1379+
async (destination) => {
1380+
const h = createSoloRegionFixture(viewer);
1381+
const preferences = createSidebarPreferencesStore({
1382+
available: true,
1383+
groupsOnly: true,
1384+
read: async () => ({
1385+
sections: [{ id: "work", name: "Work", order: 0 }],
1386+
assignments: { chat: "work" },
1387+
starred: [],
1388+
muted: [],
1389+
}),
1390+
});
1391+
await preferences.queries.ensure();
1392+
Object.assign(h.session, { soloPreferences: preferences.queries });
1393+
h.roster([
1394+
{ id: "chat", name: "Chat", channelType: "solo", creator: viewer },
1395+
{ id: "other", name: "Other", channelType: "solo", creator: viewer },
1396+
]);
1397+
await h.register({
1398+
composeWorkspaces: true,
1399+
component: ({ ui }) => (ui.ChatList ? <ui.ChatList /> : null),
1400+
});
1401+
const view = render(
1402+
<ToastProvider>
1403+
<PrimarySidebar
1404+
relay={h.relay}
1405+
navigator={h.navigator}
1406+
target={conversationTarget(h.scope, "chat")}
1407+
>
1408+
<button type="button">Elsewhere</button>
1409+
</PrimarySidebar>
1410+
</ToastProvider>,
1411+
);
1412+
try {
1413+
const heading = screen.getByLabelText("Work", { selector: "summary" });
1414+
const elsewhere = screen.getByRole("button", { name: "Elsewhere" });
1415+
const chat = screen.getByRole("button", { name: "Chat" });
1416+
chat.focus();
1417+
await act(async () => {
1418+
h.roster(
1419+
destination === "heading"
1420+
? []
1421+
: h.session.channels
1422+
.list()
1423+
.channels.filter(({ id }) => id !== "chat"),
1424+
);
1425+
if (destination === "moved") elsewhere.focus();
1426+
});
1427+
await waitFor(() => expect(chat).not.toBeInTheDocument());
1428+
expect(
1429+
destination === "neighbor"
1430+
? screen.getByRole("button", { name: "Other" })
1431+
: destination === "heading"
1432+
? heading
1433+
: elsewhere,
1434+
).toHaveFocus();
1435+
} finally {
1436+
view.unmount();
1437+
preferences.dispose();
1438+
await h.dispose();
1439+
}
1440+
},
1441+
);
1442+
1443+
it("keeps an ordinary chat editor and pending save through layout changes and task-source recovery", async () => {
13781444
const h = createSoloRegionFixture(viewer);
13791445
const preferences = createSidebarPreferencesStore({
13801446
available: true,
@@ -1426,11 +1492,13 @@ it("keeps an ordinary chat editor and pending save through task-source recovery"
14261492
h.roster([...h.session.channels.list().channels]);
14271493
const source = await h.register({
14281494
composeWorkspaces: true,
1429-
component: ({ ui }) => {
1495+
component: ({ ui, snapshot }) => {
14301496
const Workspace = ui.Workspace;
14311497
const Chats = ui.Chats;
1432-
if (!Workspace || !Chats)
1498+
const ChatList = ui.ChatList;
1499+
if (!Workspace || !Chats || !ChatList)
14331500
throw new Error("Missing workspace composition");
1501+
if (snapshot.model === "list") return <ChatList />;
14341502
return (
14351503
<>
14361504
<Workspace id="work">{null}</Workspace>
@@ -1451,24 +1519,38 @@ it("keeps an ordinary chat editor and pending save through task-source recovery"
14511519
</ToastProvider>,
14521520
);
14531521
const user = userEvent.setup();
1454-
const change = (status: "loading" | "ready", revision: number) =>
1455-
act(() => source.update({ status, binding: source.binding(), revision }));
1522+
const change = (
1523+
status: "loading" | "ready",
1524+
revision: number,
1525+
model?: string,
1526+
) =>
1527+
act(() =>
1528+
source.update({
1529+
status,
1530+
binding: source.binding(),
1531+
revision,
1532+
...(model ? { model } : {}),
1533+
}),
1534+
);
14561535
try {
14571536
await user.dblClick(await screen.findByRole("button", { name: /^Chat$/ }));
14581537
const input = await screen.findByRole("textbox", { name: "Chat name" });
14591538
await waitFor(() => expect(input).toHaveFocus());
14601539
await user.keyboard("Keep this name");
1461-
change("loading", 2);
1540+
change("ready", 2, "list");
1541+
expect(screen.queryByRole("button", { name: "Work" })).toBeNull();
1542+
expect(screen.getByRole("textbox", { name: "Chat name" })).toBe(input);
1543+
change("loading", 3);
14621544
expect(screen.getByRole("textbox", { name: "Chat name" })).toBe(input);
14631545
expect(input).toHaveValue("Keep this name");
1464-
change("ready", 3);
1546+
change("ready", 4, "list");
14651547
expect(screen.getByRole("textbox", { name: "Chat name" })).toBe(input);
14661548
await user.keyboard("{Enter}");
14671549
await waitFor(() => expect(save).toHaveBeenCalledOnce());
1468-
change("loading", 4);
1550+
change("loading", 5);
14691551
expect(savingSignal?.aborted).toBe(false);
14701552
expect(screen.getByRole("textbox", { name: "Chat name" })).toBe(input);
1471-
change("ready", 5);
1553+
change("ready", 6, "list");
14721554
expect(savingSignal?.aborted).toBe(false);
14731555
await act(async () => {
14741556
release();

‎src/bundled/channels/SoloWorkspaces.test.tsx‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
WorkspaceCompositionContext,
1515
RegionWorkspace,
1616
RegionChats,
17+
RegionChatList,
1718
type ComposeWorkspaces,
1819
} from "../../features/channel-navigation/WorkspaceComposition";
1920
import userEvent from "@testing-library/user-event";
@@ -451,6 +452,82 @@ it("shares a workspace frame while keeping selection, disclosure and chat creati
451452
}
452453
});
453454

455+
it("lists filed and unfiled chats without workspace chrome while preserving filing and pagination", async () => {
456+
const h = fixture();
457+
const store = h.store();
458+
const filed = Array.from({ length: SOLO_CHAT_CAP + 1 }, (_, index) => ({
459+
id: index === 0 ? "chat" : `filed-${index}`,
460+
title: `Filed chat ${index}`,
461+
}));
462+
await store.queries.ensure();
463+
for (const item of filed) await store.queries.assign(item.id, "work");
464+
const assignments = { ...h.saved().assignments };
465+
h.write.mockClear();
466+
function View() {
467+
const [list, setList] = useState(false);
468+
return (
469+
<>
470+
<button type="button" onClick={() => setList(!list)}>
471+
Switch layout
472+
</button>
473+
{h.view(
474+
store.queries,
475+
"chat-list",
476+
undefined,
477+
[...filed, { id: "other", title: "Unfiled chat" }],
478+
(parts) => (
479+
<WorkspaceCompositionContext value={parts}>
480+
{list ? <RegionChatList /> : <RegionChats all />}
481+
</WorkspaceCompositionContext>
482+
),
483+
)}
484+
</>
485+
);
486+
}
487+
render(<View />);
488+
const user = userEvent.setup();
489+
try {
490+
await user.click(await screen.findByRole("button", { name: "Work" }));
491+
expect(screen.queryByRole("button", { name: "Filed chat 0" })).toBeNull();
492+
await user.click(screen.getByRole("button", { name: "Switch layout" }));
493+
expect(screen.queryByRole("button", { name: "Work" })).toBeNull();
494+
expect(screen.queryByRole("button", { name: "Chats" })).toBeNull();
495+
expect(screen.getByRole("button", { name: "Unfiled chat" })).toBeVisible();
496+
expect(
497+
screen.getAllByRole("button", { name: /^Filed chat \d+$/ }),
498+
).toHaveLength(SOLO_CHAT_CAP);
499+
await user.click(
500+
screen.getByRole("button", { name: "Show more chats in Work" }),
501+
);
502+
expect(
503+
screen.getAllByRole("button", { name: /^Filed chat \d+$/ }),
504+
).toHaveLength(filed.length);
505+
await user.click(
506+
screen.getByRole("button", { name: "Show fewer chats in Work" }),
507+
);
508+
expect(
509+
screen.getAllByRole("button", { name: /^Filed chat \d+$/ }),
510+
).toHaveLength(SOLO_CHAT_CAP);
511+
await user.click(
512+
screen.getByRole("button", { name: "Actions for Filed chat 0" }),
513+
);
514+
expect(
515+
await screen.findByRole("menuitem", { name: "Move to" }),
516+
).toBeVisible();
517+
await user.keyboard("{Escape}");
518+
await user.click(screen.getByRole("button", { name: "Switch layout" }));
519+
expect(screen.getByRole("button", { name: "Work" })).toHaveAttribute(
520+
"aria-expanded",
521+
"false",
522+
);
523+
expect(screen.queryByRole("button", { name: "Filed chat 0" })).toBeNull();
524+
expect(h.saved().assignments).toEqual(assignments);
525+
expect(h.write).not.toHaveBeenCalled();
526+
} finally {
527+
store.dispose();
528+
}
529+
});
530+
454531
it("marks a chat read from its row menu and reports a failed save", async () => {
455532
const h = fixture();
456533
const store = h.store();

‎src/bundled/channels/SoloWorkspaces.tsx‎

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ export function SoloWorkspaces({
216216
)?.id ?? "";
217217
// Resolve against current visibility when focus is restored, including when
218218
// collapse was requested after the asynchronous save began.
219-
const target = collapsed.includes(project)
220-
? `project-${project}`
221-
: rowFocus;
219+
const target =
220+
collapsed.includes(project) && !rowHosts.current.get(project)?.unframed
221+
? `project-${project}`
222+
: rowFocus;
222223
document
223224
.querySelector<HTMLElement>(
224225
`[data-solo-menu-id="${target}"]:not([inert] *) button`,
@@ -422,16 +423,18 @@ export function SoloWorkspaces({
422423
const soloNeighborsRef = handoff?.soloNeighbors;
423424
useLayoutEffect(() => {
424425
if (!soloNeighborsRef) return;
425-
const shown = visible.map((project) => ({
426-
rows: project.rows,
427-
shown: collapsed.includes(project.id)
428-
? []
429-
: project.listed.map((item) => item.id),
430-
}));
431426
const neighbors = (id: string) =>
432-
soloNeighbors(shown, id).filter(
433-
(neighbor) => !pluginHiddenRows.current.has(neighbor),
434-
);
427+
soloNeighbors(
428+
visible.map((project) => ({
429+
rows: project.rows,
430+
shown:
431+
collapsed.includes(project.id) &&
432+
!rowHosts.current.get(project.id)?.unframed
433+
? []
434+
: project.listed.map((item) => item.id),
435+
})),
436+
id,
437+
).filter((neighbor) => !pluginHiddenRows.current.has(neighbor));
435438
soloNeighborsRef.current = neighbors;
436439
return () => {
437440
if (soloNeighborsRef.current === neighbors)
@@ -754,6 +757,9 @@ export function SoloWorkspaces({
754757
header,
755758
panel,
756759
ordinary,
760+
chatList: (
761+
<WorkspaceRows key={project.id} host={rowsHost} unframed={project.id} />
762+
),
757763
rows: compose ? createPortal(rows, rowsHost.element, project.id) : null,
758764
};
759765
});
@@ -807,6 +813,7 @@ export function SoloWorkspaces({
807813
{compose
808814
? compose({
809815
chats: entries.find((entry) => !entry.id)?.ordinary,
816+
chatList: entries.map((entry) => entry.chatList),
810817
workspaces: entries,
811818
ordinary: entries.map((entry) => entry.ordinary),
812819
})
@@ -931,22 +938,31 @@ export function SoloWorkspaces({
931938
type WorkspaceRowsHost = {
932939
element: HTMLDivElement;
933940
focus?: HTMLElement | undefined;
941+
unframed?: boolean | undefined;
934942
};
935-
function WorkspaceRows({ host }: { host: WorkspaceRowsHost }) {
943+
function WorkspaceRows({
944+
host,
945+
unframed,
946+
}: {
947+
host: WorkspaceRowsHost;
948+
unframed?: string;
949+
}) {
936950
const slot = useRef<HTMLDivElement>(null);
937951
useLayoutEffect(() => {
938952
const parent = slot.current;
953+
host.unframed = unframed !== undefined;
939954
parent?.appendChild(host.element);
940955
if (host.focus?.isConnected && document.activeElement === document.body)
941956
host.focus.focus({ preventScroll: true });
942957
host.focus = undefined;
943958
return () => {
959+
host.unframed = false;
944960
if (host.element.contains(document.activeElement))
945961
host.focus = document.activeElement as HTMLElement;
946962
if (host.element.parentElement === parent) host.element.remove();
947963
};
948-
}, [host]);
949-
return <div ref={slot} />;
964+
}, [host, unframed]);
965+
return <div ref={slot} data-solo-project={unframed} />;
950966
}
951967

952968
const DROP = "project:";

‎src/features/channel-navigation/SoloInventory.tsx‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,15 @@ function SoloConversationRow({
528528
const button = selectRef.current;
529529
if (!button || !present) return;
530530
const document = button.ownerDocument;
531-
const sidebar = button.closest("nav");
532-
const panel = button.closest<HTMLElement>("[data-solo-project]");
533531
return () => {
534532
if (document.activeElement !== button) return;
533+
// Row portals can attach or move after mount. Read their current layout.
534+
const sidebar = button.closest("nav");
535+
const panel = button.closest<HTMLElement>("[data-solo-project]");
536+
const inventory = button.closest("[data-solo-chat-list]") ?? panel;
537+
const region = button.closest("[data-sidebar-section]");
535538
const rows = [
536-
...(panel?.querySelectorAll<HTMLElement>(
539+
...(inventory?.querySelectorAll<HTMLElement>(
537540
"button[data-solo-channel-id]:not([inert] *)",
538541
) ?? []),
539542
];
@@ -562,6 +565,8 @@ function SoloConversationRow({
562565
sidebar.querySelector<HTMLElement>(
563566
`[data-solo-menu-id="project-${CSS.escape(panel?.dataset.soloProject ?? "")}"] button`,
564567
),
568+
region?.querySelector<HTMLElement>("summary"),
569+
sidebar.querySelector<HTMLElement>("[data-solo-heading]"),
565570
];
566571
for (const candidate of candidates) {
567572
if (!candidate?.isConnected || candidate.closest("[hidden], [inert]"))

‎src/features/channel-navigation/SoloRegions.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
WorkspaceCompositionContext,
55
RegionWorkspace,
66
RegionChats,
7+
RegionChatList,
78
type ComposeWorkspaces,
89
} from "./WorkspaceComposition";
910
import {
@@ -466,6 +467,7 @@ function RegionFrame({
466467
...destinationUi,
467468
Workspace: RegionWorkspace,
468469
Chats: RegionChats,
470+
ChatList: RegionChatList,
469471
}
470472
: destinationUi
471473
}

0 commit comments

Comments
 (0)