Skip to content

Commit ff11f26

Browse files
matt2eclaude
andauthored
fix(desktop): navigate to channel from inbox thread header (#1847)
Signed-off-by: Matt Toohey <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
1 parent b1d323c commit ff11f26

3 files changed

Lines changed: 85 additions & 12 deletions

File tree

‎desktop/src/features/home/ui/HomeView.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,10 +788,11 @@ export function HomeView({
788788
setIsDeletingMessage(false);
789789
});
790790
}}
791-
onOpenChannel={(channelId) => {
791+
onManageChannel={(channelId) => {
792792
handleCloseProfilePanel();
793793
setManagedChannelId(channelId);
794794
}}
795+
onOpenContext={onOpenContext}
795796
onSendReply={async ({
796797
content,
797798
mediaTags,

‎desktop/src/features/home/ui/InboxDetailPane.tsx‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ type InboxDetailPaneProps = {
7777
latchedDefaultParentId?: string | null;
7878
onBack?: () => void;
7979
onDelete: () => void;
80-
onOpenChannel: (channelId: string) => void;
80+
onManageChannel: (channelId: string) => void;
81+
onOpenContext: (
82+
channelId: string,
83+
messageId: string,
84+
threadRootId?: string | null,
85+
) => void;
8186
onSendReply: (input: {
8287
content: string;
8388
mediaTags?: string[][];
@@ -111,7 +116,8 @@ export function InboxDetailPane({
111116
latchedDefaultParentId = null,
112117
onBack,
113118
onDelete,
114-
onOpenChannel,
119+
onManageChannel,
120+
onOpenContext,
115121
onSendReply,
116122
onToggleReaction,
117123
}: InboxDetailPaneProps) {
@@ -318,6 +324,7 @@ export function InboxDetailPane({
318324
const contextLabel = channelContextName ?? formatInboxTypeLabel(item);
319325
const hasChannelContext = Boolean(channelContextName);
320326
const contextChannelId = item.item.channelId;
327+
const contextThreadRootId = getThreadReference(item.item.tags).rootId;
321328

322329
const handleSelectReplyTarget = (message: InboxDisplayMessage) => {
323330
setReplyTargetId((currentReplyTargetId) =>
@@ -358,7 +365,13 @@ export function InboxDetailPane({
358365
{canOpenChannel && contextChannelId ? (
359366
<button
360367
className="flex min-w-0 items-center gap-[4px] text-left text-sm font-semibold leading-5 tracking-tight text-foreground hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
361-
onClick={() => onOpenChannel(contextChannelId)}
368+
onClick={() =>
369+
onOpenContext(
370+
contextChannelId,
371+
item.id,
372+
contextThreadRootId,
373+
)
374+
}
362375
title={item.fullTimestampLabel}
363376
type="button"
364377
>
@@ -394,7 +407,7 @@ export function InboxDetailPane({
394407
currentPubkey={currentPubkey}
395408
onManageChannel={() => {
396409
if (contextChannelId) {
397-
onOpenChannel(contextChannelId);
410+
onManageChannel(contextChannelId);
398411
}
399412
}}
400413
onToggleMembers={() =>

‎desktop/tests/e2e/channels.spec.ts‎

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,9 +2389,11 @@ test("manage channel keeps canvas near the top of the sheet", async ({
23892389
expect(canvasBox?.y).toBeLessThan(nameBox?.y);
23902390
});
23912391

2392-
test("home inbox channel label opens management without leaving home", async ({
2393-
page,
2394-
}) => {
2392+
async function seedHomeInboxMention(
2393+
page: import("@playwright/test").Page,
2394+
itemId: string,
2395+
tags?: string[][],
2396+
) {
23952397
await page.goto("/");
23962398
await expect(page.getByTestId("home-inbox-list")).toBeVisible();
23972399
await page.waitForFunction(
@@ -2401,22 +2403,29 @@ test("home inbox channel label opens management without leaving home", async ({
24012403
);
24022404

24032405
await page.evaluate(
2404-
({ channelId, createdAt, currentPubkey, senderPubkey }) => {
2406+
({
2407+
channelId,
2408+
createdAt,
2409+
currentPubkey,
2410+
itemId: id,
2411+
senderPubkey,
2412+
tags: seededTags,
2413+
}) => {
24052414
const pushFeedItem = (window as MockFeedWindow)
24062415
.__BUZZ_E2E_PUSH_MOCK_FEED_ITEM__;
24072416
if (!pushFeedItem) {
24082417
throw new Error("Mock feed injection helper is not installed.");
24092418
}
24102419

24112420
pushFeedItem({
2412-
id: "mock-feed-home-channel-panel",
2421+
id,
24132422
kind: 9,
24142423
pubkey: senderPubkey,
24152424
content: "Please review the home panel routing.",
24162425
created_at: createdAt,
24172426
channel_id: channelId,
24182427
channel_name: "general",
2419-
tags: [
2428+
tags: seededTags ?? [
24202429
["e", channelId],
24212430
["p", currentPubkey],
24222431
],
@@ -2427,18 +2436,68 @@ test("home inbox channel label opens management without leaving home", async ({
24272436
channelId: GENERAL_CHANNEL_ID,
24282437
createdAt: Math.floor(Date.now() / 1000),
24292438
currentPubkey: TEST_IDENTITIES.tyler.pubkey,
2439+
itemId,
24302440
senderPubkey: TEST_IDENTITIES.alice.pubkey,
2441+
tags,
24312442
},
24322443
);
24332444

2445+
await page.getByTestId(`home-inbox-item-${itemId}`).click();
2446+
}
2447+
2448+
test("home inbox channel label navigates to the channel message", async ({
2449+
page,
2450+
}) => {
2451+
await seedHomeInboxMention(page, "mock-feed-home-channel-navigate");
2452+
24342453
await page
2435-
.getByTestId("home-inbox-item-mock-feed-home-channel-panel")
2454+
.getByTestId("home-inbox-detail")
2455+
.getByRole("button", { exact: true, name: "general" })
24362456
.click();
2457+
2458+
await expect(page).toHaveURL(
2459+
new RegExp(`#/channels/${GENERAL_CHANNEL_ID}\\?`),
2460+
);
2461+
await expect(page).toHaveURL(/messageId=mock-feed-home-channel-navigate/);
2462+
await expect(page).not.toHaveURL(/threadRootId=/);
2463+
await expect(page.getByTestId("message-timeline")).toBeVisible();
2464+
await expect(page.getByTestId("home-inbox-list")).toHaveCount(0);
2465+
});
2466+
2467+
test("home inbox thread reply mention carries threadRootId to the channel", async ({
2468+
page,
2469+
}) => {
2470+
const rootEventId = "mock-feed-home-thread-root";
2471+
await seedHomeInboxMention(page, "mock-feed-home-thread-navigate", [
2472+
["e", rootEventId, "", "root"],
2473+
["e", "mock-feed-home-thread-parent", "", "reply"],
2474+
["p", TEST_IDENTITIES.tyler.pubkey],
2475+
]);
2476+
24372477
await page
24382478
.getByTestId("home-inbox-detail")
24392479
.getByRole("button", { exact: true, name: "general" })
24402480
.click();
24412481

2482+
await expect(page).toHaveURL(
2483+
new RegExp(`#/channels/${GENERAL_CHANNEL_ID}\\?`),
2484+
);
2485+
await expect(page).toHaveURL(/messageId=mock-feed-home-thread-navigate/);
2486+
await expect(page).toHaveURL(new RegExp(`threadRootId=${rootEventId}`));
2487+
await expect(page.getByTestId("message-timeline")).toBeVisible();
2488+
await expect(page.getByTestId("home-inbox-list")).toHaveCount(0);
2489+
});
2490+
2491+
test("home inbox manage affordance opens management without leaving home", async ({
2492+
page,
2493+
}) => {
2494+
await seedHomeInboxMention(page, "mock-feed-home-channel-panel");
2495+
2496+
await page
2497+
.getByTestId("home-inbox-detail")
2498+
.getByTestId("channel-management-trigger")
2499+
.click();
2500+
24422501
await expect(page.getByTestId("channel-management-sheet")).toBeVisible();
24432502
await expect(page.getByTestId("channel-management-name-row")).toContainText(
24442503
"general",

0 commit comments

Comments
 (0)