Skip to content

Commit 18d134d

Browse files
author
Carl
committed
fix(search): keep archived sessions discoverable
Signed-off-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz>
1 parent 1056047 commit 18d134d

4 files changed

Lines changed: 95 additions & 60 deletions

File tree

‎docs/channels.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,10 @@ messages, membership and open Settings, replacing Archive with Unarchive after a
428428
fresh permission read. The conversation stays selected after reload; archived
429429
write restrictions still apply. When refreshed Settings actions remount, focus
430430
returns to its persistent Settings-tab close control instead of an unrelated sidebar row;
431-
joined archived channels remain available by name in search, labeled **Archived
432-
channel**, but stay out of the sidebar and Recent activity. Open the search result
433-
and Settings to restore it. This uses the existing membership discovery and exact
431+
joined archived channels, including session conversations, remain available by name
432+
in search, labeled **Archived channel**, but stay out of the sidebar and Recent
433+
activity. After navigating away, open the search result and Settings to restore it.
434+
This uses the existing membership discovery and exact
434435
navigation, not a new archived-channel directory.
435436

436437
Search also finds active public channels the viewer has not joined, by name,

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

Lines changed: 63 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -694,63 +694,73 @@ it("does not announce conversation enrichment over retained search choices", ()
694694
}
695695
});
696696

697-
it("finds joined archived channels by name without putting them in Recent activity", async () => {
698-
const relay = keypair(),
699-
viewer = keypair();
700-
const wire = scriptedTransport(viewer.pubkey, relay.pubkey);
701-
const discovery = [
702-
signed(relay, {
703-
kind: 39000,
704-
created_at: 1700000000,
705-
content: "",
706-
tags: [
707-
["d", "archive"],
708-
["t", "stream"],
709-
["name", "Past project"],
710-
["archived", "true"],
711-
],
712-
}),
713-
roster(relay, "archive", [viewer.pubkey]),
714-
metadata(relay, "active", "Current project"),
715-
roster(relay, "active", [viewer.pubkey]),
716-
];
717-
const owner = createRelaySession({
718-
...wire.transport,
719-
async query(filters) {
720-
return discovery.filter((event) =>
721-
filters.some((filter) => filter.kinds?.includes(event.kind)),
722-
);
723-
},
724-
});
725-
const open = vi.fn();
726-
const props = {
727-
session: owner.session,
728-
onQueryChange: () => {},
729-
input: createRef<HTMLInputElement>(),
730-
pages: [],
731-
openConversation: open,
732-
};
733-
try {
734-
const mounted = render(<SearchResults {...props} query="" />);
735-
await screen.findByRole("option", { name: /Current project/ });
736-
expect(screen.queryByRole("option", { name: /Past project/ })).toBeNull();
737-
mounted.rerender(<SearchResults {...props} query="Past" />);
738-
fireEvent.click(
739-
await screen.findByRole("option", {
740-
name: /Past project/,
697+
it.each(["stream", "forum", "session"] as const)(
698+
"finds joined archived %s channels by name without putting them in Recent activity",
699+
async (channelType) => {
700+
const relay = keypair(),
701+
viewer = keypair();
702+
const wire = scriptedTransport(viewer.pubkey, relay.pubkey);
703+
const discovery = [
704+
signed(relay, {
705+
kind: 39000,
706+
created_at: 1700000000,
707+
content: "",
708+
tags: [
709+
["d", "archive"],
710+
["t", channelType === "session" ? "stream" : channelType],
711+
...(channelType === "session"
712+
? [["private"], ["about", "Buzz session (buzz.sessions/v1)"]]
713+
: []),
714+
["name", "Past project"],
715+
["archived", "true"],
716+
],
741717
}),
742-
);
743-
expect(screen.getByText("Archived channel")).toBeTruthy();
744-
expect(open).toHaveBeenCalledExactlyOnceWith("archive");
745-
} finally {
746-
cleanup();
747-
owner.dispose();
748-
}
749-
});
718+
roster(relay, "archive", [viewer.pubkey]),
719+
metadata(relay, "active", "Current project"),
720+
roster(relay, "active", [viewer.pubkey]),
721+
];
722+
const owner = createRelaySession({
723+
...wire.transport,
724+
async query(filters) {
725+
return discovery.filter((event) =>
726+
filters.some((filter) => filter.kinds?.includes(event.kind)),
727+
);
728+
},
729+
});
730+
const open = vi.fn();
731+
const props = {
732+
session: owner.session,
733+
onQueryChange: () => {},
734+
input: createRef<HTMLInputElement>(),
735+
pages: [],
736+
openConversation: open,
737+
};
738+
try {
739+
const mounted = render(<SearchResults {...props} query="" />);
740+
await screen.findByRole("option", { name: /Current project/ });
741+
expect(owner.session.channels.get?.("archive")?.channelType).toBe(
742+
channelType,
743+
);
744+
expect(screen.queryByRole("option", { name: /Past project/ })).toBeNull();
745+
mounted.rerender(<SearchResults {...props} query="Past" />);
746+
fireEvent.click(
747+
await screen.findByRole("option", {
748+
name: /Past project/,
749+
}),
750+
);
751+
expect(screen.getByText("Archived channel")).toBeTruthy();
752+
expect(open).toHaveBeenCalledExactlyOnceWith("archive");
753+
} finally {
754+
cleanup();
755+
owner.dispose();
756+
}
757+
},
758+
);
750759

751760
it.each([
752761
{ channelType: "stream", readOnly: true },
753-
{ channelType: "session" },
762+
{ channelType: "forum", readOnly: true },
763+
{ channelType: "session", readOnly: true },
754764
{ channelType: "dm" },
755765
] as const)(
756766
"does not surface archived nonmember or non-channel destinations: %j",

‎src/app/shell/SearchResults.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ export function SearchResults({
9191
(!channel.archived ||
9292
(!channel.readOnly &&
9393
(channel.channelType === "stream" ||
94-
channel.channelType === "forum"))) &&
94+
channel.channelType === "forum" ||
95+
channel.channelType === "session"))) &&
9596
(!channel.hidden || channel.channelType === "dm") &&
9697
(!scopedChannelId || channel.id === scopedChannelId),
9798
),

‎tests/browser/channel-lifecycle.spec.mjs‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,12 @@ test("pending modal Escape in narrow navigation preserves visible recovery after
461461
expect(app.report.unexpected).toEqual([]);
462462
});
463463

