Files
chatkit/dist/react/MessageThread.d.ts
T
CatoandClaude e690b2254a Messenger: people talking to people, and to the agents among them (0.29.0) (#82)
* Messenger: people talking to people, and to the agents among them (0.26.0)

OrangeCat's direct messages were built in the app, so what was wrong with
them could not be fixed for the next product: an agent's answer in a
conversation between two people looked like the other person's, nothing
said an agent was taking part, top bar and a two-row box took half a
phone, and nothing could be attached. This is the messenger as a package.

@bitbaum/chatkit/messenger: Messenger (the whole screen) and its parts
useMessenger, ConversationList, MessageThread, MessageAttachments. The app
implements MessengerTransport; the package has no database, websocket or
storage. styles/messenger.css is the embedded sheet plus the Messenger's
section, without ChatApp.

- An agent is told from a person by the shape of its face, an Agent mark
  with whom it answered for, and an outlined bubble; the top bar says it
  is in the conversation; naming it shows that it is thinking, and says
  so if it never answers.
- Files: Camera, Photos, Videos, Files, checked against the attachment
  policy before an upload starts, photos shrunk in the browser, progress
  and Try again per file, a full-screen viewer, a film drawn as its still.
- The thread: runs, day lines, a New line, ticks from readState, a failed
  message kept with Try again, earlier messages loaded above with the
  reader's place kept, one bubble per message however often it arrives.
- Composer: layout="inline", attachmentsAlone, attach.take, attach.accept,
  a "videos" source, files dropped onto the box. Defaults unchanged.

The state is one pure function (messengerReducer), tested in Node.
test/browser-messenger.mjs drives demo/messenger.html at 390px, 320px
dark and 1280px. It found two defects before any product did: a read mark
that cleared the badge without telling the server, and a page of history
that pulled the reader to the end of the thread.

threadkit 0.1.2 (attachment policy, mention matcher, readState) is merged
and tagged but not on npm, so those rules are carried word for word in
src/thread-rules.ts with threadkit's own tests; the file says when it goes.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmsmMXvM981mcszxEA6

* test(messenger): wait for the opened conversation before reading its thread

Side by side, the conversation that was open can still be on screen with a
"New" line of its own, so the check read the old thread on a slow runner.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmsmMXvM981mcszxEA6

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 16:26:03 +01:00

58 lines
2.9 KiB
TypeScript

import { type ReactNode } from "react";
import { type MessengerAgent, type MessengerConversation, type MessengerMessage } from "../messenger.js";
import type { MessengerAwaited } from "../messenger-state.js";
import { type RenderLink } from "./Markdown.js";
import { type MessengerLabels } from "./messenger-labels.js";
export type MessageThreadProps = {
conversation: MessengerConversation;
/** The id the viewer's own messages carry. */
viewerId: string;
/** Oldest first. */
messages: readonly MessengerMessage[];
agents?: readonly MessengerAgent[];
status?: "loading" | "ready" | "failed";
onReload?: () => void;
/** There are earlier messages to load. */
hasOlder?: boolean;
loadingOlder?: boolean;
olderFailed?: boolean;
onLoadOlder?: () => void;
/** The viewer's read mark when the thread was opened: where "New" is drawn. */
unreadFrom?: Date | null;
/** Actor ids of the people typing now. */
typing?: readonly string[];
/** Agents somebody just called on. */
awaited?: readonly MessengerAwaited[];
onDismissAgent?: (agentId: string) => void;
onRetry?: (message: MessengerMessage) => void;
onDiscard?: (message: MessengerMessage) => void;
/** Open what can be done to a message (copy, edit, delete). Given, a
* message answers a long press, a right click and its "…" button. */
onAction?: (message: MessengerMessage) => void;
/** The viewer is at the newest message and it is on screen. */
onSeen?: () => void;
onFollowingChange?: (following: boolean) => void;
renderLink?: RenderLink;
/** A product's own mark for an agent with no picture. */
agentMark?: ReactNode;
locale?: string;
timeZone?: string;
labels?: MessengerLabels;
};
/**
* A conversation between people, and the agents among them.
*
* What it settles so no product has to again: whose message is whose (the
* viewer's on the right; everyone else's on the left, named whenever more
* than one other voice is present); that an agent never passes for a person
* (its own shape of face, an "Agent" mark, whom it answered for, its words in
* an outlined bubble); runs of messages that share one name and one time; a
* line where each day begins and one where the unread begin; ticks drawn from
* threadkit's `readState`; a message that failed, kept with Try again.
*
* It scrolls itself: give it a box with a height. It follows new messages
* only while the reader is at the end, and keeps its place when earlier
* messages are loaded above.
*/
export declare function MessageThread({ conversation, viewerId, messages, agents, status, onReload, hasOlder, loadingOlder, olderFailed, onLoadOlder, unreadFrom, typing, awaited, onDismissAgent, onRetry, onDiscard, onAction, onSeen, onFollowingChange, renderLink, agentMark, locale, timeZone, labels, }: MessageThreadProps): import("react").JSX.Element;
//# sourceMappingURL=MessageThread.d.ts.map