Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ import { tailWindowStart } from "@/lib/transcript-window";
import { useUnreadDivider } from "@/hooks/use-unread-divider";
import { NewMessagesDivider } from "./NewMessagesDivider";
import { PeerExchangeLine } from "./PeerExchangeLine";
import { exchangeDrawsNothing } from "@/lib/peer-exchange";
import { useExchangeRows } from "@/hooks/use-exchange-runs";
import { unreadMessageIds } from "@/lib/unread-divider";
import { useReplyDraft } from "@/lib/drafts";
Expand Down Expand Up @@ -875,6 +876,7 @@ const MessagesList = memo(function MessagesList({
const run = exchanges.runAt.get(i);
const collapsed = run !== undefined && !exchanges.isOpen(run);
if (run && i !== run.start && collapsed) return null;
if (run && exchangeDrawsNothing(run.summary, !collapsed)) return null;
const leads = run !== undefined && i === run.start;
const newDay = needsStamp(prev, first);
const divider = dividerAbove(leads ? run.items.flatMap(transcriptRows) : transcriptRows(item));
Expand Down
12 changes: 11 additions & 1 deletion src/lib/peer-exchange.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import type { Message } from "@/state/store";
import { exchangeEntries, exchangeHidden, exchangeOpenByDefault, exchangeRuns, exchangeSummary, type ExchangeSummary } from "./peer-exchange";
import { exchangeDrawsNothing, exchangeEntries, exchangeHidden, exchangeOpenByDefault, exchangeRuns, exchangeSummary, type ExchangeSummary } from "./peer-exchange";

const msg = (id: string, fields: Partial<Message>): Message => ({ id, role: "bot", kind: "text", at: 1, ...fields } as Message);
const ghosty = { id: "ghosty", name: "Ghosty" };
Expand Down Expand Up @@ -29,6 +29,16 @@ describe("one chat per bot", () => {
expect(exchangeOpenByDefault({ kind: "single", direction: "inbound", as: "answer", peer })).toBe(true);
expect(exchangeOpenByDefault({ kind: "single", direction: "outbound", as: "reply", peer })).toBe(false);
});

it("leaves no stamp or divider over a folded run that draws no line", () => {
const peer = { id: "dusk", name: "dusk bot" };
const ask = { kind: "single", direction: "inbound", peer } as const;
expect(exchangeDrawsNothing(ask, false)).toBe(true);
expect(exchangeDrawsNothing({ kind: "single", direction: "outbound", as: "ask", peer }, false)).toBe(true);
expect(exchangeDrawsNothing({ kind: "single", direction: "outbound", as: "reply", peer }, false)).toBe(false);
expect(exchangeDrawsNothing({ kind: "single", direction: "inbound", as: "answer", peer }, true)).toBe(false);
expect(exchangeDrawsNothing({ kind: "thread", count: 3, peers: [peer] }, false)).toBe(false);
});
});

describe("exchangeEntries", () => {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/peer-exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export function exchangeSummary(all: readonly PeerEntry[]): ExchangeSummary | nu
* of its own ask shows inline under its line. */
export const exchangeHidden = (summary: ExchangeSummary): boolean =>
summary.kind === "single" && ((summary.direction === "inbound" && summary.as !== "answer") || summary.as === "ask");
/** A folded run with no line draws nothing, so it must not leave a day stamp or unread divider over blank space. */
export const exchangeDrawsNothing = (summary: ExchangeSummary, open: boolean): boolean => !open && exchangeHidden(summary);
/** A peer's answer starts open; with bot-to-bot replies switched off every run starts folded under its line. */
export const exchangeOpenByDefault = (summary: ExchangeSummary, showPeerReplies = true): boolean =>
showPeerReplies && summary.kind === "single" && summary.as === "answer";
Expand Down
Loading