464-
// Browser-only: the legacy header branch must keep a working details entry after
465-
// Archive removes its row, with real menu/dialog focus and retained transcript.
464+
// Browser-only: recover an archived session after leaving its URL via the real
465+
// search -> header -> Settings route. The empty session has no message fallback.
466466
test.describe("legacy sessions", () => {
467467
test.use({ sessionChannels: ["11111111-1111-4111-8111-111111111111"] });
468468

469-
test("sidebar and header manage a legacy session without converting it", async ({
469+
test("sidebar and header manage a session and recover it through name search", async ({
470470
page,
471471
app,
472472
}) => {
@@ -523,6 +523,29 @@ test.describe("legacy sessions", () => {
523523
await page.reload();
524524
await expect(composer).toBeDisabled();
525525
await expect(page).toHaveURL(url);
526+
await page
527+
.getByRole("navigation", { name: "Subscribed channels" })
528+
.getByRole("button", { name: "Alpha", exact: true })
529+
.click();
530+
await expect(
531+
page.getByRole("textbox", { name: "Message #Alpha", exact: true }),
532+
).toBeVisible();
533+
await expect(page).not.toHaveURL(url);
534+
await page
535+
.getByRole("button", { name: "Search Buzz", exact: true })
536+
.click();
537+
const search = page.getByRole("dialog", { name: "Search Buzz" });
538+
await search
539+
.getByRole("combobox", { name: "Search Buzz" })
540+
.fill("Lifecycle channel");
541+
const result = search
542+
.getByRole("group", { name: "Channels" })
543+
.getByRole("option", { name: /Lifecycle channel/ });
544+
await expect(result).toContainText("Archived channel");
545+
await result.click();
546+
await expect(search).toHaveCount(0);
547+
await expect(page).toHaveURL(url);
548+
await expect(composer).toBeDisabled();
526549
await openChannelDetails(page);
527550
await expect(
528551
page.getByRole("button", { name: "View members" }),

0 commit comments

Comments
 (0)