fix(desktop): refine thread panel reply layout

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Thomas Petersen
2026-05-09 15:17:34 -04:00
parent c6da3a72ab
commit 0230f2d438
3 changed files with 72 additions and 4 deletions

View File

@@ -1,7 +1,10 @@
import assert from "node:assert/strict";
import test from "node:test";
import { buildMainTimelineEntries } from "./threadPanel.ts";
import {
buildMainTimelineEntries,
buildThreadPanelData,
} from "./threadPanel.ts";
function message(overrides) {
return {
@@ -56,3 +59,66 @@ test("buildMainTimelineEntries includes broadcast replies", () => {
["root", "broadcast-reply"],
);
});
test("buildThreadPanelData keeps direct replies flat", () => {
const root = message({ id: "root", createdAt: 1 });
const reply = message({
id: "reply",
createdAt: 2,
parentId: "root",
rootId: "root",
depth: 1,
tags: [["e", "root", "", "reply"]],
});
const panel = buildThreadPanelData([root, reply], "root", null, new Set());
assert.deepEqual(
panel.visibleReplies.map((entry) => ({
id: entry.message.id,
depth: entry.message.depth,
})),
[{ id: "reply", depth: 0 }],
);
});
test("buildThreadPanelData indents expanded subthread replies", () => {
const root = message({ id: "root", createdAt: 1 });
const reply = message({
id: "reply",
createdAt: 2,
parentId: "root",
rootId: "root",
depth: 1,
tags: [["e", "root", "", "reply"]],
});
const nestedReply = message({
id: "nested-reply",
createdAt: 3,
parentId: "reply",
rootId: "root",
depth: 2,
tags: [
["e", "root", "", "root"],
["e", "reply", "", "reply"],
],
});
const panel = buildThreadPanelData(
[root, reply, nestedReply],
"root",
null,
new Set(["reply"]),
);
assert.deepEqual(
panel.visibleReplies.map((entry) => ({
id: entry.message.id,
depth: entry.message.depth,
})),
[
{ id: "reply", depth: 0 },
{ id: "nested-reply", depth: 1 },
],
);
});

View File

@@ -207,7 +207,7 @@ function buildVisibleThreadReplies(params: {
appendExpandedReplies({
entries,
parentId: openThreadHeadId,
depth: 1,
depth: 0,
directChildrenByParentId,
descendantStatsByMessageId,
expandedReplyIds,

View File

@@ -255,7 +255,7 @@ export const MessageRow = React.memo(
<article
className={cn(
"group/message rounded-2xl px-2 py-1 transition-colors",
isThreadReplyLayout ? "space-y-1" : "flex items-start gap-2.5",
isThreadReplyLayout ? "space-y-0" : "flex items-start gap-2.5",
highlighted ? "bg-primary/10 ring-1 ring-primary/30" : "",
)}
data-message-id={message.id}
@@ -298,7 +298,9 @@ export const MessageRow = React.memo(
</div>
</div>
</div>
<div className="min-w-0 space-y-0.5">{messageBodyNode}</div>
<div className="-mt-0.5 min-w-0 space-y-0.5 pl-[26px]">
{messageBodyNode}
</div>
</>
) : (
<>