Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

Merge remote-tracking branch 'origin/main' into feat/chats-visual-redesign

Rezk Jörg Sebening71ce79483f4b
diff --cc CHANGELOG.md
index f6a820bac,c25c62e87..ad92ab211
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -17,11 -19,8 +19,11 @@@ and this project adheres to [Semantic V
- Add All, Unread, 1:1, Groups and Unknown quick filters to the dashboard chat list. Thanks @rjsebening.
- Add a New chat panel to the dashboard Chats page that opens a chat with a saved contact or a number WhatsApp confirms, and on Baileys creates a group. Thanks @rjsebening.
- Add chat and contact menus to the dashboard Chats page: pin, mute, archive, mark unread, save, rename and block a contact, leave a group, and clear or delete a chat on whatsapp-web.js only until #1891 is fixed. Thanks @rjsebening.
- - Add an Archived view to the dashboard chat list. Thanks @rjsebening.
+ - Add an Archived view to the dashboard chat list; archived chats no longer appear in the main list unless searched, and pinned chats lead it. Thanks @rjsebening.
- Add a group info dialog to the dashboard Chats page that edits a group and manages its participants. Thanks @rjsebening.
- - Add a session switcher to the dashboard Chats page that lists every session with its state, picture, push name and number, and lets only a ready one be selected.
- - Add a contact info panel to the dashboard chat room with the contact's picture, name, number and copyable chat id.
- - Add Today, Yesterday and date separators to the dashboard chat thread.
++- Add a session switcher to the dashboard Chats page that lists every session with its state, picture, push name and number, and lets only a ready one be selected. Thanks @rjsebening.
++- Add a contact info panel to the dashboard chat room with the contact's picture, name, number and copyable chat id. Thanks @rjsebening.
++- Add Today, Yesterday and date separators to the dashboard chat thread. Thanks @rjsebening.
### Changed
@@@ -35,15 -37,27 +40,33 @@@
- Remove the unused `STORAGE_LIST_MAX_FILES` setting; a leftover value is ignored instead of validated at boot.
- Remove the `INFO` permission from the bundled Docker socket proxy; nothing used it, and `GET /info` through the proxy is now refused.
- Drop the `archiver` dependency; the storage export writes its tar.gz with `tar-stream` and `zlib`.
- - Remove a stored plugin secret when a config write sends `null` for it; an empty string still keeps it.
+ - Remove a stored plugin secret when a config write sends `null` for it, where `null` used to keep it; an empty string still keeps it.
- Send `null` for a cleared secret field in the plugin config form of the dashboard, which removes the stored secret.
- Reuse the participant list of a Baileys group for up to 5 minutes (`BAILEYS_GROUP_METADATA_CACHE_TTL_MS`, `0` queries for every send) instead of querying it for every group message.
- - Redesign the dashboard Chats page in a WhatsApp Web style, full height without the page header, with its own light and dark palette, a patterned wallpaper behind the thread, coloured avatars, tailed bubbles and a single-pill composer; every existing chat feature stays.
- - Show the dashboard Chats page's message search behind a toggle in the chat list header, still hidden for read-only keys.
- - Show the raw chat id of a dashboard chat in its contact info panel instead of the room header.
- - Show a dashboard chat message's time and delivery ticks inside its last line of text, with the delivery status still named for screen readers.
- - Show dashboard chat list times as the clock today, Yesterday, the weekday within the last week and a short date before that.
- - Move the dashboard sidebar's collapse button from the sidebar edge into its header, beside the logo or under it when collapsed, with a panel icon mirrored for right-to-left languages.
+ - Close a `/events` WebSocket connection that sends a client frame over 8 KiB, where Socket.IO's default allowed 1 MB; the subscribe frames of the dashboard and the SDKs are under 1 KB.
+ - Cut an inbound poll to 32 options and 1024 characters per option and for the question, far above WhatsApp's own limits, so a malformed poll cannot bloat stored rows, webhooks or socket frames.
+ - Refuse a JSON boolean or object in a string field of a request body with 400; they used to be converted to text, so `{"text":{"a":1}}` sent the customer `[object Object]`. A JSON number is still converted.
+ - Refuse an array where a request body expects an object (bulk options, `customLinkPreview`, bulk item content and media, infrastructure config sections, status media sources) and an object where it expects a list with 400; they were stored as defaults or as an empty list.
+ - Refuse a request body nested more than 100 levels deep with 400; a body a few thousand levels deep used to answer 500 with a stack trace in the error log.
+ - Refuse a `muteUntil` above 9007199254740991 on `POST /api/sessions/{sessionId}/chats/mute` with 400; larger values are not exact integers, and from 2^63 they wrapped the Baileys int64.
+ - Mark the fields the gateway always sends as required in the JavaScript, Python and Go SDK response types and drop the `null` it never sends; `ParticipantsResult` no longer extends `SuccessResult` in the JavaScript and Python SDKs, and the key validation `role` is typed `admin`, `operator` or `viewer` in the JavaScript and Python SDKs, from SDK 0.7.0.
+ - Hold the dashboard automatic mark-as-read while the browser tab is hidden and send it when the tab is visible again.
+ - Acknowledge, when the dashboard opens a chat on Baileys, up to the 100 newest loaded incoming messages it has not acknowledged yet, where it acknowledged only the newest.
+ - Add `builtInSet` to the `database`, `redis` and `storage` sections of `GET /api/infra/config`, true when the saved configuration states the built-in mode; a host pinned by the environment now decides `builtIn`.
+ - List `message.receipt` among the webhook events of the Webhooks page and say in the description of `*` that it does not deliver `message.receipt`.
+ - List in `envPinned` of `GET /api/infra/status` any of the 31 settings a save of the Infrastructure page writes that the environment pins, where 0.25.0 listed eight, and report the storage `endpoint` there in S3 mode; the page names each pinned setting beside its field and its restart warning follows the pinned value.
+ - Add `running` to the `database`, `redis` and `storage` sections of `GET /api/infra/status`, true while a bundled container OpenWA created runs and this instance's built-in flag is set, whether or not the service uses it, and false for one Docker Compose created; it is absent while Docker is unreachable.
+ - Accept a `database` or `storage` section without `type` on `PUT /api/infra/config`, keeping the stored type.
+ - Serve every page after the first of `GET /api/sessions/{sessionId}/chats` and `GET /api/sessions/{sessionId}/contacts` from the list the engine returned within the last 5 s, so walking a large account costs one engine read instead of one per page.
+ - Name the Go SDK status font constants after the WhatsApp protocol (`StatusFontSystemText`, `StatusFontFBScript`, `StatusFontMorningBreezeRegular`, `StatusFontCalistogaRegular`, `StatusFontExo2ExtraBold`, `StatusFontCourierPrimeBold`), from Go SDK 0.7.0; the old names, which did not match the font each id selects, stay as deprecated aliases.
+ - Refuse to start with `REDIS_TLS=true` or a `REDIS_USERNAME` other than `default` beside the built-in Redis, which serves plain TCP and only its default user, where every Redis connection failed; the Infrastructure page refuses to save that combination.
+ - Log an error at start for `STORAGE_TYPE=s3` with an `S3_ENDPOINT` that is not an absolute `http://` or `https://` URL, where every S3 call failed and media went to local disk, and refuse a save from the Infrastructure page that changes it or newly selects S3 beside it.
++- Redesign the dashboard Chats page in a WhatsApp Web style, full height without the page header, with its own light and dark palette, a patterned wallpaper behind the thread, coloured avatars, tailed bubbles and a single-pill composer; every existing chat feature stays. Thanks @rjsebening.
++- Show the dashboard Chats page's message search behind a toggle in the chat list header, still hidden for read-only keys. Thanks @rjsebening.
++- Show the raw chat id of a dashboard chat in its contact info panel instead of the room header. Thanks @rjsebening.
++- Show a dashboard chat message's time and delivery ticks inside its last line of text, with the delivery status still named for screen readers. Thanks @rjsebening.
++- Show dashboard chat list times as the clock today, Yesterday, the weekday within the last week and a short date before that. Thanks @rjsebening.
++- Move the dashboard sidebar's collapse button from the sidebar edge into its header, beside the logo or under it when collapsed, with a panel icon mirrored for right-to-left languages. Thanks @rjsebening.
### Fixed
diff --cc dashboard/src/bidi.test.ts
index 000000000,673ff9dc3..0b7e293fb
mode 000000,100644..100644
--- a/dashboard/src/bidi.test.ts
+++ b/dashboard/src/bidi.test.ts
@@@ -1,0 -1,85 +1,96 @@@
+ import { test } from 'node:test';
+ import assert from 'node:assert/strict';
+ import { readFileSync } from 'node:fs';
+ import { fileURLToPath } from 'node:url';
+ import { dirname, join } from 'node:path';
+
+ // Under <html dir="rtl"> a phone number or an id shown as plain text is laid out right to left: "+1 555 000 1111"
+ // reads "1111 000 555 1+" and "[email protected]" splits around the at sign. Each such value has to be
+ // isolated so it keeps its own left to right order.
+
+ const SRC = dirname(fileURLToPath(import.meta.url));
+
+ function body(file: string, selector: string): string {
+ const css = readFileSync(join(SRC, file), 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');
+ for (const m of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
+ if (m[1].split(',').some(s => s.trim() === selector)) return m[2];
+ }
+ assert.fail(`${file} has no ${selector} rule`);
+ }
+
-test('the open chat header isolates the phone number and the raw id', () => {
- for (const selector of ['.chats-page .room-contact-phone', '.chats-page .room-contact-jid']) {
- assert.match(body('pages/Chats.css', selector), /unicode-bidi:\s*plaintext/, selector);
- }
++// The room header shows the number under the name, and the contact panel the raw id. Each is a value of its own,
++// isolated left to right in the markup: in an RTL page "+1 555 000 1111" would otherwise read "1111 000 555 1+" and
++// "[email protected]" would move "@c.us" to the other end.
++const CHATS_TSX = readFileSync(join(SRC, 'pages/Chats.tsx'), 'utf8');
++
++test('the open chat header isolates the phone number, and the contact panel the raw id', () => {
++ assert.match(
++ CHATS_TSX,
++ /<span className="room-contact-phone">\s*<bdi dir="ltr">\{activePhoneText\}<\/bdi>/,
++ 'the header number is not isolated',
++ );
++ assert.match(
++ CHATS_TSX,
++ /<dd className="mono">[\s\S]*?<bdi dir="ltr"[^>]*>\s*\{activeChat\.id\}\s*<\/bdi>/,
++ 'the chat id in the contact panel is not isolated',
++ );
+ });
+
-test('the header lines hug the start edge with the name instead of stretching across it', () => {
- // A paragraph of digits or Latin letters resolves to left to right under plaintext, so inside a stretched box
- // its text would sit on the left of an Arabic header while the name sits on the right.
- for (const selector of ['.chats-page .room-contact-phone', '.chats-page .room-contact-jid']) {
- assert.match(body('pages/Chats.css', selector), /align-self:\s*flex-start/, selector);
- }
++test('the header number keeps the page direction, so it sits at the start edge with the name', () => {
++ // The isolate inside it carries the number's own direction. Under plaintext the line would resolve to left to
++ // right and, in a box the header column stretches, sit at the left edge of an Arabic header with the name at the
++ // right; the name, which is cut and so takes its own direction, hugs the start edge instead (see below).
++ assert.doesNotMatch(body('pages/Chats.css', '.chats-page .room-contact-phone'), /unicode-bidi/);
+ });
+
+ test('text cut with an ellipsis takes its direction from its own characters', () => {
+ // The ellipsis removes the end of the line in the direction of the box. Under the page direction a Latin name in
+ // an Arabic page (or an Arabic one in an English page) lost its first letters and kept its last.
+ const cut = [
+ '.chats-page .chat-item-name',
+ '.chats-page .chat-item-snippet',
- '.chats-page .room-contact-info h3',
++ '.chats-page .room-contact-name',
+ '.chats-page .preview-filename',
+ '.chats-page .quote-body',
+ '.chats-page .replying-to-body',
+ '.chats-page .group-info-member .name',
+ ];
+ for (const selector of cut) {
+ const rule = body('pages/Chats.css', selector);
+ assert.match(rule, /text-overflow:\s*ellipsis/, `${selector} is expected to be cut with an ellipsis`);
+ assert.match(rule, /unicode-bidi:\s*plaintext/, selector);
+ }
+ });
+
+ test('the reply title is a sentence with a name inside, so it keeps the page direction', () => {
+ // Read by its first strong letter, "{{name}} kişisine yanıt veriliyor" with an Arabic name would resolve right
+ // to left and draw its words backwards.
+ const rule = body('pages/Chats.css', '.chats-page .replying-to-title');
+ assert.match(rule, /text-overflow:\s*ellipsis/);
+ assert.doesNotMatch(rule, /unicode-bidi/);
+ });
+
+ test('cut text that a flex column stretches hugs the start edge, where its siblings are', () => {
+ // unicode-bidi: plaintext also aligns the text by its own direction, so a stretched box would put a Latin name
+ // at the left edge of an Arabic page while the lines beside it sit at the right.
+ const hugging = [
+ '.chats-page .chat-item-info > .chat-item-name',
+ '.chats-page .chat-item-info > .chat-item-snippet',
- '.chats-page .room-contact-info h3',
++ '.chats-page .room-contact-name',
+ '.chats-page .preview-filename',
+ '.chats-page .replying-to-body',
+ ];
+ for (const selector of hugging) {
+ const rule = body('pages/Chats.css', selector);
+ assert.match(rule, /align-self:\s*flex-start/, selector);
+ assert.match(rule, /max-width:\s*100%/, `${selector} needs a cap, or the ellipsis never shows`);
+ }
+ const quote = body('pages/Chats.css', '.chats-page .quote-body');
+ assert.match(quote, /width:\s*fit-content/);
- // A long nowrap quote is as wide as its text, so the cap has to follow the room in the box, not only 250px.
- assert.match(quote, /max-width:\s*min\(250px,\s*100%\)/);
++ // A long nowrap quote is as wide as its text, so the cap has to follow the room in the box, not only a fixed width.
++ assert.match(quote, /max-width:\s*min\(\d+px,\s*100%\)/);
+ });
+
+ test('chart plots stay left to right on a right to left page', () => {
+ assert.match(body('components/DashboardCharts.css', '.dashboard-charts .recharts-surface'), /direction:\s*ltr/);
+ });
diff --cc dashboard/src/components/Layout.css
index 20f9e7043,80c8064a2..0252b11f9
--- a/dashboard/src/components/Layout.css
+++ b/dashboard/src/components/Layout.css
@@@ -111,17 -110,15 +112,17 @@@
}
.collapse-toggle:hover {
- background: var(--primary);
- border-color: var(--primary);
- color: #0f172a;
- box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
+ background: var(--bg-light);
+ color: var(--text-primary);
}
-.collapse-toggle svg {
- width: 16px;
- height: 16px;
+.collapse-toggle:focus-visible {
- outline: 2px solid var(--primary);
++ outline: 2px solid var(--focus-ring);
+ outline-offset: 2px;
+}
+
+.sidebar.collapsed .collapse-toggle {
+ margin-inline-start: 0;
}
.sidebar-nav {
diff --cc dashboard/src/components/Layout.css.test.ts
index a637b7b25,93ffc33d1..bab3fdb98
--- a/dashboard/src/components/Layout.css.test.ts
+++ b/dashboard/src/components/Layout.css.test.ts
@@@ -67,12 -68,146 +68,147 @@@ test('the closed mobile sidebar slides
const open = find("[dir='rtl'] .sidebar.mobile.open").filter(r => r.media === closed[0].media);
assert.equal(open.length, 1, 'the RTL closed rule would also hide the open sidebar');
assert.equal(decl(open[0].body, 'transform'), 'translateX(0)');
+ // The shadow falls on the content side, which under RTL is the left.
+ assert.match(decl(open[0].body, 'box-shadow') ?? '', /^-2px /);
+ });
+
+ // A shadow on the closed drawer reaches about 20px past its off-screen edge and showed as a grey band along the
+ // edge of every phone page.
+ test('the mobile sidebar casts its shadow only while it is open', () => {
+ for (const dir of ['', "[dir='rtl'] "]) {
+ const closed = find(`${dir}.sidebar.mobile`).filter(r => r.media);
+ assert.equal(closed.length, 1, `${dir}.sidebar.mobile`);
+ assert.equal(decl(closed[0].body, 'box-shadow'), undefined, `${dir}.sidebar.mobile shadows the screen edge`);
+ }
+ const open = find('.sidebar.mobile.open').filter(r => r.media);
+ assert.equal(open.length, 1, 'no open rule for the mobile sidebar');
+ assert.match(decl(open[0].body, 'box-shadow') ?? '', /^2px /);
+ });
+
+ // The language menu opens upward from the sidebar footer with all 15 languages in it, 559px tall. With no bound its
+ // first entries (English included) ended above the top edge of any window shorter than about 720px, and the sidebar
+ // is fixed, so nothing scrolled them back into view. The footer and the menu sit lower in the collapsed sidebar.
+ test('the language menu is bounded by the window and scrolls', () => {
+ const menu = find('.language-menu-list').find(r => !r.media);
+ assert.ok(menu, 'no base .language-menu-list rule');
+ assert.equal(decl(menu.body, 'overflow-y'), 'auto');
+ assert.equal(decl(menu.body, 'max-height'), 'calc(100vh - 13rem)');
+ const collapsed = find('.sidebar.collapsed .language-menu-list').find(r => !r.media);
+ assert.ok(collapsed, 'no collapsed .language-menu-list rule');
+ assert.equal(decl(collapsed.body, 'max-height'), 'calc(100vh - 9rem)');
+ });
+
+ // 100vh is the large viewport on a phone whose browser collapses its toolbar, so a full-height scroller ended behind
+ // the toolbar and its last rows could not be scrolled into view. 100dvh follows the visible area; the 100vh line
+ // before it is the fallback for a browser without dvh.
+ const valuesOf = (body: string, prop: string): string[] =>
+ [...body.matchAll(new RegExp(`(?:^|;)\\s*${prop}\\s*:\\s*([^;]+)`, 'g'))].map(m => m[1].trim());
+
+ test('the full-height sidebar and mobile scroller follow the dynamic viewport', () => {
+ const sidebar = find('.sidebar').find(r => !r.media);
+ assert.ok(sidebar, 'no base .sidebar rule');
+ assert.deepEqual(valuesOf(sidebar.body, 'height'), ['100vh', '100dvh']);
+ const scroller = find('.main-content.mobile').find(r => r.media);
+ assert.ok(scroller, 'no mobile .main-content rule');
+ assert.deepEqual(valuesOf(scroller.body, 'height'), ['100vh', '100dvh']);
+ // .main-content keeps min-height: 100vh, which beats a smaller height: unless the scroller resets it, the dvh line
+ // above never takes effect and the scroller stays as tall as the large viewport.
+ assert.deepEqual(valuesOf(scroller.body, 'min-height'), ['0']);
+ });
+
+ // The header menu button turns into the close control while the drawer is open. A drawer that started at the top edge
+ // sat over it (sidebar 100, header 90) and the tap landed on the drawer's logo. The drawer starts under the header, and
+ // the header rises above the dimming overlay so the button stays visible and tappable.
+ test('the phone drawer starts below the mobile header and the header stays above the overlay', () => {
+ const header = find('.mobile-header').find(r => r.media);
+ assert.ok(header, 'no mobile .mobile-header rule');
+ const headerHeight = decl(header.body, 'height');
+ assert.match(headerHeight ?? '', /^\d+px$/);
+
+ const drawer = find('.sidebar.mobile').find(r => r.media);
+ assert.ok(drawer, 'no mobile .sidebar.mobile rule');
+ assert.equal(decl(drawer.body, 'top'), headerHeight, 'the drawer starts above the bottom of the header');
+ assert.deepEqual(valuesOf(drawer.body, 'height'), [
+ `calc(100vh - ${headerHeight})`,
+ `calc(100dvh - ${headerHeight})`,
+ ]);
+ // The page scroller keeps the same strip clear.
+ const scroller = find('.main-content.mobile').find(r => r.media);
+ assert.equal(decl(scroller?.body ?? '', 'padding-top'), headerHeight);
+
+ // The language menu grows upward from the footer, and the drawer is a header shorter than the window: unbounded by
+ // that strip it rose over the header and the menu button (Arabic, whose footer is the tallest).
+ const menu = find('.sidebar.mobile .language-menu-list').find(r => r.media);
+ assert.deepEqual(valuesOf(menu?.body ?? '', 'max-height'), [
+ `calc(100vh - 13rem - ${headerHeight})`,
+ `calc(100dvh - 13rem - ${headerHeight})`,
+ ]);
+
+ const overlay = find('.sidebar-overlay').find(r => r.media);
+ assert.ok(
+ Number(decl(header.body, 'z-index')) > Number(decl(overlay?.body ?? '', 'z-index')),
+ 'the overlay dims the button',
+ );
+ });
+
+ test('the language menu is bounded by the dynamic viewport too, since it hangs off the sidebar bottom', () => {
+ const menu = find('.language-menu-list').find(r => !r.media);
+ assert.deepEqual(valuesOf(menu?.body ?? '', 'max-height'), ['calc(100vh - 13rem)', 'calc(100dvh - 13rem)']);
+ const collapsed = find('.sidebar.collapsed .language-menu-list').find(r => !r.media);
+ assert.deepEqual(valuesOf(collapsed?.body ?? '', 'max-height'), ['calc(100vh - 9rem)', 'calc(100dvh - 9rem)']);
+ });
+
+ // The Plugins page pins its status rail with position: sticky. overflow-x: hidden makes .main-content a scroll
+ // container (overflow-y computes to auto), the nearest one a sticky box sticks to, and that one never scrolls, so
+ // the rail scrolled away with the page. clip hides the overflow without that.
+ test('the main content clips sideways overflow without becoming a scroll container', () => {
+ const main = find('.main-content').find(r => !r.media);
+ assert.ok(main, 'no base .main-content rule');
+ assert.equal(decl(main.body, 'overflow-x'), 'clip');
});
-test('the collapse chevron is mirrored once, by the icon Layout.tsx picks', () => {
- assert.match(tsx, /isRtl \? \(\s*<ChevronLeft/, 'Layout.tsx no longer swaps the chevron for RTL');
- for (const r of all.filter(r => r.selectors.some(s => s.includes('.collapse-toggle svg')))) {
- assert.equal(decl(r.body, 'transform'), undefined, `${r.selectors.join(', ')} flips the chevron again`);
+test('the collapse icon is mirrored once, by the icon Layout.tsx picks', () => {
+ assert.match(tsx, /isRtl \?\s*\(?\s*<PanelRightClose/, 'Layout.tsx no longer swaps the collapse icon for RTL');
+ assert.match(tsx, /isRtl \?\s*\(?\s*<PanelRightOpen/, 'Layout.tsx no longer swaps the expand icon for RTL');
+ for (const r of all.filter(r => r.selectors.some(s => s.includes('.collapse-toggle') && s.includes('svg')))) {
+ assert.equal(decl(r.body, 'transform'), undefined, `${r.selectors.join(', ')} flips the icon again`);
}
});
+
-// A selector's weight as classes, attributes and pseudo-classes: the selectors under test carry no ids.
-const weight = (selector: string): number =>
- (selector.match(/\.[\w-]+|\[[^\]]+\]|:[\w-]+(?:\([^)]*\))?/g) ?? []).length;
-
-test('no rule outweighs the RTL one that moves the collapse toggle to the sidebar inner edge', () => {
- const mirror = "[dir='rtl'] .collapse-toggle";
- assert.equal(find(mirror).length, 1, 'no RTL rule for the collapse toggle');
- // A heavier rule that sets `right` (the collapsed sidebar once repeated the base value) wins under
- // RTL and pushes the toggle half off the screen.
- const heavier = all
- .filter(r => decl(r.body, 'right') !== undefined)
- .flatMap(r => r.selectors)
- .filter(s => /\.collapse-toggle$/.test(s) && weight(s) >= weight(mirror) && s !== mirror);
- assert.deepEqual(heavier, []);
++// The collapse toggle sits in the header row, pushed to its end by a logical margin, not on the sidebar edge, so it
++// follows the page direction by itself. A physical offset or an absolute position would need an RTL mirror again, and
++// a heavier rule that set `right` once won over that mirror and pushed the RTL toggle half off the screen.
++test('the collapse toggle sits in the header row with logical offsets, so a right-to-left page needs no mirror', () => {
++ const toggles = all.filter(r => r.selectors.some(s => /\.collapse-toggle$/.test(s)));
++ const base = toggles.find(r => !r.media && r.selectors.includes('.collapse-toggle'));
++ assert.ok(base, 'no base .collapse-toggle rule');
++ assert.equal(decl(base.body, 'margin-inline-start'), 'auto');
++ for (const r of toggles) {
++ for (const prop of ['position', 'left', 'right', 'margin-left', 'margin-right']) {
++ assert.equal(decl(r.body, prop), undefined, `${r.selectors.join(', ')} sets ${prop}`);
++ }
++ }
++ assert.equal(find("[dir='rtl'] .collapse-toggle").length, 0, 'an RTL rule moves the toggle again');
+ });
+
+ // -webkit-overflow-scrolling: touch gave iOS momentum scrolling before iOS 13, which now scrolls every overflow area that
+ // way. WebKit still honours the property on iPhone and gives the element a stacking context (StyleAdjuster.cpp:
+ // "Touch overflow scrolling creates a stacking context"), which would trap the page-level modal overlays (z-index
+ // 1000) inside the scroller, under the fixed mobile header (90) and sidebar (100).
+ test('no stylesheet asks for the legacy touch overflow scrolling', () => {
+ const sheets = (dir: string): string[] =>
+ readdirSync(dir, { withFileTypes: true }).flatMap(entry => {
+ const full = join(dir, entry.name);
+ if (entry.isDirectory()) return sheets(full);
+ return entry.name.endsWith('.css') ? [full] : [];
+ });
+ const files = sheets(join(DIR, '..'));
+ assert.ok(files.length >= 20, `only ${files.length} stylesheets found`);
+ const offenders = files.filter(file =>
+ /-webkit-overflow-scrolling/.test(readFileSync(file, 'utf8').replace(/\/\*[\s\S]*?\*\//g, '')),
+ );
+ assert.deepEqual(
+ offenders.map(file => file.slice(DIR.length - 'components'.length)),
+ [],
+ );
+ });
diff --cc dashboard/src/components/chats/ChatThread.test.ts
index c7cbd2e54,eb10940fc..f5751835f
--- a/dashboard/src/components/chats/ChatThread.test.ts
+++ b/dashboard/src/components/chats/ChatThread.test.ts
@@@ -1852,57 -1836,5 +1852,57 @@@ test('does not label an unedited or rev
{ ...PROMPT, metadata: undefined },
{ ...PROMPT, id: 'revoked', waMessageId: 'revoked', type: 'revoked', metadata: { edited: true } },
]);
- assert.equal(container.querySelector('.message-edited'), null);
+ assert.equal(container.querySelectorAll('.message-edited').length, 0);
});
+
+// Two messages one day apart, and a reply on the second day from the other side.
+const DAY = 86_400;
+const dayThread = (): ChatMessageView[] => [
+ { ...PROMPT, id: 'd1', waMessageId: 'wamid.d1', body: 'first day', metadata: undefined },
+ {
+ ...PROMPT,
+ id: 'd2',
+ waMessageId: 'wamid.d2',
+ body: 'second day',
+ timestamp: PROMPT.timestamp! + DAY,
+ metadata: undefined,
+ },
+ {
+ ...PROMPT,
+ id: 'd3',
+ waMessageId: 'wamid.d3',
+ body: 'reply',
+ direction: 'outgoing',
+ status: 'read',
+ timestamp: PROMPT.timestamp! + DAY + 60,
+ metadata: undefined,
+ },
+];
+
+// The older-page indicator is measured against the first text of the thread, which this pill is: a thread
+// always opens with the day of its first message.
+test('a thread opens with the day of its first message, and each new day gets a pill of its own', () => {
+ const { container } = renderThread('operator', dayThread());
+ const children = Array.from(container.querySelector('.room-messages')!.children);
+ assert.ok(children[0].classList.contains('day-separator'), 'the thread opens with a day pill');
+ assert.equal(container.querySelectorAll('.day-separator').length, 2, 'one pill per day');
+ // A pill is never an anchor the scroll hook holds the reader by: only messages are.
+ assert.ok(!children[0].hasAttribute('data-scroll-anchor'), 'the day pill is not a scroll anchor');
+});
+
+test('the first bubble of a run from one side starts a run, and a new day starts one too', () => {
+ const { container } = renderThread('operator', dayThread());
+ const starts = Array.from(container.querySelectorAll('.message-bubble-wrapper')).map(wrapper =>
+ wrapper.classList.contains('run-start'),
+ );
+ assert.deepEqual(starts, [true, true, true]);
+
+ rtl.cleanup();
+ const sameDay = dayThread().map(message => ({ ...message, direction: 'incoming' as const }));
+ sameDay[0] = { ...sameDay[0], timestamp: sameDay[1].timestamp };
+ const { container: oneRun } = renderThread('operator', sameDay);
+ const runStarts = Array.from(oneRun.querySelectorAll('.message-bubble-wrapper')).map(wrapper =>
+ wrapper.classList.contains('run-start'),
+ );
+ assert.deepEqual(runStarts, [true, false, false], 'one side on one day is a single run');
+});
diff --cc dashboard/src/components/chats/ChatThread.tsx
index 82ca83033,94e1ab4f6..5b3f3ee70
--- a/dashboard/src/components/chats/ChatThread.tsx
+++ b/dashboard/src/components/chats/ChatThread.tsx
@@@ -697,149 -646,119 +697,149 @@@ function ChatThread(
const isMasked = msg.type === 'masked';
return (
- <div
- key={msg.id}
- className={`message-bubble-wrapper ${isMe ? 'outgoing' : 'incoming'}`}
- data-wa-message-id={msg.waMessageId}
- data-scroll-anchor={msg.id}
- >
+ <Fragment key={msg.id}>
+ {/* A sibling of the bubbles, not an anchor: the scroll hook holds the reader by messages only. */}
+ {startsNewDay && (
+ <div className="day-separator">
+ <span>{formatDayLabel(ts)}</span>
+ </div>
+ )}
<div
- className="message-bubble-container"
- {...(hasActions(msg)
- ? {
- 'data-roving-message': '',
- tabIndex: tabStopId === msg.id ? 0 : -1,
- // Only focus on the bubble itself: a link or a button inside it is a stop of its own and
- // must not turn the bubble into the thread's tab stop as well.
- onFocus: (event: FocusEvent<HTMLDivElement>) => {
- if (event.target === event.currentTarget) setFocusedMessageId(msg.id);
- },
- onKeyDown: onBubbleKeyDown,
- }
- : {})}
+ className={`message-bubble-wrapper ${isMe ? 'outgoing' : 'incoming'}${startsRun ? ' run-start' : ''}${
+ hasReactions ? ' has-reactions' : ''
+ }`}
+ data-wa-message-id={msg.waMessageId}
- data-scroll-anchor=""
++ data-scroll-anchor={msg.id}
>
<div
- className={`message-bubble ${isMe ? 'outgoing' : 'incoming'} ${msg.status} ${
- isMediaMessage ? 'media-type' : ''
- } ${isRevoked ? 'revoked-type' : ''}`}
+ className="message-bubble-container"
+ {...(hasActions(msg)
+ ? {
+ 'data-roving-message': '',
+ tabIndex: tabStopId === msg.id ? 0 : -1,
+ // Only focus on the bubble itself: a link or a button inside it is a stop of its own and
+ // must not turn the bubble into the thread's tab stop as well.
+ onFocus: (event: FocusEvent<HTMLDivElement>) => {
+ if (event.target === event.currentTarget) setFocusedMessageId(msg.id);
+ },
+ onKeyDown: onBubbleKeyDown,
+ }
+ : {})}
>
- {/* Group sender label (WhatsApp-style: coloured name atop the bubble) */}
- {/* Group sender label (WhatsApp-style: coloured name atop the bubble).
+ <div
+ className={`message-bubble ${isMe ? 'outgoing' : 'incoming'} ${msg.status} ${
+ isMediaMessage ? 'media-type' : ''
+ } ${isRevoked ? 'revoked-type' : ''}`}
+ >
+ {/* Group sender label (WhatsApp-style: coloured name atop the bubble) */}
+ {/* Group sender label (WhatsApp-style: coloured name atop the bubble).
Colour keys on the stable sender id, so same-named participants
still get distinct colours; the label shows the human name. */}
- {showSender && (
- <div className="message-sender" style={{ color: senderColor(senderKey(msg)!) }}>
- {msg.chatName}
- </div>
- )}
+ {showSender && (
+ <div className="message-sender" style={{ color: senderColor(senderKey(msg)!) }}>
+ {msg.chatName}
+ </div>
+ )}
- {/* Quoted message display */}
- {msg.metadata?.quotedMessage && (
- <div className="message-quote-box">
- <MessageBody
- text={resolveMentions(msg.metadata.quotedMessage.body, mentionNames)}
- className="quote-body"
- />
- </div>
- )}
+ {/* Quoted message display */}
+ {msg.metadata?.quotedMessage && (
+ <div className="message-quote-box">
+ <MessageBody
+ text={resolveMentions(msg.metadata.quotedMessage.body, mentionNames)}
+ className="quote-body"
+ />
+ </div>
+ )}
- {renderMedia()}
+ {renderMedia()}
+
+ {/* Text flows inline and ends in an invisible spacer as wide as the time and ticks, so the
+ meta tucks into the last line when it fits and wraps below it only when it does not. */}
+ <div className="message-content">
+ {isRevoked ? (
+ <div className="message-text">{t('chats.messageDeleted')}</div>
+ ) : isMasked ? (
+ <div className="message-text message-masked">{t('chats.messageMasked')}</div>
+ ) : (
+ displayBody &&
+ (!mediaInfo || displayBody !== mediaInfo.filename) &&
+ msg.type !== 'location' &&
+ msg.type !== 'call' && (
+ <MessageBody text={resolveMentions(displayBody, mentionNames)} className="message-text" />
+ )
+ )}
- {isRevoked ? (
- <div className="message-text">{t('chats.messageDeleted')}</div>
- ) : isMasked ? (
- <div className="message-text message-masked">{t('chats.messageMasked')}</div>
- ) : (
- displayBody &&
- (!mediaInfo || displayBody !== mediaInfo.filename) &&
- msg.type !== 'location' &&
- msg.type !== 'call' && (
- <MessageBody text={resolveMentions(displayBody, mentionNames)} className="message-text" />
- )
- )}
+ {!isRevoked && msg.type === 'poll' && (msg.metadata?.poll?.options?.length ?? 0) > 0 && (
+ <ul className="message-text message-poll-options" aria-label={t('messageTester.pollOptions')}>
+ {msg.metadata!.poll!.options.map((option, index) => (
+ <li key={index}>
+ <bdi>{option}</bdi>
+ </li>
+ ))}
+ </ul>
+ )}
- {!isRevoked && msg.type === 'poll' && (msg.metadata?.poll?.options?.length ?? 0) > 0 && (
- <ul className="message-text" aria-label={t('messageTester.pollOptions')}>
- {msg.metadata!.poll!.options.map((option, index) => (
- <li key={index}>
- <bdi>{option}</bdi>
- </li>
- ))}
- </ul>
- )}
+ {/* Inbound business prompt choices; a tap calls POST .../messages/click-button. */}
+ {!isMe && !isRevoked && !isMasked && (msg.metadata?.buttons?.length ?? 0) > 0 && (
+ <div className="message-prompt-buttons" role="group" aria-label={t('chats.promptButtons')}>
+ {msg.metadata!.buttons!.map((btn, idx) => {
+ const clickKey = msg.waMessageId || msg.id;
+ const state = buttonClick[clickKey];
+ const loading = state?.loadingId === btn.id;
+ const disabled = Boolean(state?.loadingId || state?.done);
+ return (
+ <button
+ key={`${idx}:${btn.id}`}
+ type="button"
+ className={`message-prompt-button${state?.selectedId === btn.id ? ' selected' : ''}${state?.done ? ' answered' : ''}`}
+ disabled={disabled || !canWrite}
+ onClick={() => void handleClickButton(msg, btn)}
+ >
+ {loading ? <Loader2 size={14} className="animate-spin" /> : btn.text}
+ </button>
+ );
+ })}
+ </div>
+ )}
- {/* Inbound business prompt choices; a tap calls POST .../messages/click-button. */}
- {!isMe && !isRevoked && !isMasked && (msg.metadata?.buttons?.length ?? 0) > 0 && (
- <div className="message-prompt-buttons" role="group" aria-label={t('chats.promptButtons')}>
- {msg.metadata!.buttons!.map((btn, idx) => {
- const clickKey = msg.waMessageId || msg.id;
- const state = buttonClick[clickKey];
- const loading = state?.loadingId === btn.id;
- const disabled = Boolean(state?.loadingId || state?.done);
- return (
- <button
- key={`${idx}:${btn.id}`}
- type="button"
- className={`message-prompt-button${state?.selectedId === btn.id ? ' selected' : ''}${state?.done ? ' answered' : ''}`}
- disabled={disabled || !canWrite}
- onClick={() => void handleClickButton(msg, btn)}
+ {/* Holds the room the time (and an edited label, whose width the language decides) takes
+ at the end of the last line, so the text never runs under them. */}
+ <span className={`meta-spacer${isMe ? ' with-status' : ''}`} aria-hidden="true">
+ {isEdited && <span className="meta-spacer-edited">{t('chats.edited')}</span>}
+ </span>
+ <span className="message-meta">
+ {isEdited && <span className="message-edited">{t('chats.edited')}</span>}
+ <span className="message-time">{formattedTime}</span>
+ {/* delivered and read render the SAME glyph and differ only in colour, which
+ carries the meaning nowhere a screen reader or a colour-blind reader can
+ reach it. The status is spelled out for both. */}
+ {isMe && (
+ <span
+ className={`message-status-icon ${msg.status}`}
+ role="img"
+ aria-label={t(`chats.messageStatus.${msg.status}`)}
+ title={t(`chats.messageStatus.${msg.status}`)}
>
- {loading ? <Loader2 size={14} className="animate-spin" /> : btn.text}
- </button>
- );
- })}
+ {STATUS_ICONS[msg.status]}
+ </span>
+ )}
+ </span>
</div>
- )}
- <div className="message-meta">
- {!isRevoked && msg.metadata?.edited && <span className="message-edited">{t('chats.edited')}</span>}
- <span className="message-time">{formattedTime}</span>
- {/* delivered and read render the SAME glyph and differ only in colour, which
- carries the meaning nowhere a screen reader or a colour-blind reader can
- reach it. The status is spelled out for both. */}
- {isMe && (
- <span
- className={`message-status-icon ${msg.status}`}
- role="img"
- aria-label={t(`chats.messageStatus.${msg.status}`)}
- title={t(`chats.messageStatus.${msg.status}`)}
- >
- {msg.status === 'pending' && '🕒'}
- {msg.status === 'sent' && '✓'}
- {msg.status === 'delivered' && '✓✓'}
- {msg.status === 'read' && '✓✓'}
- {msg.status === 'failed' && '⚠️'}
- </span>
+ {/* Reactions display */}
+ {hasReactions && (
+ <div className="message-reactions-badge">
+ {Object.values(reactions)
+ .slice(0, 3)
+ .map((emoji, idx) => (
+ <span key={idx} className="reaction-emoji-span">
+ {emoji}
+ </span>
+ ))}
+ {Object.keys(reactions).length > 1 && (
+ <span className="reactions-count-span">{Object.keys(reactions).length}</span>
+ )}
+ </div>
)}
</div>
diff --cc dashboard/src/components/chats/GroupInfoDialog.tsx
index 0213c12ac,e979a6798..a5a2279ae
--- a/dashboard/src/components/chats/GroupInfoDialog.tsx
+++ b/dashboard/src/components/chats/GroupInfoDialog.tsx
@@@ -348,15 -344,19 +350,19 @@@ function GroupInfoDialog({ session, gro
<ul className="group-info-list">
{info.participants.map(p => {
const own = isOwnAccount(p, session);
- const label = own ? t('chats.you') : p.name || formatPhoneForDisplay(p.number) || p.number;
+ // Formatted from the id, not from `number`: a privacy id (@lid) has digits too, and they are no phone.
+ const phone = formatPhoneForDisplay(p.id);
+ const label = own ? t('chats.you') : p.name || phone || p.number;
+ // In a sentence (a button's label, the confirmation) a phone is isolated, as the typed number is.
+ const spoken = !own && !p.name && phone ? isolateNumber(phone) : label;
return (
<li key={p.id}>
- <ChatAvatar kind="individual" />
+ <ChatAvatar chatId={p.id} kind="individual" size="sm" />
<span className="group-info-member">
<bdi className="name">{label}</bdi>
- {p.name && (
+ {p.name && phone && (
<bdi className="number" dir="ltr">
- {formatPhoneForDisplay(p.number) ?? p.number}
+ {phone}
</bdi>
)}
</span>
diff --cc dashboard/src/components/chats/chatActionItems.tsx
index 17821757e,b3aa26d2c..b8d2ca95d
--- a/dashboard/src/components/chats/chatActionItems.tsx
+++ b/dashboard/src/components/chats/chatActionItems.tsx
@@@ -18,10 -17,11 +18,12 @@@ import
} from 'lucide-react';
import type { Chat } from '../../services/api';
-/** What a chat can be asked to do from its row or its room. Every one but group info is an operator route. */
+/** What a chat can be asked to do from its row or its room. Every one but the info views is an operator route. */
export interface ChatRowActions {
+ /** A 1:1 chat's menu is opening: what its entries read (the address book) is loaded from here, not at page load. */
+ onMenuOpen?: () => void;
onGroupInfo: (chat: Chat) => void;
+ onContactInfo?: (chat: Chat) => void;
onSaveContact?: (chat: Chat) => void;
/** Whether the chat has a phone-based id the address book accepts; Save is offered disabled otherwise. */
canSaveContact?: (chat: Chat) => boolean;
diff --cc dashboard/src/pages/Chats.css
index 48c0d27e6,a95099cb6..dc777e1c0
--- a/dashboard/src/pages/Chats.css
+++ b/dashboard/src/pages/Chats.css
@@@ -1,91 -1,12 +1,94 @@@
.chats-page {
- padding: 2rem;
+ /* Chat palette. Light values follow WhatsApp Web; the dark set below swaps them as a whole, so the rules
+ further down never need a theme branch of their own. */
+ --chat-panel: var(--bg-white);
+ --chat-panel-header: #f0f2f5;
+ --chat-hover: #f5f6f6;
+ --chat-active: #f0f2f5;
+ --chat-divider: #e9edef;
+ --chat-wallpaper: #efeae2;
+ --chat-wallpaper-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' fill='none' stroke='rgba%2884,72,56,0.07%29' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E %3Cpath d='M22 30h40a8 8 0 0 1 8 8v20a8 8 0 0 1-8 8H38l-12 10v-10h-4a8 8 0 0 1-8-8V38a8 8 0 0 1 8-8z'/%3E %3Cpath d='M150 40c0-7 9-11 14-5 5-6 14-2 14 5 0 9-14 17-14 17s-14-8-14-17z'/%3E %3Cpath d='M205 120l5 11 12 2-9 8 2 12-10-6-10 6 2-12-9-8 12-2z'/%3E %3Crect x='30' y='150' width='40' height='30' rx='6'/%3E%3Ccircle cx='50' cy='165' r='8'/%3E%3Cpath d='M40 150l4-6h12l4 6'/%3E %3Cpath d='M120 130l46-18-18 46-8-20z'/%3E%3Cpath d='M140 138l8-8'/%3E %3Ccircle cx='120' cy='210' r='12'/%3E%3Cpath d='M114 214c2 3 10 3 12 0'/%3E%3Cpath d='M115 206h.1M125 206h.1'/%3E %3Cpath d='M190 200h30M190 210h20M184 192h42v28h-42z'/%3E %3Cpath d='M90 70l6 6 12-12'/%3E%3Ccircle cx='99' cy='70' r='14'/%3E %3Cpath d='M200 70a10 10 0 1 1-1-8'/%3E%3Cpath d='M60 110h.1M70 110h.1M80 110h.1'/%3E %3C/svg%3E");
+ --chat-bubble-in: #ffffff;
+ --chat-bubble-out: #d9fdd3;
+ --chat-bubble-text: #111b21;
+ /* Text tokens clear WCAG AA (4.5:1) on every surface they land on: the list rows (resting, hover,
+ active) and both bubbles. theme-contrast.test.ts checks each pair. */
+ --chat-meta: #54656f;
+ --chat-meta-out: #54656f;
+ --chat-pill: #ffffff;
+ --chat-pill-active-bg: #d9fdd3;
- --chat-pill-active-text: #008069;
++ --chat-pill-active-text: #017561;
+ --chat-accent: #00a884;
+ --chat-accent-text: #017561;
+ --chat-accent-hover: #008f6f;
+ --chat-quote-accent: #06cf9c;
- --chat-link: #027eb5;
++ --chat-link: #0271a6;
++ --chat-link-out: #0271a6;
+ /* The WhatsApp read blue is 2.13:1 on the outgoing bubble; this one clears 3:1 for the icon there. Read
+ and delivered also differ in aria-label and title, never by colour alone. */
+ --chat-tick-read: #1f8fc4;
+ --chat-icon: #54656f;
+ --chat-shadow-bubble: 0 1px 0.5px rgba(11, 20, 26, 0.13);
+
width: 100%;
- height: calc(100vh - 4rem);
+ height: 100vh;
display: flex;
flex-direction: column;
box-sizing: border-box;
}
+[data-theme='dark'] .chats-page {
+ --chat-panel: #111b21;
+ --chat-panel-header: #202c33;
+ --chat-hover: #202c33;
+ --chat-active: #2a3942;
+ --chat-divider: #222d34;
+ --chat-wallpaper: #0b141a;
+ --chat-wallpaper-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' fill='none' stroke='rgba%28255,255,255,0.045%29' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E %3Cpath d='M22 30h40a8 8 0 0 1 8 8v20a8 8 0 0 1-8 8H38l-12 10v-10h-4a8 8 0 0 1-8-8V38a8 8 0 0 1 8-8z'/%3E %3Cpath d='M150 40c0-7 9-11 14-5 5-6 14-2 14 5 0 9-14 17-14 17s-14-8-14-17z'/%3E %3Cpath d='M205 120l5 11 12 2-9 8 2 12-10-6-10 6 2-12-9-8 12-2z'/%3E %3Crect x='30' y='150' width='40' height='30' rx='6'/%3E%3Ccircle cx='50' cy='165' r='8'/%3E%3Cpath d='M40 150l4-6h12l4 6'/%3E %3Cpath d='M120 130l46-18-18 46-8-20z'/%3E%3Cpath d='M140 138l8-8'/%3E %3Ccircle cx='120' cy='210' r='12'/%3E%3Cpath d='M114 214c2 3 10 3 12 0'/%3E%3Cpath d='M115 206h.1M125 206h.1'/%3E %3Cpath d='M190 200h30M190 210h20M184 192h42v28h-42z'/%3E %3Cpath d='M90 70l6 6 12-12'/%3E%3Ccircle cx='99' cy='70' r='14'/%3E %3Cpath d='M200 70a10 10 0 1 1-1-8'/%3E%3Cpath d='M60 110h.1M70 110h.1M80 110h.1'/%3E %3C/svg%3E");
+ --chat-bubble-in: #202c33;
+ --chat-bubble-out: #005c4b;
+ --chat-bubble-text: #e9edef;
+ --chat-meta: #9aa8b0;
+ --chat-meta-out: #c2d6cf;
+ --chat-accent-text: #1fbf95;
+ --chat-pill: #202c33;
+ --chat-pill-active-bg: #0a332c;
- --chat-pill-active-text: #00a884;
++ --chat-pill-active-text: #1fbf95;
+ --chat-link: #53bdeb;
++ --chat-link-out: #8fd4f4;
+ --chat-tick-read: #53bdeb;
+ --chat-icon: #aebac1;
+ --chat-shadow-bubble: 0 1px 0.5px rgba(11, 20, 26, 0.4);
+}
+
+/* System-dark twin: the default 'system' theme removes data-theme entirely, so the explicit rule above
+ never matches on a dark OS. :not([data-theme='light']) keeps an explicit light choice in control. */
+@media (prefers-color-scheme: dark) {
+ :root:not([data-theme='light']) .chats-page {
+ --chat-panel: #111b21;
+ --chat-panel-header: #202c33;
+ --chat-hover: #202c33;
+ --chat-active: #2a3942;
+ --chat-divider: #222d34;
+ --chat-wallpaper: #0b141a;
+ --chat-wallpaper-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' fill='none' stroke='rgba%28255,255,255,0.045%29' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E %3Cpath d='M22 30h40a8 8 0 0 1 8 8v20a8 8 0 0 1-8 8H38l-12 10v-10h-4a8 8 0 0 1-8-8V38a8 8 0 0 1 8-8z'/%3E %3Cpath d='M150 40c0-7 9-11 14-5 5-6 14-2 14 5 0 9-14 17-14 17s-14-8-14-17z'/%3E %3Cpath d='M205 120l5 11 12 2-9 8 2 12-10-6-10 6 2-12-9-8 12-2z'/%3E %3Crect x='30' y='150' width='40' height='30' rx='6'/%3E%3Ccircle cx='50' cy='165' r='8'/%3E%3Cpath d='M40 150l4-6h12l4 6'/%3E %3Cpath d='M120 130l46-18-18 46-8-20z'/%3E%3Cpath d='M140 138l8-8'/%3E %3Ccircle cx='120' cy='210' r='12'/%3E%3Cpath d='M114 214c2 3 10 3 12 0'/%3E%3Cpath d='M115 206h.1M125 206h.1'/%3E %3Cpath d='M190 200h30M190 210h20M184 192h42v28h-42z'/%3E %3Cpath d='M90 70l6 6 12-12'/%3E%3Ccircle cx='99' cy='70' r='14'/%3E %3Cpath d='M200 70a10 10 0 1 1-1-8'/%3E%3Cpath d='M60 110h.1M70 110h.1M80 110h.1'/%3E %3C/svg%3E");
+ --chat-bubble-in: #202c33;
+ --chat-bubble-out: #005c4b;
+ --chat-bubble-text: #e9edef;
+ --chat-meta: #9aa8b0;
+ --chat-meta-out: #c2d6cf;
+ --chat-accent-text: #1fbf95;
+ --chat-pill: #202c33;
+ --chat-pill-active-bg: #0a332c;
- --chat-pill-active-text: #00a884;
++ --chat-pill-active-text: #1fbf95;
+ --chat-link: #53bdeb;
++ --chat-link-out: #8fd4f4;
+ --chat-tick-read: #53bdeb;
+ --chat-icon: #aebac1;
+ --chat-shadow-bubble: 0 1px 0.5px rgba(11, 20, 26, 0.4);
+ }
+}
+
.chats-page .chats-layout {
display: flex;
flex: 1;
@@@ -126,528 -24,391 +129,522 @@@
SIDEBAR: Left Column
============================================================================= */
.chats-page .chats-sidebar {
- width: 320px;
- border-inline-end: 1px solid var(--border);
+ width: 380px;
+ min-width: 300px;
+ max-width: 40%;
display: flex;
flex-direction: column;
- background: var(--bg-white);
+ background: var(--chat-panel);
+ border-inline-end: 1px solid var(--chat-divider);
flex-shrink: 0;
+ min-height: 0;
}
-.chats-page .sidebar-header-box {
- padding: 1.25rem;
- border-bottom: 1px solid var(--border);
+.chats-page .sidebar-header {
+ height: 64px;
+ padding-block: 0;
+ padding-inline: 1rem 0.75rem;
display: flex;
- flex-direction: column;
- gap: 1rem;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.5rem;
+ border-bottom: 1px solid var(--chat-divider);
+ box-sizing: border-box;
+ flex-shrink: 0;
}
-.chats-page .session-select-group {
- display: flex;
- flex-direction: column;
- gap: 0.375rem;
+/* Session switcher: the selected account in the header, opening a searchable list of every session. */
+.chats-page .session-switcher {
+ position: relative;
+ min-width: 0;
}
-.chats-page .session-selector {
- width: 100%;
- padding: 0.625rem 0.75rem;
- border: 1px solid var(--border);
- border-radius: var(--radius, 8px);
- background-color: var(--bg-light);
+.chats-page .session-switcher-btn {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ max-width: 100%;
+ min-width: 0;
+ padding-block: 0.25rem;
+ padding-inline: 0.25rem 0.5rem;
+ margin-inline-start: -0.25rem;
+ background: transparent;
+ border: none;
+ border-radius: 12px;
color: var(--text-primary);
- font-size: 0.875rem;
- font-weight: 500;
- outline: none;
+ text-align: start;
cursor: pointer;
- transition: all 0.2s;
}
-.chats-page .session-selector:focus {
- border-color: var(--focus-ring);
- background-color: var(--bg-white);
- box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
+.chats-page .session-switcher-btn:hover {
+ background: var(--chat-hover);
}
-/* Chats / Channels / Status segmented control */
-.chats-page .chats-tabs {
- display: flex;
- gap: 4px;
- padding: 4px;
- background: var(--bg-light);
- border: 1px solid var(--border);
- border-radius: var(--radius, 8px);
+.chats-page .session-switcher-btn:focus-visible {
- outline: 2px solid var(--chat-accent);
++ outline: 2px solid var(--focus-ring);
+ outline-offset: 2px;
}
-.chats-page .chats-tab {
- flex: 1;
- padding: 6px 8px;
- border: none;
- border-radius: 6px;
- background: transparent;
- color: var(--text-secondary);
- cursor: pointer;
- font-size: 0.8125rem;
- transition:
- background 0.15s ease,
- color 0.15s ease;
+.chats-page .session-avatar {
+ position: relative;
+ width: 48px;
+ height: 48px;
+ border-radius: 50%;
+ background: color-mix(in srgb, var(--chat-accent) 12%, var(--chat-panel));
+ border: 1px solid color-mix(in srgb, var(--chat-accent) 25%, transparent);
+ color: var(--chat-accent);
+ font-weight: 600;
+ font-size: 1rem;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ box-sizing: border-box;
}
-.chats-page .chats-tab:hover {
- color: var(--text-primary);
+.chats-page .session-avatar.sm {
+ width: 44px;
+ height: 44px;
+ font-size: 0.9375rem;
}
-.chats-page .chats-tab.active {
- background: var(--bg-card);
- color: var(--text-primary);
- font-weight: 600;
- box-shadow: var(--shadow-sm, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
+.chats-page .session-avatar img {
+ width: 100%;
+ height: 100%;
+ border-radius: 50%;
+ object-fit: cover;
}
-.chats-page .chat-search-input {
- display: flex;
- align-items: center;
- gap: 0.5rem;
- padding: 0.625rem 0.75rem;
- background: var(--bg-light);
- border: 1px solid var(--border);
- border-radius: var(--radius, 8px);
+.chats-page .session-avatar.add {
+ border-style: solid;
}
-.chats-page .chat-search-input svg {
- color: var(--text-muted);
- flex-shrink: 0;
+.chats-page .session-status-dot {
+ position: absolute;
+ top: -1px;
+ inset-inline-end: -1px;
+ width: 12px;
+ height: 12px;
+ border-radius: 50%;
+ background: var(--success);
+ border: 2px solid var(--chat-panel);
}
-.chats-page .chat-search-input input {
- flex: 1;
- border: none;
- background: none;
- font-size: 0.875rem;
- color: var(--text-primary);
- outline: none;
+.chats-page .session-status-dot.pending {
+ background: var(--warning);
}
-.chats-page .chat-search-input:focus-within {
- border-color: var(--focus-ring);
- box-shadow: 0 0 0 3px var(--primary-soft);
+.chats-page .session-status-dot.down {
+ background: var(--error);
}
-.chats-page .chats-list {
- flex: 1;
- overflow-y: auto;
+.chats-page .session-text {
display: flex;
flex-direction: column;
+ min-width: 0;
+ line-height: 1.3;
}
-/* Custom Scrollbar for chats list */
-.chats-page .chats-list::-webkit-scrollbar,
-.chats-page .room-messages::-webkit-scrollbar {
- width: 6px;
+.chats-page .session-name {
+ font-size: 1rem;
+ font-weight: 500;
+ color: var(--text-primary);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
-.chats-page .chats-list::-webkit-scrollbar-thumb,
-.chats-page .room-messages::-webkit-scrollbar-thumb {
- background: var(--border);
- border-radius: 3px;
+.chats-page .session-phone {
+ font-size: 0.875rem;
+ color: var(--chat-meta);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
-.chats-page .chats-list::-webkit-scrollbar-track,
-.chats-page .room-messages::-webkit-scrollbar-track {
- background: transparent;
+.chats-page .session-flag {
+ margin-inline-end: 0.3em;
}
-.chats-page .chats-list-loading,
-.chats-page .chats-list-empty {
+.chats-page .session-chevron {
+ color: var(--chat-icon);
+ flex-shrink: 0;
+ margin-inline-start: 0.5rem;
+ transition: transform 0.15s;
+}
+
+.chats-page .session-chevron.open {
+ transform: rotate(180deg);
+}
+
+/* The open list */
+.chats-page .session-picker {
+ position: absolute;
+ top: calc(100% + 0.5rem);
+ inset-inline-start: -0.25rem;
+ z-index: 30;
+ width: min(360px, calc(100vw - 2rem));
display: flex;
flex-direction: column;
+ background: var(--chat-panel);
+ border: 1px solid var(--chat-divider);
+ border-radius: 14px;
+ box-shadow: var(--shadow-lg);
+ overflow: hidden;
+}
+
+.chats-page .session-picker-search {
+ display: flex;
align-items: center;
- justify-content: center;
- padding: 3rem 1.5rem;
- color: var(--text-muted);
- font-size: 0.875rem;
- gap: 0.5rem;
+ gap: 0.625rem;
+ padding-block: 0.875rem;
+ padding-inline: 1rem;
+ border-bottom: 1px solid var(--chat-divider);
+ color: var(--chat-meta);
}
-.chats-page .btn-secondary[aria-disabled='true'] {
- opacity: 0.6;
- cursor: progress;
++/* The field draws no outline of its own; the row underlines it instead. */
+.chats-page .session-picker-search:focus-within {
- color: var(--chat-accent);
++ color: var(--focus-ring);
++ box-shadow: inset 0 -2px 0 var(--focus-ring);
}
-.chats-page .chat-item-card {
+.chats-page .session-picker-search input {
+ flex: 1;
+ min-width: 0;
+ border: none;
+ background: none;
+ font-size: 1rem;
+ color: var(--text-primary);
+ outline: none;
+}
+
+.chats-page .session-picker-search input::placeholder {
+ color: var(--chat-meta);
+}
+
+.chats-page .session-picker-list {
+ margin: 0;
+ padding: 0.25rem;
+ list-style: none;
+ max-height: 360px;
+ overflow-y: auto;
+}
+
+.chats-page .session-picker-option,
+.chats-page .session-picker-add {
+ width: 100%;
display: flex;
align-items: center;
- gap: 0.75rem;
- padding: 1rem 1.25rem;
- border-bottom: 1px solid var(--border);
+ gap: 0.875rem;
+ padding-block: 0.625rem;
+ padding-inline: 0.75rem;
+ background: transparent;
+ border: none;
+ border-radius: 10px;
+ color: inherit;
+ font: inherit;
+ text-align: start;
+ text-decoration: none;
cursor: pointer;
- transition: background 0.15s ease;
- user-select: none;
+ box-sizing: border-box;
}
-.chats-page .chat-item-card:hover {
- background: var(--bg-light);
+.chats-page .session-picker-option:hover:not(:disabled),
+.chats-page .session-picker-option:focus-visible,
+.chats-page .session-picker-add:hover,
+.chats-page .session-picker-add:focus-visible {
+ background: var(--chat-hover);
}
-.chats-page .chat-item-card.active {
- background: rgba(34, 197, 94, 0.08);
+/* The hover tint alone is too faint to show keyboard focus (about 1.1:1 against the panel), so focus keeps a
+ ring, drawn inside so the scrolling list does not clip it. */
+.chats-page .session-picker-option:focus-visible,
+.chats-page .session-picker-add:focus-visible,
- .chats-page .chat-row-menu-popover button:focus-visible {
- outline: 2px solid var(--chat-accent);
++.chats-page .chat-row-menu-popover button:focus-visible,
++.chats-page .room-menu-popover button:focus-visible {
++ outline: 2px solid var(--focus-ring);
+ outline-offset: -2px;
}
-/* The muted gray is 4.44:1 on the active row's tint. */
-.chats-page .chat-item-card.active .chat-item-time,
-.chats-page .chat-item-card.active .chat-item-snippet {
- color: var(--text-secondary);
+.chats-page .session-picker-option:disabled {
+ cursor: not-allowed;
}
-.chats-page .chat-avatar {
- width: 44px;
- height: 44px;
- border-radius: 50%;
- background: var(--bg-light);
- border: 1px solid var(--border);
- display: flex;
- align-items: center;
- justify-content: center;
- color: var(--text-secondary);
+.chats-page .session-picker-option:disabled .session-name {
+ color: var(--chat-meta);
+}
+
+.chats-page .session-check {
+ margin-inline-start: auto;
+ color: var(--chat-accent);
flex-shrink: 0;
- overflow: hidden;
}
-.chats-page .chat-avatar img {
- width: 100%;
- height: 100%;
- object-fit: cover;
- display: block;
+.chats-page .session-picker-empty {
+ padding-block: 1rem;
+ padding-inline: 0.75rem;
+ color: var(--chat-meta);
+ font-size: 0.875rem;
+ text-align: center;
}
-.chats-page .chat-item-card.active .chat-avatar {
- background: var(--bg-white);
- color: var(--primary-text);
- border-color: rgba(34, 197, 94, 0.3);
+.chats-page .session-picker-add {
+ border-top: 1px solid var(--chat-divider);
+ border-radius: 0;
+ padding-block: 0.875rem;
+ padding-inline: 1rem;
}
-.chats-page .chat-item-info {
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 0.25rem;
- min-width: 0; /* Ensures text truncation works */
+.chats-page .session-picker-add .session-name {
+ font-weight: 600;
}
-.chats-page .chat-item-top {
- display: flex;
- justify-content: flex-start;
- align-items: baseline;
- gap: 6px;
+.chats-page .session-picker-add-chevron {
+ margin-inline-start: auto;
+ color: var(--chat-icon);
+ flex-shrink: 0;
}
-/* Text that is cut with an ellipsis takes its direction from its own characters (unicode-bidi: plaintext).
- Under an inherited direction the ellipsis eats the wrong end of a name written the other way round: a
- Latin name in an Arabic page lost its first letters and kept its last ("...hi Armyndharis").
- The same property aligns the text by its own direction, so a box that a flex column stretches across its
- width would put a Latin name at the left edge of an Arabic page while its siblings sit at the right. Those
- boxes hug the start edge instead (align-self: flex-start, capped by max-width so the ellipsis still shows). */
-.chats-page .chat-item-name {
- font-size: 0.9375rem;
- font-weight: 600;
- color: var(--text-primary);
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- unicode-bidi: plaintext;
+[dir='rtl'] .chats-page .session-picker-add-chevron {
+ transform: scaleX(-1);
}
-/* In the New chat list the name and the number are direct children of a stretched column; in the chat list
- they sit in rows that are as wide as their text, which needs nothing. */
-.chats-page .chat-item-info > .chat-item-name,
-.chats-page .chat-item-info > .chat-item-snippet {
- align-self: flex-start;
- max-width: 100%;
+.chats-page .sidebar-header-actions {
+ display: flex;
+ align-items: center;
+ gap: 0.125rem;
+ flex-shrink: 0;
}
-.chats-page .chat-item-time {
- font-size: 0.75rem;
- color: var(--text-muted);
+/* Full-text message search (collapsible). The input's own minimum would push the scope toggle out of a
+ narrow list. */
+.chats-page .sidebar-message-search {
+ padding-block: 0.75rem 0;
+ padding-inline: 1rem;
+}
+
+.chats-page .sidebar-message-search .global-search-input {
+ min-width: 0;
+}
+
+.chats-page .sidebar-header-box {
+ padding-block: 0.75rem 0;
+ padding-inline: 1rem;
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
flex-shrink: 0;
- margin-inline-start: auto;
}
-.chats-page .chat-item-bottom {
+/* Chats / Channels / Status segmented control */
+.chats-page .chats-tabs {
display: flex;
- justify-content: space-between;
- align-items: center;
+ gap: 4px;
+ padding: 4px;
+ background: var(--chat-panel-header);
+ border-radius: 10px;
}
-.chats-page .chat-item-snippet {
+.chats-page .chats-tab {
+ flex: 1;
+ padding: 6px 8px;
+ border: none;
+ border-radius: 7px;
+ background: transparent;
+ color: var(--chat-meta);
+ cursor: pointer;
font-size: 0.8125rem;
- color: var(--text-muted);
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- unicode-bidi: plaintext;
- max-width: 180px;
+ font-weight: 500;
+ transition:
+ background 0.15s ease,
+ color 0.15s ease;
}
-.chats-page .chat-item-snippet .no-message {
- font-style: italic;
+.chats-page .chats-tab:hover {
+ color: var(--text-primary);
}
-.chats-page .chat-unread-badge {
- display: inline-flex;
+.chats-page .chats-tab.active {
+ background: var(--chat-panel);
+ color: var(--text-primary);
+ font-weight: 600;
+ box-shadow: var(--chat-shadow-bubble);
+}
+
+/* Search box (sidebar and new-chat panel) */
+.chats-page .chat-search-input {
+ display: flex;
align-items: center;
- justify-content: center;
+ gap: 0.625rem;
+ padding-block: 0;
+ padding-inline: 0.875rem;
+ height: 40px;
+ background: var(--chat-panel);
+ border: 1px solid var(--chat-divider);
+ border-radius: 10px;
+ color: var(--chat-meta);
box-sizing: border-box;
- height: 20px;
- min-width: 20px;
- padding: 0 6px;
- background: var(--primary);
- color: #0f172a;
- font-size: 0.75rem;
- font-weight: 700;
- line-height: 1;
- border-radius: 999px;
- box-shadow: 0 2px 4px rgba(34, 197, 94, 0.3);
+ transition:
+ border-color 0.15s,
+ box-shadow 0.15s;
}
-.chats-page .chat-kind-badge {
- font-size: 0.7rem;
- padding: 0 6px;
- border-radius: 8px;
- border: 1px solid var(--border);
- color: var(--text-secondary);
- white-space: nowrap;
+.chats-page .chat-search-input svg {
+ flex-shrink: 0;
}
-/* =============================================================================
- CHAT ROOM: Right Column
- ============================================================================= */
-.chats-page .chats-room {
+.chats-page .chat-search-input:focus-within {
- border-color: var(--chat-accent);
++ border-color: var(--focus-ring);
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-accent) 15%, transparent);
+}
+
+.chats-page .chat-search-input input {
flex: 1;
min-width: 0;
- min-height: 0;
- display: flex;
- flex-direction: column;
- background: var(--bg-light);
+ border: none;
+ background: none;
+ font-size: 0.9375rem;
+ color: var(--text-primary);
+ outline: none;
}
-.chats-page .chats-room-placeholder {
- flex: 1;
+.chats-page .chat-search-input input::placeholder {
+ color: var(--chat-meta);
+}
+
- .chats-page .search-clear {
- display: flex;
- padding: 2px;
- background: none;
- border: none;
- border-radius: 50%;
- color: var(--chat-meta);
- cursor: pointer;
- }
-
- .chats-page .search-clear:hover {
- color: var(--text-primary);
- }
-
+/* Filter pills */
+.chats-page .chat-filters {
display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 3rem;
- text-align: center;
- color: var(--text-muted);
+ flex-wrap: wrap;
+ gap: 0.5rem;
+ padding-block: 0.75rem;
+ padding-inline: 1rem;
+ flex-shrink: 0;
}
-.chats-page .placeholder-icon {
- margin-bottom: 1.5rem;
- opacity: 0.3;
- color: var(--text-secondary);
+.chats-page .chat-filter-pill {
+ flex-shrink: 0;
+ padding-block: 0.375rem;
+ padding-inline: 0.875rem;
+ background: var(--chat-pill);
+ border: 1px solid var(--chat-divider);
+ border-radius: 999px;
+ font-size: 0.875rem;
+ font-weight: 500;
+ color: var(--chat-meta);
+ cursor: pointer;
+ transition:
+ background 0.15s,
+ color 0.15s,
+ border-color 0.15s;
}
-.chats-page .chats-room-placeholder h2 {
- font-size: 1.25rem;
- font-weight: 600;
- color: var(--text-primary);
- /* Reset the global h2 eyebrow treatment: this is an empty-state title, not a section label. */
- text-transform: none;
- letter-spacing: -0.01em;
- margin: 0 0 0.375rem;
+.chats-page .chat-filter-pill:hover {
+ background: var(--chat-hover);
}
-.chats-page .chats-room-placeholder p {
- font-size: 0.9375rem;
- max-width: 380px;
- margin: 0;
+.chats-page .chat-filter-pill.active {
+ background: var(--chat-pill-active-bg);
+ border-color: transparent;
+ color: var(--chat-pill-active-text);
}
-.chats-page .room-container {
+/* Lists */
+.chats-page .chats-list {
flex: 1;
min-height: 0;
+ overflow-y: auto;
display: flex;
flex-direction: column;
- height: 100%;
+ padding-block: 0 0.5rem;
+ padding-inline: 0.5rem;
}
-.chats-page .room-header {
- height: 70px;
- background: var(--bg-white);
- border-bottom: 1px solid var(--border);
- padding: 0 1.5rem;
+/* The Channels and Status tabs have no filter row; the list keeps its distance from the search box. */
+.chats-page .sidebar-header-box + .chats-list {
+ padding-block-start: 0.5rem;
+}
+
+.chats-page .chats-list::-webkit-scrollbar,
+.chats-page .room-messages::-webkit-scrollbar {
+ width: 6px;
+}
+
+.chats-page .chats-list::-webkit-scrollbar-thumb,
+.chats-page .room-messages::-webkit-scrollbar-thumb {
+ background: color-mix(in srgb, var(--chat-meta) 35%, transparent);
+ border-radius: 3px;
+}
+
+.chats-page .chats-list::-webkit-scrollbar-track,
+.chats-page .room-messages::-webkit-scrollbar-track {
+ background: transparent;
+}
+
+.chats-page .chats-list-loading,
+.chats-page .chats-list-empty {
display: flex;
+ flex-direction: column;
align-items: center;
- gap: 0.75rem;
- box-sizing: border-box;
+ justify-content: center;
+ padding: 3rem 1.5rem;
+ color: var(--chat-meta);
+ font-size: 0.875rem;
+ gap: 0.5rem;
+ text-align: center;
}
-/* Back-to-list control: only needed in the single-pane mobile layout; hidden on the two-pane desktop. */
-.chats-page .room-back {
- display: none;
++.chats-page .btn-secondary[aria-disabled='true'] {
++ opacity: 0.6;
++ cursor: progress;
++}
++
+.chats-page .chat-item-card {
+ display: flex;
align-items: center;
- justify-content: center;
- width: 36px;
- height: 36px;
- /* Reset the global `button` padding (0.6em 1.2em): with box-sizing:border-box it would consume
- the whole 36px width and collapse the arrow icon to 0px wide, making the button look empty. */
- padding: 0;
- margin-inline-start: -0.5rem;
+ gap: 0.875rem;
+ padding-block: 0.625rem;
+ padding-inline: 0.75rem;
+ border-radius: 10px;
+ cursor: pointer;
+ user-select: none;
+ transition: background 0.12s;
+}
+
+/* The new-chat panel's rows are buttons: they take the row's look, not the global button's. */
+.chats-page button.chat-item-card {
+ width: 100%;
background: transparent;
border: none;
- border-radius: 8px;
- color: var(--text-secondary);
- cursor: pointer;
- flex-shrink: 0;
+ color: inherit;
+ font: inherit;
+ text-align: start;
}
-.chats-page .room-back:hover {
- background: var(--bg-light);
- color: var(--text-primary);
+.chats-page .chat-item-card:hover {
+ background: var(--chat-hover);
}
-.chats-page .room-avatar {
- width: 40px;
- height: 40px;
+.chats-page .chat-item-card.active {
+ background: var(--chat-active);
+}
+
+.chats-page .chat-item-card:focus-visible {
- outline: 2px solid var(--chat-accent);
++ outline: 2px solid var(--focus-ring);
+ outline-offset: -2px;
+}
+
+.chats-page .chat-item-card:disabled {
+ cursor: progress;
+ opacity: 0.75;
+}
+
+/* Avatars */
+.chats-page .chat-avatar {
+ width: 52px;
+ height: 52px;
border-radius: 50%;
- background: var(--bg-light);
- border: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: center;
@@@ -724,1421 -428,1231 +721,1490 @@@
display: flex;
flex-direction: column;
gap: 0.125rem;
- min-width: 0;
+ min-width: 0; /* Ensures text truncation works */
+}
+
+.chats-page .chat-item-top,
+.chats-page .chat-item-bottom {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+}
+
+.chats-page .chat-item-bottom {
+ justify-content: space-between;
}
-.chats-page .room-contact-info h3 {
++/* Text that is cut with an ellipsis takes its direction from its own characters (unicode-bidi: plaintext).
++ Under an inherited direction the ellipsis eats the wrong end of a name written the other way round: a
++ Latin name in an Arabic page lost its first letters and kept its last ("...hi Armyndharis").
++ The same property aligns the text by its own direction, so a box that a flex column stretches across its
++ width would put a Latin name at the left edge of an Arabic page while its siblings sit at the right. Those
++ boxes hug the start edge instead (align-self: flex-start, capped by max-width so the ellipsis still shows). */
+.chats-page .chat-item-name {
font-size: 1rem;
font-weight: 600;
color: var(--text-primary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
+ unicode-bidi: plaintext;
++}
++
++/* In the New chat list the name and the number are direct children of a stretched column; in the chat list
++ they sit in rows that are as wide as their text, which needs nothing. */
++.chats-page .chat-item-info > .chat-item-name,
++.chats-page .chat-item-info > .chat-item-snippet {
+ align-self: flex-start;
+ max-width: 100%;
}
-/* Prettified phone (or "Group" / "Private contact" label for non-personal JIDs). Primary subtitle
- line directly under the name — what an operator reads first. */
-.chats-page .room-contact-phone {
+.chats-page .action-row .chat-item-name {
+ font-weight: 500;
+}
+
+.chats-page .chat-item-time {
font-size: 0.8125rem;
- color: var(--text-muted);
- line-height: 1.2;
- /* A number or the Group label: each takes its direction from its own text, so a phone keeps its digit
- order inside Arabic and Hebrew pages. A line of digits resolves to left to right, so the box hugs the
- start edge of the header (the right one in RTL, where the name is) instead of stretching across it. */
- unicode-bidi: plaintext;
- align-self: flex-start;
+ color: var(--chat-meta);
+ flex-shrink: 0;
+ margin-inline-start: auto;
}
-/* Raw JID preserved for technical use (lid resolution, webhook payloads, group ids). Muted mono,
- below the phone, truncated to keep the header compact — the full value is in the title tooltip. */
-.chats-page .room-contact-jid {
- font-size: 0.6875rem;
- color: var(--text-muted);
- font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
+.chats-page .chat-item-card.unread .chat-item-time {
+ color: var(--chat-accent-text);
+ font-weight: 600;
+}
+
+.chats-page .chat-item-snippet {
+ font-size: 0.875rem;
+ color: var(--chat-meta);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
+ unicode-bidi: plaintext;
- max-width: 100%;
- align-self: flex-start;
+ min-width: 0;
}
-.chats-page .room-messages {
- flex: 1;
- padding: 1.5rem;
- overflow-y: auto;
- /* Chrome/Firefox already adjust scrollTop on their own when content is prepended above the
- viewport (CSS scroll anchoring). The older-page handler applies its own correction for the
- same event, so leaving the browser's default on double-applies it. WebKit implements no
- scroll anchoring, so this is a no-op there and the manual correction is the only one that runs. */
- overflow-anchor: none;
- display: flex;
- flex-direction: column;
- gap: 0.75rem;
- background-image: radial-gradient(var(--border) 1px, transparent 0);
- background-size: 24px 24px;
- position: relative;
- /* The failure indicator's text is set against the width of the thread (the container query below), not the
- viewport: beside the list at an 890px viewport its client width is 244px, narrower than the 286px of a
- 320px phone. */
- container-type: inline-size;
+.chats-page .chat-item-snippet .no-message {
+ font-style: italic;
- opacity: 0.85;
}
-/* Floating scroll-to-bottom button. Sits at the bottom-right of the messages pane (not the footer)
- so it overlays the conversation without stealing input-bar space. It is the last child of the
- scroller and sticky, not absolute: an absolute child of the scroller moves with the content, so it
- sat at the bottom of the first screen of the thread, off screen whenever it was shown. In flow it
- would add its own height and one flex gap to the thread, which the negative margin takes back, so
- the scroll height is the same with and without it (the gap is the 0.75rem of .room-messages). The
- right edge is the scroller's padding, clear of the scrollbar. It sits below a bubble's actions menu
- (z-index 5), which it would otherwise cover: it is later in the DOM, and the Delete icon of a message
- near the bottom edge of the pane lies under it. */
-.chats-page .scroll-to-bottom-btn {
- position: sticky;
- bottom: 1rem;
- align-self: flex-end;
- flex: none;
- margin-top: calc(-40px - 0.75rem);
- z-index: 4;
- width: 40px;
- height: 40px;
- border-radius: 50%;
- display: flex;
+.chats-page .chat-unread-badge {
+ display: inline-flex;
align-items: center;
justify-content: center;
- background: var(--bg-white);
- color: var(--text-secondary);
- border: 1px solid var(--border);
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
- cursor: pointer;
- transition:
- background 0.15s,
- color 0.15s,
- transform 0.1s;
- padding: 0;
-}
-
-.chats-page .scroll-to-bottom-btn:hover {
- background: var(--bg-light);
- color: var(--primary-text);
- border-color: var(--primary);
+ box-sizing: border-box;
+ height: 20px;
+ min-width: 20px;
+ padding-block: 0;
+ padding-inline: 6px;
+ background: var(--chat-accent);
- color: #fff;
++ /* White is 3.03:1 on the accent green; the slate text is 5.89:1. */
++ color: #0f172a;
+ font-size: 0.75rem;
+ font-weight: 700;
+ line-height: 1;
+ border-radius: 999px;
+ flex-shrink: 0;
}
-.chats-page .scroll-to-bottom-btn:active {
- transform: scale(0.94);
+.chats-page .chat-kind-badge {
+ font-size: 0.7rem;
+ padding-block: 0;
+ padding-inline: 6px;
+ border-radius: 8px;
+ border: 1px solid var(--chat-divider);
+ color: var(--chat-meta);
+ white-space: nowrap;
+ flex-shrink: 0;
}
-.chats-page .messages-loading {
+.chats-page .status-compose-trigger {
display: flex;
- flex-direction: column;
align-items: center;
justify-content: center;
- flex: 1;
- color: var(--text-muted);
- font-size: 0.9375rem;
- gap: 0.75rem;
+ gap: 0.375rem;
+ width: 100%;
+ padding-block: 0.5rem;
+ padding-inline: 0.75rem;
+ font-size: 0.8125rem;
}
-/* The older-page indicator (ChatThread): a pill that holds to the top edge of the pane while a page loads,
- and the failure to load one. Neither takes room in the thread: a row in flow adds its height and one flex
- gap above the oldest bubble, which pushed the reader's content down by that much when the page was
- requested and back up when it landed. The loading pill's height is explicit, and its margins take it and
- the gap back (the gap is the 0.75rem of .room-messages), as the scroll-to-bottom button does, so the
- thread lays out the same with and without the row. The top margin lifts it into the 1.5rem of padding,
- clear of the first bubble when the thread is at its top, whatever its height; the bottom margin is what is
- left to add up to minus the gap. It never takes a pointer event from a bubble under it, and it must not
- take the flex remainder either. */
-.chats-page .messages-loading-older {
- --older-row-height: 1.25rem;
- position: sticky;
- /* Sticky offsets are measured from the scroller's padding edge: the 1.5rem of padding back out, less
- the 0.125rem the pill keeps from the pane's edge. */
- top: -1.375rem;
- z-index: 4;
- align-self: center;
- flex: none;
- box-sizing: border-box;
- display: flex;
+.chats-page .chats-tab {
+ display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.375rem;
- max-width: 100%;
- height: var(--older-row-height);
- margin-top: -1.375rem;
- margin-bottom: calc(0.625rem - var(--older-row-height));
- padding: 0 0.75rem;
- border: 1px solid var(--border);
- border-radius: 999px;
- background: var(--bg-white);
- box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
- color: var(--text-muted);
- font-size: 0.75rem;
- line-height: 1.25;
- pointer-events: none;
}
-.chats-page .messages-loading-older > svg {
- flex: none;
- width: 0.875rem;
- height: 0.875rem;
+/* Group rows: the chevron beside the time, shown on hover, on keyboard focus and while its list is open. Its
+ room is kept clear on every group row, so the time does not move when it appears. */
+.chats-page .chat-item-wrap {
+ position: relative;
}
-/* The text has to clip (the ellipsis, and the line limit of the failure, need overflow other than visible),
- and a line box is shorter than the glyphs of some scripts: the tails of g and p, Telugu conjuncts below the
- base, Arabic marks above and below the letters. The padding is the room the clip leaves them, and the
- negative margin takes it back, so the span lays out as the line it is. */
-.chats-page .messages-loading-older > span {
- min-width: 0;
- padding-block: 0.25em;
- padding-inline: 0.15em;
- margin-block: -0.25em;
- margin-inline: -0.15em;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
+.chats-page .chat-item-wrap.has-menu .chat-item-top {
+ padding-inline-end: 1.75rem;
}
-/* The failure carries the retry hint, so it wraps; its height is not known, and no margin can take it back. It
- is out of flow instead, so it takes no room at any height. It is not the reader's to carry through the
- thread: it stays at the top of the thread, where scrolling up again retries. Centred by its auto margins, as
- wide as its text up to the pane less its inset. It is held to two lines, which end inside the 1.5rem of
- padding and the top padding of the first bubble: a reader at the top of the thread is on that message, and a
- third line would run over its first line of text. Two lines hold the whole sentence of every translation
- in a thread wider than the container query below says; at that width or less only the retry instruction is
- shown. */
-.chats-page .messages-loading-older.failed {
+.chats-page .chat-row-menu {
position: absolute;
- top: 0.125rem;
- inset-inline: 0.25rem;
- width: max-content;
- max-width: calc(100% - 0.5rem);
- height: auto;
- min-height: var(--older-row-height);
- margin: 0 auto;
- padding: 0 0.5rem;
- border-radius: 0.875rem;
- font-size: 0.6875rem;
+ top: 0.5rem;
+ inset-inline-end: 0.5rem;
}
-.chats-page .messages-loading-older.failed > span {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow-wrap: anywhere;
- text-align: center;
- white-space: normal;
+.chats-page .chat-row-menu-trigger {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 26px;
+ height: 26px;
+ padding: 0;
+ border: 1px solid var(--chat-divider);
+ border-radius: 8px;
+ background: var(--chat-panel);
+ color: var(--chat-icon);
+ cursor: pointer;
+ opacity: 0;
+ transition: opacity 0.12s;
}
-.chats-page .messages-loading-older.failed > .older-failure-hint {
- display: none;
+.chats-page .chat-item-wrap:hover .chat-row-menu-trigger,
+.chats-page .chat-row-menu.open .chat-row-menu-trigger,
+.chats-page .chat-row-menu-trigger:focus-visible {
+ opacity: 1;
}
-/* In a thread of 17rem of content or less, two lines may not hold the whole sentence, and only the retry
- instruction is shown. The width queried is the content box of the thread: its client width, which leaves
- out a scrollbar, less the 1.5rem of padding on each side. 17rem of it is a client width of 320px. The
- longest sentence, the German one, needs 308px of client width for two lines in every engine. A 360px phone
- has 326px, and shows the sentence with an overlay scrollbar; a classic scrollbar of 6px leaves it 320px,
- and the instruction alone is shown. The instruction is two lines at most in the narrowest thread there is,
- 244px of client width beside the list at an 890px viewport (238px with a scrollbar of 6px). display: none
- takes the hidden text out of the accessibility tree as well, so what is read is what is shown. */
-@container (max-width: 17rem) {
- .chats-page .messages-loading-older.failed > .older-failure-full {
- display: none;
- }
+.chats-page .chat-row-menu-trigger:focus-visible {
- outline: 2px solid var(--chat-accent);
++ outline: 2px solid var(--focus-ring);
+ outline-offset: 1px;
+}
- .chats-page .messages-loading-older.failed > .older-failure-hint {
- display: -webkit-box;
++/* A touch screen has no hover to reveal the trigger, so it stays visible there. */
++@media (hover: none) {
++ .chats-page .chat-row-menu-trigger {
++ opacity: 1;
+ }
+ }
+
-/* The loading label is one line while the pill fits it: the longest translation, the French one, is 285px
- wide with its icon and padding, and 18rem of content box is 288px. At 18rem or less the label may wrap
- onto a second line, at the size of the failure text. The pill is 1.875rem high there instead of 1.25rem
- whether or not the label wraps: its margins take that back (see above), and the two lines end where the
- failure's do, above the first message's text. */
-@container (max-width: 18rem) {
- .chats-page .messages-loading-older:not(.failed) {
- --older-row-height: 1.875rem;
- font-size: 0.6875rem;
- }
-
- .chats-page .messages-loading-older:not(.failed) > span {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow-wrap: anywhere;
- text-align: center;
- white-space: normal;
- }
+.chats-page .chat-row-menu-popover {
+ position: absolute;
+ top: calc(100% + 0.375rem);
+ inset-inline-end: 0;
+ z-index: 30;
+ min-width: 240px;
+ padding: 0.375rem;
+ display: flex;
+ flex-direction: column;
+ background: var(--chat-panel);
+ border: 1px solid var(--chat-divider);
+ border-radius: 14px;
+ box-shadow: var(--shadow-lg);
}
-.chats-page .messages-empty {
+.chats-page .chat-row-menu-popover button {
display: flex;
- flex-direction: column;
align-items: center;
- justify-content: center;
- flex: 1;
- color: var(--text-muted);
+ gap: 0.875rem;
+ padding-block: 0.625rem;
+ padding-inline: 0.75rem;
+ background: transparent;
+ border: none;
+ border-radius: 10px;
font-size: 0.9375rem;
- gap: 0.75rem;
- text-align: center;
- padding: 2rem;
+ color: var(--text-primary);
+ text-align: start;
+ white-space: nowrap;
+ cursor: pointer;
}
-.chats-page .message-bubble-wrapper {
- display: flex;
- width: 100%;
+.chats-page .chat-row-menu-popover button:hover,
+.chats-page .chat-row-menu-popover button:focus-visible {
+ background: var(--chat-hover);
}
-.chats-page .message-bubble-wrapper.incoming {
- justify-content: flex-start;
+.chats-page .chat-row-menu-group {
+ display: flex;
+ flex-direction: column;
}
-.chats-page .message-bubble-wrapper.outgoing {
- justify-content: flex-end;
+.chats-page .chat-action-label {
+ display: flex;
+ flex-direction: column;
+ white-space: normal;
}
-.chats-page .message-bubble {
- max-width: 100%;
- padding: 0.625rem 0.875rem 0.375rem;
- border-radius: 12px;
- font-size: 0.9375rem;
- line-height: 1.4;
- position: relative;
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
+.chats-page .chat-action-label small {
+ max-width: 16rem;
+ font-size: 0.75rem;
+ color: var(--chat-meta);
}
-.chats-page .message-bubble.incoming {
- background: var(--bg-white);
- color: var(--text-primary);
- border-end-start-radius: 2px;
- border: 1px solid var(--border);
+.chats-page .chat-row-menu-popover button:disabled,
+.chats-page .room-menu-popover button:disabled {
+ cursor: not-allowed;
+ opacity: 0.6;
}
-.chats-page .message-bubble.outgoing {
- background: #d9fdd3; /* Soft WhatsApp Green */
- color: #111b21;
- border-end-end-radius: 2px;
+.chats-page .chat-row-menu-popover button:disabled:hover,
+.chats-page .room-menu-popover button:disabled:hover {
+ background: transparent;
}
-/* Dark theme outgoing chat bubble override */
-[data-theme='dark'] .chats-page .message-bubble.outgoing {
- background: #005c4b; /* Dark WhatsApp Green */
- color: #e9edef;
+.chats-page .chat-row-menu-popover hr {
+ width: 100%;
+ margin-block: 0.25rem;
+ border: none;
+ border-top: 1px solid var(--chat-divider);
}
-/* System-dark twin: the default 'system' theme removes data-theme entirely, so the explicit rule
- above never matches on a dark OS. :not([data-theme='light']) keeps an explicit light choice in
- control (same pattern as Webhooks.css). */
-@media (prefers-color-scheme: dark) {
- :root:not([data-theme='light']) .chats-page .message-bubble.outgoing {
- background: #005c4b;
- color: #e9edef;
- }
+/* Leave-group confirmation: the confirm-modal shape the Sessions page uses. */
+.chats-page .confirm-modal {
+ max-width: 420px;
}
-.chats-page .message-text {
- word-break: break-word;
- white-space: pre-wrap;
+.chats-page .confirm-modal .modal-body p {
+ margin: 0 0 0.5rem;
}
-/* Group sender label: the poster's name atop an incoming group bubble (colour set inline per sender). */
-.chats-page .message-sender {
- font-size: 0.78rem;
- font-weight: 600;
- line-height: 1.2;
- margin-bottom: 0.15rem;
- word-break: break-word;
+.chats-page .confirm-modal .text-muted {
+ color: var(--text-muted);
+ font-size: 0.875rem;
}
-.chats-page .message-meta {
- display: flex;
+.chats-page .chat-item-flags {
+ display: inline-flex;
align-items: center;
- justify-content: flex-end;
gap: 0.25rem;
- margin-top: 0.25rem;
-}
-
-.chats-page .message-edited,
-.chats-page .message-time {
- font-size: 0.6875rem;
- color: var(--text-muted);
+ color: var(--chat-meta);
+ flex-shrink: 0;
+ margin-inline-start: auto;
}
-/* On an outgoing bubble the muted gray was 4.29:1 on the light green and 3.11:1 on the dark one. */
-.chats-page .message-bubble.outgoing .message-edited,
-.chats-page .message-bubble.outgoing .message-time {
- color: var(--text-secondary);
+.chats-page .chat-item-flags + .chat-unread-badge {
+ margin-inline-start: 0.25rem;
}
-/* A styled status bubble sets its own inline background + white text; let its timestamp inherit
- instead of staying the muted gray meant for the default bubble. */
-.chats-page .message-bubble[style] .message-edited,
-.chats-page .message-bubble[style] .message-time {
- color: inherit;
- opacity: 0.75;
+/* The archive's entry at the head of the chat list, and the way back from its view. */
+.chats-page .chat-archive-entry {
+ display: flex;
+ align-items: center;
+ gap: 1.25rem;
+ width: 100%;
+ padding-block: 0.75rem;
+ padding-inline: 1.5rem 0.75rem;
+ background: transparent;
+ border: none;
+ border-radius: 10px;
+ color: var(--text-primary);
+ font: inherit;
+ font-weight: 500;
+ text-align: start;
+ cursor: pointer;
}
-.chats-page .message-status-icon {
- font-size: 0.75rem;
+.chats-page .chat-archive-entry svg {
+ color: var(--chat-accent);
}
-.chats-page .message-status-icon.read {
- /* The WhatsApp blue is 2.13:1 on the outgoing bubble, and these checks are TEXT, not an icon.
- Darkened to clear 4.5:1 there (4.62:1) and on white; the status is also spelled out in aria-label/title,
- since delivered and read otherwise differ only by this colour. */
- color: #337592;
+.chats-page .chat-archive-entry:hover {
+ background: var(--chat-hover);
}
-/* That blue is for the light bubble (4.62:1 on it, 1.56:1 on the dark green one). On the dark bubble the read tick
- takes --read-tick, 4.78:1 there where --info is 3.14:1; the status is also spelled out in aria-label/title. */
-[data-theme='dark'] .chats-page .message-status-icon.read {
- color: var(--read-tick);
+.chats-page .chat-archive-count {
+ margin-inline-start: auto;
+ font-size: 0.8125rem;
+ font-weight: 600;
+ color: var(--chat-accent);
}
-@media (prefers-color-scheme: dark) {
- :root:not([data-theme='light']) .chats-page .message-status-icon.read {
- color: var(--read-tick);
- }
+/* The room's menu lists the row's actions too: its groups stack, and dividers part them. */
+.chats-page .room-menu-group {
+ display: flex;
+ flex-direction: column;
}
-/* =============================================================================
- INPUT BAR: Bottom Footer
- ============================================================================= */
-.chats-page .room-input-footer {
- background: var(--bg-white);
- border-top: 1px solid var(--border);
- padding: 1rem 1.5rem;
- box-sizing: border-box;
+.chats-page .room-menu-popover hr {
+ width: 100%;
+ margin-block: 0.25rem;
+ border: none;
+ border-top: 1px solid var(--chat-divider);
}
-.chats-page .input-form {
+/* Mute and save-contact dialogs (confirm-modal cards). */
+.chats-page .chat-dialog-options {
display: flex;
+ flex-direction: column;
gap: 0.75rem;
- align-items: center;
-}
-
-.chats-page .message-text-input {
- flex: 1;
- /* An input keeps its intrinsic width as its automatic minimum, which pinned the whole composer to
- 369px and pushed the send button outside the layout's clip. The floor replaces that with one small
- enough to let the composer fit a narrow pane and large enough to keep a caret and a few characters
- visible; without it the box shrinks to its own padding and shows nothing at all. */
- min-width: 64px;
- padding: 0.75rem 1rem;
- border: 1px solid var(--border);
- border-radius: 24px;
- font-size: 0.9375rem;
- background: var(--bg-light);
- color: var(--text-primary);
- outline: none;
- transition: all 0.2s;
- box-sizing: border-box;
-}
-
-.chats-page .message-text-input:focus {
- border-color: var(--focus-ring);
- background: var(--bg-white);
- box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
+ margin: 0.75rem 0 0;
+ padding: 0;
+ border: none;
}
-.chats-page .btn-send-message {
+.chats-page .chat-dialog-options label {
display: flex;
align-items: center;
- justify-content: center;
- width: 48px;
- height: 48px;
- background: var(--primary);
- border: none;
- border-radius: 50%;
- color: #0f172a;
+ gap: 0.75rem;
+ font-size: 0.9375rem;
+ color: var(--text-primary);
cursor: pointer;
- transition:
- background 0.2s,
- transform 0.1s;
- flex-shrink: 0;
- box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}
-.chats-page .btn-send-message:hover:not(:disabled) {
- background: var(--primary-hover);
- transform: scale(1.05);
+.chats-page .chat-dialog-options input {
+ accent-color: var(--chat-accent);
+ width: 18px;
+ height: 18px;
}
-.chats-page .btn-send-message:disabled {
- /* Keep the brand silhouette readable while clearly inactive — a bare gray-on-gray glyph
- reads as "no button here" rather than "send, disabled". */
- background: var(--primary);
- color: #0f172a;
- opacity: 0.55;
- cursor: not-allowed;
- box-shadow: none;
+.chats-page .chat-dialog-form {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
}
-/* =============================================================================
- GENERAL CHATS STYLES & ERROR STATES
- ============================================================================= */
-.chats-page .chats-loading-container,
-.chats-page .chats-error-state {
+.chats-page .chat-dialog-form label {
display: flex;
flex-direction: column;
- align-items: center;
- justify-content: center;
- background: var(--bg-white);
- border: 1px solid var(--border);
- border-radius: 16px;
- padding: 4rem 2rem;
- margin-top: 1rem;
- text-align: center;
- color: var(--text-secondary);
- box-shadow: var(--shadow-sm);
- flex: 1;
+ gap: 0.375rem;
+ font-size: 0.875rem;
+ font-weight: 600;
+ color: var(--text-primary);
}
-.chats-page .chats-error-state h3 {
- font-size: 1.25rem;
- margin: 1rem 0 0.5rem;
+.chats-page .chat-dialog-form input {
+ padding-block: 0.625rem;
+ padding-inline: 0.875rem;
+ border: 1px solid var(--chat-divider);
+ border-radius: 10px;
+ background: var(--chat-panel-header);
color: var(--text-primary);
+ font: inherit;
+ font-weight: 400;
+ outline: none;
}
-.chats-page .chats-error-state p {
- font-size: 0.9375rem;
- max-width: 450px;
+.chats-page .chat-dialog-form input:focus {
- border-color: var(--chat-accent);
++ border-color: var(--focus-ring);
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-accent) 15%, transparent);
+}
+
+.chats-page .chat-dialog-form .text-muted {
margin: 0;
- color: var(--text-muted);
+ font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
+ font-size: 0.8125rem;
}
-.chats-page .chats-error-state button {
- margin-top: 1.5rem;
+/* =============================================================================
+ GROUP INFO DIALOG (the global .modal card, inside the page)
+ ============================================================================= */
+.chats-page .group-info-modal {
+ max-width: 680px;
}
-.chats-page .text-warn {
- color: var(--warning-text);
+.chats-page .group-info-title {
+ display: flex;
+ align-items: center;
+ gap: 1rem;
}
-/* Real-time connection-lost banner */
-.chats-page .chats-reconnect-banner {
+.chats-page .group-info-tile {
+ width: 52px;
+ height: 52px;
+ border-radius: 14px;
+ background: linear-gradient(135deg, #5fd17b, var(--chat-accent));
+ color: #fff;
display: flex;
align-items: center;
- gap: 0.5rem;
- padding: 0.5rem 0.75rem;
- margin-bottom: 0.75rem;
- border-radius: 6px;
- background: rgba(234, 88, 12, 0.1);
- color: var(--warning-text);
- font-size: 0.875rem;
+ justify-content: center;
+ flex-shrink: 0;
}
-.chats-page .chats-reconnect-banner button {
- margin-inline-start: auto;
+.chats-page .group-info-heading {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
}
-/* =============================================================================
- ATTACHMENT PREVIEW & EMOJI PICKER
- ============================================================================= */
-.chats-page .btn-input-accessory {
- background: transparent;
- border: none;
- color: var(--text-secondary);
- cursor: pointer;
- padding: 0.5rem;
- border-radius: 50%;
+.chats-page .group-info-subtitle {
+ font-size: 1rem;
+ font-weight: 400;
+ color: var(--chat-meta);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.chats-page .group-info-toolbar {
display: flex;
align-items: center;
- justify-content: center;
- transition: all 0.2s ease;
- flex-shrink: 0;
+ gap: 0.75rem;
+ flex-wrap: wrap;
+ padding-block: 1rem 0;
+ padding-inline: 1.5rem;
}
-.chats-page .btn-input-accessory:hover {
- background: var(--bg-light);
- color: var(--text-primary);
+.chats-page .group-info-toolbar .chats-tabs {
+ flex: none;
}
-.chats-page .btn-input-accessory.active {
- background: rgba(34, 197, 94, 0.1);
- color: var(--primary-text);
+.chats-page .group-info-toolbar .chats-tab {
+ padding-block: 0.5rem;
+ padding-inline: 0.875rem;
+ font-size: 0.9375rem;
}
-.chats-page .attachment-preview-banner {
- background: var(--bg-white);
- border-top: 1px solid var(--border);
- padding: 0.75rem 1.5rem;
- display: flex;
+.chats-page .group-info-toolbar .icon-btn {
+ margin-inline-start: auto;
+}
+
+.chats-page .group-info-badge {
+ display: inline-flex;
align-items: center;
- gap: 1rem;
- box-sizing: border-box;
+ gap: 0.5rem;
+ padding-block: 0.5rem;
+ padding-inline: 0.875rem;
+ border-radius: 10px;
+ border: 1px solid var(--chat-divider);
+ background: var(--chat-panel-header);
+ color: var(--chat-meta);
+ font-size: 0.9375rem;
}
-.chats-page .preview-thumbnail {
- width: 48px;
- height: 48px;
- object-fit: cover;
- border-radius: 6px;
- border: 1px solid var(--border);
+.chats-page .group-info-badge.admin {
+ border-color: color-mix(in srgb, var(--chat-accent) 35%, transparent);
+ background: color-mix(in srgb, var(--chat-accent) 10%, var(--chat-panel));
+ color: var(--chat-pill-active-text);
}
-.chats-page .preview-file-icon {
- width: 48px;
- height: 48px;
- background: var(--bg-light);
- border: 1px solid var(--border);
- border-radius: 6px;
+.chats-page .group-info-state {
display: flex;
- align-items: center;
justify-content: center;
- font-size: 1.5rem;
+ padding: 2rem;
+ color: var(--chat-meta);
}
-.chats-page .preview-file-info {
- flex: 1;
+.chats-page .group-info-form {
display: flex;
flex-direction: column;
- min-width: 0;
+ gap: 1.25rem;
}
-.chats-page .preview-filename {
- font-size: 0.875rem;
+.chats-page .group-info-field {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ font-size: 1rem;
font-weight: 600;
color: var(--text-primary);
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- unicode-bidi: plaintext;
- align-self: flex-start;
- max-width: 100%;
}
-.chats-page .preview-filesize {
- font-size: 0.75rem;
- color: var(--text-muted);
+.chats-page .group-info-field .required {
- color: var(--error);
++ color: var(--error-text);
}
-.chats-page .btn-remove-attachment {
- background: transparent;
- border: none;
- color: var(--text-muted);
- cursor: pointer;
- padding: 0.375rem;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- transition: all 0.2s;
+.chats-page .group-info-field input,
+.chats-page .group-info-field textarea,
+.chats-page .group-info-add input {
+ width: 100%;
+ box-sizing: border-box;
+ padding-block: 0.75rem;
+ padding-inline: 1rem;
+ border: 1px solid var(--chat-divider);
+ border-radius: 10px;
+ background: var(--chat-panel-header);
+ color: var(--text-primary);
+ font: inherit;
+ font-weight: 400;
+ outline: none;
}
-.chats-page .btn-remove-attachment:hover {
- background: rgba(239, 68, 68, 0.12);
- color: var(--error-text);
+.chats-page .group-info-field textarea {
+ resize: vertical;
+ min-height: 7rem;
}
-.chats-page .chats-emoji-picker {
- background: var(--bg-white);
- border-top: 1px solid var(--border);
- padding: 0.75rem 1.5rem;
- box-sizing: border-box;
- max-height: 120px;
- overflow-y: auto;
+.chats-page .group-info-field input:focus,
+.chats-page .group-info-field textarea:focus,
+.chats-page .group-info-add input:focus {
- border-color: var(--chat-accent);
++ border-color: var(--focus-ring);
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-accent) 15%, transparent);
}
-.chats-page .emoji-grid {
- display: flex;
- flex-wrap: wrap;
- gap: 0.5rem;
+.chats-page .group-info-field input:disabled,
+.chats-page .group-info-field textarea:disabled {
+ opacity: 0.7;
+ cursor: not-allowed;
}
-.chats-page .emoji-btn {
- background: transparent;
- border: none;
- font-size: 1.25rem;
- padding: 0.375rem;
- border-radius: 6px;
- cursor: pointer;
- transition: all 0.15s;
+.chats-page .group-info-picture {
display: flex;
align-items: center;
- justify-content: center;
+ gap: 1.25rem;
+ padding: 1rem;
+ border: 1px solid var(--chat-divider);
+ border-radius: 12px;
+ background: var(--chat-panel-header);
+ color: var(--text-primary);
+ font: inherit;
+ font-weight: 400;
+ text-align: start;
+ cursor: pointer;
}
-.chats-page .emoji-btn:hover {
- background: var(--bg-light);
+.chats-page .group-info-picture:hover:not(:disabled) {
+ border-color: var(--chat-accent);
}
-.chats-page .message-bubble.media-type {
- border-start-start-radius: 12px;
- border-start-end-radius: 12px;
+.chats-page .group-info-picture:disabled {
+ cursor: default;
}
-/* =============================================================================
- RESPONSIVENESS
- ============================================================================= */
-@media (max-width: 768px) {
- .chats-page {
- padding: 1rem;
- height: calc(100dvh - 3.5rem);
- }
-
- .chats-page .chats-layout {
- flex-direction: column;
- height: calc(100vh - 7rem);
- }
-
- /* Single-pane on mobile: the list and the open conversation each take the full panel
- instead of being squeezed into one short stacked column. */
- .chats-page .chats-sidebar {
- width: 100%;
- height: 100%;
- border-inline-end: none;
- }
+.chats-page .group-info-picture .chat-avatar {
+ width: 96px;
+ height: 96px;
+ background: var(--chat-panel);
+ border: 1px solid var(--chat-divider);
+}
- .chats-page .chats-room {
- height: 100%;
- }
+.chats-page .group-info-members {
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+}
- /* Opening a chat replaces the list with the thread; the back button returns to the list. */
- .chats-page .chats-layout.has-active-chat .chats-sidebar {
- display: none;
- }
+.chats-page .group-info-add {
+ display: flex;
+ gap: 0.5rem;
+}
- .chats-page .chats-layout:not(.has-active-chat) .chats-room {
- display: none;
- }
+.chats-page .group-info-add button {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.375rem;
+ flex-shrink: 0;
+}
- .chats-page .room-back {
- display: inline-flex;
- }
+.chats-page .group-info-count {
+ font-size: 0.875rem;
+ font-weight: 600;
+ color: var(--chat-meta);
+}
- .chats-page .room-header {
- height: 60px;
- }
+.chats-page .group-info-list {
+ margin: 0;
+ padding: 0;
+ list-style: none;
}
-/* Between the mobile breakpoint and 889px the two-pane layout leaves the room narrower than the
- composer's 244px minimum, so the send button fell outside the panel's clip with no scrollbar to
- recover it. In that band the panes swap one at a time instead, the way they already do on a phone.
- Bounded on both sides on purpose: at 768px and below the mobile shell owns the layout, and from 890px
- the room fits the composer again. The room is `viewport - 646`, so the bound is 646 + 244 - 1; it
- moves if the composer's own minimum does. Keyed to the navigation as well as the viewport, because
- that arithmetic only holds while the nav is expanded; collapsed it already fits and none of this
- should apply. `.main-content.expanded` is Layout's class for the COLLAPSED nav. */
-@media (min-width: 769px) and (max-width: 889px) {
- .main-content:not(.expanded) .chats-page .chats-layout {
- flex-direction: column;
- }
+.chats-page .group-info-list li {
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ padding-block: 0.5rem;
+ border-bottom: 1px solid var(--chat-divider);
+}
- .main-content:not(.expanded) .chats-page .chats-sidebar {
- width: 100%;
- height: 100%;
- border-inline-end: none;
- }
+.chats-page .group-info-member {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ flex: 1;
+}
- .main-content:not(.expanded) .chats-page .chats-layout.has-active-chat .chats-sidebar {
- display: none;
- }
+.chats-page .group-info-member .name {
+ font-weight: 500;
+ color: var(--text-primary);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
++ unicode-bidi: plaintext;
+}
- .main-content:not(.expanded) .chats-page .chats-layout:not(.has-active-chat) .chats-room {
- display: none;
- }
+.chats-page .group-info-member .number {
+ font-size: 0.8125rem;
+ color: var(--chat-meta);
+}
- .main-content:not(.expanded) .chats-page .room-back {
- display: inline-flex;
- }
+.chats-page .group-info-role {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.25rem;
+ padding-block: 0.125rem;
+ padding-inline: 0.5rem;
+ border-radius: 999px;
+ background: var(--chat-pill-active-bg);
+ color: var(--chat-pill-active-text);
+ font-size: 0.75rem;
+ font-weight: 600;
+ flex-shrink: 0;
+}
+
+.chats-page .group-info-actions {
+ display: flex;
+ gap: 0.125rem;
+ flex-shrink: 0;
+}
+
+.chats-page .icon-btn.danger:hover {
+ color: var(--error-text);
+ background: rgba(239, 68, 68, 0.12);
}
/* =============================================================================
- MEDIA RENDERING STYLES
+ NEW CHAT / NEW GROUP PANEL (sidebar sub-view)
============================================================================= */
-.chats-page .chat-image-media {
- max-width: 100%;
- max-height: 250px;
- border-radius: 8px;
- display: block;
- margin-bottom: 0.5rem;
- cursor: pointer;
- object-fit: cover;
+.chats-page .new-chat-panel {
+ flex: 1;
+ min-height: 0;
+ display: flex;
+ flex-direction: column;
}
-/* An archived preview swaps a 14px spinner (plus .25rem of margin) for an image that has no box until it
- decodes. Holding that box at the difference to the image's own .5rem of margin keeps the swap from
- shortening the thread: a shorter thread clamps a scroll position pinned to the bottom, and the clamp
- reaches the scroll hook as the reader scrolling away. It also makes the box the hook seeds at mount
- exactly what the thread gains once the image decodes. */
-.chats-page .chat-image-media-archived {
- min-height: calc(14px - 0.25rem);
+.chats-page .new-chat-header {
+ height: 64px;
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ padding-block: 0;
+ padding-inline: 0.75rem;
+ border-bottom: 1px solid var(--chat-divider);
+ font-size: 1rem;
+ font-weight: 600;
+ color: var(--text-primary);
+ box-sizing: border-box;
+ flex-shrink: 0;
}
-/* A button, not a label: the bytes are fetchable from the per-message media route, so this is the
- viewer's handle on media the list did not inline. Styled to keep the previous inert appearance
- apart from the affordance. */
-.chats-page .message-media-omitted {
+.chats-page .new-chat-search {
+ margin-block: 0.75rem 0;
+ margin-inline: 1rem;
+ flex-shrink: 0;
+}
+
++/* The clear button at the end of a search field: a small icon button whose block margin keeps it inside the
++ height of the line, so the field does not grow when it appears. */
++.chats-page .search-clear {
+ display: flex;
+ align-items: center;
- gap: 0.3rem;
++ justify-content: center;
++ width: 28px;
++ height: 28px;
++ margin-block: -0.5rem;
+ padding: 0;
+ border: none;
- background: none;
- color: var(--text-muted);
- font-style: italic;
- font-size: 0.9em;
- font-family: inherit;
- margin-bottom: 0.25rem;
++ border-radius: 50%;
++ background: transparent;
++ color: var(--chat-meta);
+ cursor: pointer;
- text-decoration: underline dotted;
++ flex-shrink: 0;
+ }
+
-.chats-page .message-media-omitted:disabled {
- cursor: default;
- text-decoration: none;
++.chats-page .search-clear:hover {
++ background: var(--chat-hover);
++ color: var(--text-primary);
+ }
+
-/* The archived audio and video placeholders hold the height of the element that replaces them, so the
- bubble does not grow when the bytes land and move a thread that was pinned to the bottom or being read.
- The element's own bottom margin is 0.5rem and the placeholder's 0.25rem, so the quarter rem that is
- missing from the margin is added to the box: a native audio player is 54px tall, and a video element
- that has no metadata yet has the default 150px replaced-element height. */
-.chats-page .message-media-archived-loading-audio {
- min-height: calc(54px + 0.25rem);
++.chats-page .search-clear:focus-visible {
++ outline: 2px solid var(--focus-ring);
++ outline-offset: 1px;
+ }
+
-.chats-page .message-media-archived-loading-video {
- min-height: calc(150px + 0.25rem);
+.chats-page .new-chat-hint {
+ margin-block: 0.375rem 0;
+ margin-inline: 1rem;
+ font-size: 0.8125rem;
+ color: var(--chat-meta);
}
-/* The map preview keeps its own modest cap, but bounded by the bubble the way every other media type
- here is. As a bare pixel width it stayed 220px wide in a narrower room and ran past the panel edge. */
-.chats-page .chat-location-media {
- max-width: min(220px, 100%);
- border-radius: 8px;
- display: block;
- margin-bottom: 0.25rem;
+.chats-page .new-chat-list {
+ padding-block-start: 0.5rem;
}
-.chats-page .chat-video-media {
- max-width: 100%;
- max-height: 250px;
- border-radius: 8px;
- display: block;
- margin-bottom: 0.5rem;
+.chats-page .new-chat-section-label {
+ padding-block: 0.875rem 0.375rem;
+ padding-inline: 0.75rem;
+ font-size: 0.8125rem;
+ font-weight: 600;
+ color: var(--chat-accent);
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
}
-.chats-page .chat-audio-media {
- max-width: 100%;
- display: block;
- margin-bottom: 0.5rem;
+.chats-page .select-check {
+ width: 22px;
+ height: 22px;
+ box-sizing: border-box;
+ border-radius: 6px;
+ border: 2px solid color-mix(in srgb, var(--chat-meta) 60%, transparent);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ color: #fff;
}
-.chats-page .chat-document-media {
+.chats-page .select-check.checked {
+ background: var(--chat-accent);
+ border-color: var(--chat-accent);
+}
+
+.chats-page .new-group-fields {
+ display: flex;
+ flex-direction: column;
+ gap: 0.625rem;
+ padding-block: 0.875rem 0;
+ padding-inline: 1rem;
+ flex-shrink: 0;
+}
+
+.chats-page .new-group-name {
+ height: 42px;
+ padding-block: 0;
+ padding-inline: 0.875rem;
+ border: none;
- border-bottom: 2px solid var(--chat-accent);
++ border-bottom: 2px solid var(--chat-divider);
+ background: transparent;
+ font-size: 1rem;
+ color: var(--text-primary);
+ outline: none;
+}
+
++.chats-page .new-group-name:focus {
++ border-bottom-color: var(--focus-ring);
++}
++
+.chats-page .new-group-name::placeholder {
+ color: var(--chat-meta);
+}
+
+.chats-page .participant-chips {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.375rem;
+ max-height: 96px;
+ overflow-y: auto;
+}
+
+.chats-page .participant-chip {
display: inline-flex;
align-items: center;
- gap: 0.5rem;
- padding: 0.5rem 0.75rem;
- background: var(--bg-light);
- border: 1px solid var(--border);
- border-radius: 6px;
+ gap: 0.25rem;
+ padding-block: 0.25rem;
+ padding-inline: 0.75rem 0.25rem;
+ background: var(--chat-active);
+ border-radius: 999px;
+ font-size: 0.8125rem;
color: var(--text-primary);
- text-decoration: none;
- font-size: 0.875rem;
- font-weight: 500;
- margin-bottom: 0.5rem;
- transition: all 0.2s;
- word-break: break-all;
}
-.chats-page .chat-document-media:hover {
- background: var(--border);
+.chats-page .participant-chip button {
+ display: flex;
+ padding: 2px;
+ background: transparent;
+ border: none;
+ border-radius: 50%;
+ color: var(--chat-meta);
+ cursor: pointer;
}
-[data-theme='dark'] .chats-page .chat-document-media {
- background: #202c33;
- border-color: #2f3b43;
+.chats-page .participant-chip button:hover {
+ background: color-mix(in srgb, var(--chat-icon) 14%, transparent);
}
-@media (prefers-color-scheme: dark) {
- :root:not([data-theme='light']) .chats-page .chat-document-media {
- background: #202c33;
- border-color: #2f3b43;
- }
+.chats-page .new-group-footer {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 0.75rem;
+ padding-block: 0.75rem;
+ padding-inline: 1rem;
+ border-top: 1px solid var(--chat-divider);
+ flex-shrink: 0;
}
-.chats-page .message-bubble.media-type {
- padding: 0.5rem;
+.chats-page .new-group-count {
+ font-size: 0.875rem;
+ color: var(--chat-meta);
}
-/* =============================================================================
- HOVER MENU, REPLIES, REACTIONS, AND DELETIONS
- ============================================================================= */
-.chats-page .message-bubble-container {
- position: relative;
- display: flex;
+.chats-page .new-group-create {
+ display: inline-flex;
align-items: center;
- gap: 0.5rem;
- max-width: 70%;
+ gap: 0.375rem;
+ padding-block: 0.5rem;
+ padding-inline: 1rem;
+ background: var(--chat-accent);
+ border: none;
+ border-radius: 999px;
- color: #fff;
++ color: #0f172a;
+ font-size: 0.875rem;
+ font-weight: 600;
+ cursor: pointer;
}
-.chats-page .message-bubble-wrapper.outgoing .message-bubble-container {
- flex-direction: row-reverse;
+.chats-page .new-group-create:hover:not(:disabled) {
- background: var(--chat-accent-hover);
++ /* Lighter, not darker: the darker hover green leaves the slate text at 4.39:1. */
++ background: color-mix(in srgb, var(--chat-accent) 88%, #ffffff);
}
-.chats-page .message-bubble-wrapper.incoming .message-bubble-container {
- flex-direction: row;
+.chats-page .new-group-create:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
}
-/* Hover Menu */
-.chats-page .message-actions-menu {
- position: absolute;
- top: 0.5rem;
- inset-inline-end: 0.5rem;
- display: none;
- align-items: center;
- gap: 0.25rem;
- background: var(--bg-white);
- border: 1px solid var(--border);
- box-shadow: var(--shadow-sm);
- border-radius: 20px;
- padding: 2px 6px;
- z-index: 5;
+/* =============================================================================
+ CHAT ROOM: Right Column
+ ============================================================================= */
+.chats-page .chats-room {
+ flex: 1;
+ min-width: 0;
+ min-height: 0;
+ display: flex;
+ flex-direction: column;
+ background: var(--chat-wallpaper);
}
-.chats-page .message-bubble-container:hover .message-actions-menu,
-.chats-page .room-messages:not([data-pointer]) .message-bubble-container:focus-within .message-actions-menu {
+.chats-page .chats-room-placeholder {
+ flex: 1;
display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding: 3rem;
+ text-align: center;
+ color: var(--chat-meta);
+ background: var(--chat-panel-header);
+ border-bottom: 6px solid var(--chat-accent);
+}
+
+.chats-page .placeholder-icon {
+ margin-bottom: 1.5rem;
+ opacity: 0.35;
+}
+
+.chats-page .chats-room-placeholder h2 {
+ font-size: 1.5rem;
+ font-weight: 300;
+ color: var(--text-primary);
+ /* Reset the global h2 eyebrow treatment: this is an empty-state title, not a section label. */
+ text-transform: none;
+ letter-spacing: -0.01em;
+ margin: 0 0 0.5rem;
+}
+
+.chats-page .chats-room-placeholder p {
+ font-size: 0.9375rem;
+ max-width: 420px;
+ margin: 0;
+}
+
+.chats-page .room-container {
+ flex: 1;
+ min-height: 0;
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+}
+
+.chats-page .room-header,
+.chats-page .chats-room-header {
+ height: 64px;
+ background: var(--chat-panel-header);
+ border-bottom: 1px solid var(--chat-divider);
+ padding-block: 0;
+ padding-inline: 1rem 0.75rem;
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ box-sizing: border-box;
+ flex-shrink: 0;
+}
+
+/* Back-to-list control: only needed in the single-pane mobile layout; hidden on the two-pane desktop. */
+.chats-page .room-back {
+ display: none;
+ align-items: center;
+ justify-content: center;
+ width: 36px;
+ height: 36px;
+ /* Reset the global `button` padding (0.6em 1.2em): with box-sizing:border-box it would consume
+ the whole 36px width and collapse the arrow icon to 0px wide, making the button look empty. */
+ padding: 0;
+ margin-inline-start: -0.5rem;
+ background: transparent;
+ border: none;
+ border-radius: 50%;
+ color: var(--chat-icon);
+ cursor: pointer;
+ flex-shrink: 0;
+}
+
+.chats-page .room-back:hover {
+ background: color-mix(in srgb, var(--chat-icon) 14%, transparent);
+}
+
+.chats-page .room-contact {
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ align-items: center;
+ gap: 0.875rem;
+ padding: 0;
+ background: transparent;
+ border: none;
+ cursor: pointer;
+ text-align: start;
+ color: inherit;
+}
+
+.chats-page .room-contact-info {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ line-height: 1.25;
+}
+
+.chats-page .room-contact-name {
+ font-size: 1rem;
+ font-weight: 600;
+ color: var(--text-primary);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
++ unicode-bidi: plaintext;
++ align-self: flex-start;
++ max-width: 100%;
+}
+
++/* The number under the name is isolated left to right in the markup (<bdi dir="ltr">), so the line keeps the page
++ direction and sits at the start edge with the name. */
++
+.chats-page .room-contact-phone {
+ font-size: 0.8125rem;
+ color: var(--chat-meta);
+}
+
+.chats-page .room-header-actions {
+ display: flex;
+ align-items: center;
+ gap: 0.25rem;
+ flex-shrink: 0;
+}
+
+.chats-page .room-menu {
+ position: relative;
+}
+
+.chats-page .room-menu-popover {
+ position: absolute;
+ top: calc(100% + 6px);
+ inset-inline-end: 0;
+ z-index: 30;
+ min-width: 200px;
+ padding: 0.375rem;
+ display: flex;
+ flex-direction: column;
+ background: var(--chat-panel);
+ border: 1px solid var(--chat-divider);
+ border-radius: 12px;
+ box-shadow: var(--shadow-lg);
+}
+
+.chats-page .room-menu-popover button {
+ display: flex;
+ align-items: center;
+ gap: 0.625rem;
+ padding-block: 0.625rem;
+ padding-inline: 0.75rem;
+ background: transparent;
+ border: none;
+ border-radius: 8px;
+ font-size: 0.875rem;
+ color: var(--text-primary);
+ cursor: pointer;
+ text-align: start;
+ white-space: nowrap;
+}
+
- .chats-page .room-menu-popover button:hover {
++.chats-page .room-menu-popover button:hover,
++.chats-page .room-menu-popover button:focus-visible {
+ background: var(--chat-hover);
+}
+
+.chats-page .room-menu-popover svg {
+ color: var(--chat-icon);
+}
+
+/* =============================================================================
+ THREAD
+ ============================================================================= */
+.chats-page .room-messages {
+ flex: 1;
+ min-height: 0;
+ /* Load-bearing on every side: the older-page pill is lifted into the top padding, and the width its
+ failure text is measured against assumes 1.5rem inline (see .messages-loading-older). */
+ padding: 1.5rem;
+ overflow-y: auto;
+ /* Chrome/Firefox already adjust scrollTop on their own when content is prepended above the
+ viewport (CSS scroll anchoring). The older-page handler applies its own correction for the
+ same event, so leaving the browser's default on double-applies it. WebKit implements no
+ scroll anchoring, so this is a no-op there and the manual correction is the only one that runs. */
+ overflow-anchor: none;
+ display: flex;
+ flex-direction: column;
+ /* The space between two bubbles of one run; a new run adds its own margin. The older-page pill and the
+ scroll-to-bottom button take it back in their margins. */
+ gap: 2px;
+ background-color: var(--chat-wallpaper);
+ background-image: var(--chat-wallpaper-pattern);
+ background-size: 240px 240px;
+ position: relative;
+ /* The failure indicator's text is set against the width of the thread (the container query below), not the
+ viewport: beside the list at an 890px viewport its client width is narrower than a phone's. */
+ container-type: inline-size;
+}
+
+/* Floating scroll-to-bottom button. It is the last child of the scroller and sticky, not absolute: an
+ absolute child of the scroller moves with the content, so it sat at the bottom of the first screen of
+ the thread, off screen whenever it was shown. In flow it would add its own height and one flex gap to
+ the thread, which the negative margin takes back, so the scroll height is the same with and without it.
+ It sits below a bubble's actions menu (z-index 5), which it would otherwise cover: it is later in the
+ DOM, and the Delete icon of a message near the bottom edge of the pane lies under it. */
+.chats-page .scroll-to-bottom-btn {
+ position: sticky;
+ bottom: 0.75rem;
+ align-self: flex-end;
+ flex: none;
+ margin-top: calc(-42px - 2px);
+ z-index: 4;
+ width: 42px;
+ height: 42px;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: var(--chat-bubble-in);
+ color: var(--chat-icon);
+ border: none;
+ box-shadow: 0 2px 6px rgba(11, 20, 26, 0.2);
+ cursor: pointer;
+ transition:
+ color 0.15s,
+ transform 0.1s;
+ padding: 0;
+}
+
+.chats-page .scroll-to-bottom-btn:hover {
+ color: var(--chat-accent);
+}
+
+.chats-page .scroll-to-bottom-btn:active {
+ transform: scale(0.94);
+}
+
+.chats-page .messages-loading {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ flex: 1;
+ color: var(--chat-meta);
+ font-size: 0.9375rem;
+ gap: 0.75rem;
+}
+
+/* The older-page indicator (ChatThread): a pill that holds to the top edge of the pane while a page loads,
+ and the failure to load one. Neither takes room in the thread: a row in flow adds its height and one flex
+ gap above the oldest bubble, which pushed the reader's content down by that much when the page was
+ requested and back up when it landed. The loading pill's height is explicit, and its margins take it and
+ the gap back, as the scroll-to-bottom button does, so the thread lays out the same with and without the
+ row. The top margin lifts it into the 1.5rem of padding, clear of the first bubble when the thread is at
+ its top, whatever its height; the bottom margin is what is left to add up to minus the gap. It never takes
+ a pointer event from a bubble under it, and it must not take the flex remainder either. */
+.chats-page .messages-loading-older {
+ --older-row-height: 1.25rem;
+ position: sticky;
+ /* Sticky offsets are measured from the scroller's padding edge: the 1.5rem of padding back out, less
+ the 0.125rem the pill keeps from the pane's edge. */
+ top: -1.375rem;
+ z-index: 4;
+ align-self: center;
+ flex: none;
+ box-sizing: border-box;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 0.375rem;
+ max-width: 100%;
+ height: var(--older-row-height);
+ margin-top: -1.375rem;
+ margin-bottom: calc(1.375rem - 2px - var(--older-row-height));
+ padding: 0 0.75rem;
+ border: 1px solid var(--chat-divider);
+ border-radius: 999px;
+ background: var(--chat-bubble-in);
+ box-shadow: var(--chat-shadow-bubble);
+ color: var(--chat-meta);
+ font-size: 0.75rem;
+ line-height: 1.25;
+ pointer-events: none;
+}
+
+.chats-page .messages-loading-older > svg {
+ flex: none;
+ width: 0.875rem;
+ height: 0.875rem;
+}
+
+/* The text has to clip (the ellipsis, and the line limit of the failure, need overflow other than visible),
+ and a line box is shorter than the glyphs of some scripts: the tails of g and p, Telugu conjuncts below the
+ base, Arabic marks above and below the letters. The padding is the room the clip leaves them, and the
+ negative margin takes it back, so the span lays out as the line it is. */
+.chats-page .messages-loading-older > span {
+ min-width: 0;
+ padding-block: 0.25em;
+ padding-inline: 0.15em;
+ margin-block: -0.25em;
+ margin-inline: -0.15em;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+/* The failure carries the retry hint, so it wraps; its height is not known, and no margin can take it back. It
+ is out of flow instead, so it takes no room at any height. It is not the reader's to carry through the
+ thread: it stays at the top of the thread, where scrolling up again retries. Centred by its auto margins, as
+ wide as its text up to the pane less its inset. It is held to two lines, which end inside the 1.5rem of
+ padding and the top padding of the first bubble: a reader at the top of the thread is on that message, and a
+ third line would run over its first line of text. Two lines hold the whole sentence of every translation
+ in a thread wider than the container query below says; at that width or less only the retry instruction is
+ shown. */
+.chats-page .messages-loading-older.failed {
+ position: absolute;
+ top: 0.125rem;
+ inset-inline: 0.25rem;
+ width: max-content;
+ max-width: calc(100% - 0.5rem);
+ height: auto;
+ min-height: var(--older-row-height);
+ margin: 0 auto;
+ padding: 0 0.5rem;
+ border-radius: 0.875rem;
+ font-size: 0.6875rem;
+}
+
+.chats-page .messages-loading-older.failed > span {
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+ overflow-wrap: anywhere;
+ text-align: center;
+ white-space: normal;
+}
+
+.chats-page .messages-loading-older.failed > .older-failure-hint {
+ display: none;
+}
+
+/* In a thread of 17rem of content or less, two lines may not hold the whole sentence, and only the retry
+ instruction is shown. The width queried is the content box of the thread: its client width, which leaves
+ out a scrollbar, less its inline padding. The longest sentence, the German one, needs 308px of client
+ width for two lines in every engine with 1.5rem of padding on each side. display: none takes the hidden
+ text out of the accessibility tree as well, so what is read is what is shown. */
+@container (max-width: 17rem) {
+ .chats-page .messages-loading-older.failed > .older-failure-full {
+ display: none;
+ }
+
+ .chats-page .messages-loading-older.failed > .older-failure-hint {
+ display: -webkit-box;
+ }
}
-/* A bubble is a keyboard stop (ChatThread): the ring says which message the arrow keys act on. */
-.chats-page .message-bubble-container:focus-visible {
- outline: 2px solid var(--focus-ring);
- outline-offset: 2px;
- border-radius: 12px;
+/* The loading label is one line while the pill fits it: the longest translation, the French one, is 285px
+ wide with its icon and padding, and 18rem of content box is 288px. At 18rem or less the label may wrap
+ onto a second line, at the size of the failure text. The pill is 1.875rem high there instead of 1.25rem
+ whether or not the label wraps: its margins take that back (see above), and the two lines end where the
+ failure's do, above the first message's text. */
+@container (max-width: 18rem) {
+ .chats-page .messages-loading-older:not(.failed) {
+ --older-row-height: 1.875rem;
+ font-size: 0.6875rem;
+ }
+
+ .chats-page .messages-loading-older:not(.failed) > span {
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 2;
+ overflow-wrap: anywhere;
+ text-align: center;
+ white-space: normal;
+ }
}
-.chats-page .action-btn {
- background: transparent;
- border: none;
- color: var(--text-muted);
- cursor: pointer;
- padding: 4px;
- border-radius: 50%;
+.chats-page .messages-empty {
display: flex;
+ flex-direction: column;
align-items: center;
justify-content: center;
- transition: all 0.15s ease;
+ flex: 1;
+ color: var(--chat-meta);
+ font-size: 0.9375rem;
+ gap: 0.75rem;
+ text-align: center;
+ padding: 2rem;
}
-.chats-page .action-btn:hover {
- background: var(--bg-light);
- color: var(--text-primary);
+.chats-page .messages-empty span {
+ background: var(--chat-bubble-in);
+ padding-block: 0.5rem;
+ padding-inline: 0.875rem;
+ border-radius: 8px;
+ box-shadow: var(--chat-shadow-bubble);
}
-.chats-page .action-btn.delete-btn:hover {
- color: var(--error-text);
- background: rgba(239, 68, 68, 0.12);
+/* Day separator pill */
+.chats-page .day-separator {
+ display: flex;
+ justify-content: center;
+ margin-block: 0.75rem 0.5rem;
}
-/* Reaction Quick Popover */
-.chats-page .reaction-trigger-wrapper {
- position: relative;
+.chats-page .day-separator span {
+ padding-block: 0.3rem;
+ padding-inline: 0.75rem;
+ background: var(--chat-bubble-in);
+ color: var(--chat-bubble-text);
+ border-radius: 8px;
+ font-size: 0.8125rem;
+ font-weight: 600;
+ box-shadow: var(--chat-shadow-bubble);
}
-.chats-page .reaction-quick-popover {
- display: none;
- position: absolute;
- bottom: 100%;
- left: 50%;
- /* --popover-shift is set when it opens, by the amount it would run past the pane (ChatThread). */
- transform: translateX(calc(-50% + var(--popover-shift, 0px))) translateY(-6px);
- background: var(--bg-white);
- border: 1px solid var(--border);
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
- border-radius: 24px;
- padding: 0.375rem 0.625rem;
- gap: 0.375rem;
- z-index: 50;
- white-space: nowrap;
+/* Bubbles */
+.chats-page .message-bubble-wrapper {
+ display: flex;
+ width: 100%;
}
-/* The pill sits at the end of its bubble and an own bubble is at the end of the pane, so a popover centred
- on the react icon runs past the pane and clips the last emoji, which cannot then be picked. Anchored to
- the end of the icon it grows toward the middle of the pane, in either text direction. */
-.chats-page .message-bubble-wrapper.outgoing .reaction-quick-popover {
- left: auto;
- inset-inline-end: 0;
- transform: translateX(var(--popover-shift, 0px)) translateY(-6px);
+.chats-page .message-bubble-wrapper.run-start {
+ margin-top: 0.5rem;
}
-/* Opened below the icon when there is no room above it in the pane (ChatThread sets data-below). */
-.chats-page .reaction-quick-popover[data-below] {
- bottom: auto;
- top: 100%;
- transform: translateX(calc(-50% + var(--popover-shift, 0px))) translateY(6px);
+.chats-page .day-separator + .message-bubble-wrapper.run-start {
+ margin-top: 0;
}
-.chats-page .message-bubble-wrapper.outgoing .reaction-quick-popover[data-below] {
- transform: translateX(var(--popover-shift, 0px)) translateY(6px);
+.chats-page .message-bubble-wrapper.has-reactions {
+ margin-bottom: 0.875rem;
}
-.chats-page .reaction-quick-popover[data-below]::after {
- top: auto;
- bottom: 100%;
+.chats-page .message-bubble-wrapper.incoming {
+ justify-content: flex-start;
}
-.chats-page .reaction-quick-popover::after {
- content: '';
- position: absolute;
- top: 100%;
- left: 0;
- right: 0;
- height: 12px;
- background: transparent;
+.chats-page .message-bubble-wrapper.outgoing {
+ justify-content: flex-end;
}
-.chats-page .reaction-trigger-wrapper:hover .reaction-quick-popover,
-.chats-page .room-messages:not([data-pointer]) .reaction-trigger-wrapper:focus-within .reaction-quick-popover {
+.chats-page .message-bubble-container {
+ position: relative;
display: flex;
+ align-items: center;
+ gap: 0.5rem;
+ max-width: min(65%, 640px);
}
-.chats-page .reaction-quick-popover button {
- background: transparent;
- border: none;
- font-size: 1.25rem;
- padding: 2px;
- cursor: pointer;
- transition: transform 0.1s ease;
+.chats-page .message-bubble-wrapper.outgoing .message-bubble-container {
+ flex-direction: row-reverse;
}
-.chats-page .reaction-quick-popover button:hover {
- transform: scale(1.3);
+.chats-page .message-bubble-wrapper.incoming .message-bubble-container {
+ flex-direction: row;
}
-/* Reactions Badge */
-.chats-page .message-reactions-badge {
- position: absolute;
- bottom: -12px;
- background: var(--bg-white);
- border: 1px solid var(--border);
- box-shadow: var(--shadow-sm);
- border-radius: 12px;
- padding: 2px 6px;
- display: flex;
- align-items: center;
- gap: 2px;
- font-size: 0.75rem;
- z-index: 2;
- cursor: pointer;
- user-select: none;
+.chats-page .message-bubble {
+ position: relative;
+ min-width: 0;
+ max-width: 100%;
+ padding: 0.375rem 0.5rem 0.5rem;
+ border-radius: 8px;
+ font-size: 0.9375rem;
+ line-height: 1.4;
+ color: var(--chat-bubble-text);
+ box-shadow: var(--chat-shadow-bubble);
}
-.chats-page .message-bubble-wrapper.outgoing .message-reactions-badge {
- inset-inline-end: 12px;
+.chats-page .message-bubble.incoming {
+ background: var(--chat-bubble-in);
}
-.chats-page .message-bubble-wrapper.incoming .message-reactions-badge {
- inset-inline-start: 12px;
+.chats-page .message-bubble.outgoing {
+ background: var(--chat-bubble-out);
}
-.chats-page .reaction-emoji-span {
- font-size: 0.8125rem;
+/* The tail on the first bubble of a run, on the side the bubble comes from. */
+.chats-page .run-start .message-bubble.incoming {
+ border-start-start-radius: 0;
}
-.chats-page .reactions-count-span {
- font-weight: 600;
- color: var(--text-secondary);
- margin-inline-start: 2px;
+.chats-page .run-start .message-bubble.outgoing {
+ border-start-end-radius: 0;
}
-/* Quoted Box inside Bubble */
-.chats-page .message-quote-box {
- background: rgba(0, 0, 0, 0.04);
- border-inline-start: 4px solid var(--primary);
- border-radius: 4px;
- padding: 0.375rem 0.625rem;
- margin-bottom: 0.5rem;
- font-size: 0.8125rem;
- color: var(--text-secondary);
- cursor: pointer;
+.chats-page .run-start .message-bubble::before {
+ content: '';
+ position: absolute;
+ top: 0;
+ width: 8px;
+ height: 13px;
}
-.chats-page .message-bubble.outgoing .message-quote-box {
- background: rgba(0, 0, 0, 0.05);
- border-inline-start-color: #008069;
+.chats-page .run-start .message-bubble.incoming::before {
+ inset-inline-start: -8px;
+ background: var(--chat-bubble-in);
+ clip-path: polygon(0 0, 100% 0, 100% 100%);
}
-[data-theme='dark'] .chats-page .message-quote-box {
- background: rgba(255, 255, 255, 0.08);
-}
-/* Outgoing-bubble quote boxes: the plain dark rule loses the specificity tie with the light
- outgoing rule below, so both dark modes apply the same treatment explicitly. */
-[data-theme='dark'] .chats-page .message-bubble.outgoing .message-quote-box {
- background: rgba(255, 255, 255, 0.08);
+.chats-page .run-start .message-bubble.outgoing::before {
+ inset-inline-end: -8px;
+ background: var(--chat-bubble-out);
+ clip-path: polygon(0 0, 100% 0, 0 100%);
}
-@media (prefers-color-scheme: dark) {
- :root:not([data-theme='light']) .chats-page .message-quote-box {
- background: rgba(255, 255, 255, 0.08);
- }
+/* clip-path does not follow the writing direction, so a right-to-left layout mirrors both triangles. */
+[dir='rtl'] .chats-page .run-start .message-bubble.incoming::before {
+ clip-path: polygon(0 0, 100% 0, 0 100%);
}
-.chats-page .quote-body {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- unicode-bidi: plaintext;
- /* The cap is the smaller of 250px and the room in the quote box: under nowrap the shrink-to-fit width is the
- whole text, so a bare 250px cap let a long quote paint past a narrow bubble. */
- max-width: min(250px, 100%);
- width: fit-content;
+[dir='rtl'] .chats-page .run-start .message-bubble.outgoing::before {
+ clip-path: polygon(0 0, 100% 0, 100% 100%);
}
-/* Inbound business prompt buttons (Baileys click-button) */
-.chats-page .message-prompt-buttons {
- display: flex;
- flex-direction: column;
- gap: 0.375rem;
- margin-top: 0.5rem;
- width: 100%;
+.chats-page .message-bubble.media-type {
+ padding-block: 0.25rem 0.375rem;
+ padding-inline: 0.25rem;
}
-.chats-page .message-prompt-button {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 0.375rem;
- width: 100%;
- padding: 0.5rem 0.75rem;
- border: 1px solid var(--border);
- border-radius: 8px;
- background: var(--bg-white);
- color: var(--primary-text);
- font-size: 0.875rem;
- font-weight: 500;
- cursor: pointer;
- transition:
- background 0.15s ease,
- border-color 0.15s ease,
- opacity 0.15s ease;
+.chats-page .message-bubble.media-type .message-content {
+ padding-inline: 0.3125rem;
}
-.chats-page .message-prompt-button:hover:not(:disabled) {
- background: rgba(0, 0, 0, 0.04);
- border-color: var(--primary);
+/* Revoked / Deleted message type */
+.chats-page .message-bubble.revoked-type .message-text {
+ font-style: italic;
+ color: var(--chat-meta);
}
-.chats-page .message-prompt-button:disabled {
- cursor: default;
- opacity: 0.55;
+/* Group sender label: the poster's name atop an incoming group bubble (colour set inline per sender). */
+.chats-page .message-sender {
+ font-size: 0.8125rem;
+ font-weight: 600;
+ line-height: 1.2;
+ margin-bottom: 0.15rem;
+ word-break: break-word;
}
-.chats-page .message-prompt-button.selected {
- opacity: 1;
- border-color: var(--primary);
- background: rgba(0, 128, 105, 0.08);
- font-weight: 600;
+/* Inline text plus trailing time and ticks. The spacer reserves the meta's width at the end of the last
+ line, and the meta sits absolutely over it, so it tucks into that line when it fits and wraps below. */
+.chats-page .message-content {
+ position: relative;
+ word-break: break-word;
}
-.chats-page .message-prompt-button.answered:not(.selected) {
- opacity: 0.4;
+.chats-page .message-content > .message-text {
+ display: inline;
+ white-space: pre-wrap;
}
-[data-theme='dark'] .chats-page .message-prompt-button {
- background: rgba(255, 255, 255, 0.06);
+.chats-page .message-content > .message-poll-options {
+ display: block;
+ margin-block: 0.25rem;
+ padding-inline-start: 1.25rem;
}
-[data-theme='dark'] .chats-page .message-prompt-button:hover:not(:disabled) {
- background: rgba(255, 255, 255, 0.1);
+.chats-page .message-text a {
+ color: var(--chat-link);
+ text-decoration: underline;
}
-[data-theme='dark'] .chats-page .message-prompt-button.selected {
- background: rgba(0, 168, 132, 0.18);
++/* The blue of an incoming link is 4.07:1 on the light green and 3.74:1 on the dark one. */
++.chats-page .message-bubble.outgoing .message-text a {
++ color: var(--chat-link-out);
+ }
+
-@media (prefers-color-scheme: dark) {
- :root:not([data-theme='light']) .chats-page .message-prompt-button {
- background: rgba(255, 255, 255, 0.06);
- }
+.chats-page .message-masked {
+ color: var(--chat-meta);
+}
- :root:not([data-theme='light']) .chats-page .message-prompt-button:hover:not(:disabled) {
- background: rgba(255, 255, 255, 0.1);
- }
+.chats-page .meta-spacer {
+ display: inline-block;
+ width: 3.25rem;
+ height: 1px;
+ vertical-align: baseline;
+}
- :root:not([data-theme='light']) .chats-page .message-prompt-button.selected {
- background: rgba(0, 168, 132, 0.18);
- }
+.chats-page .meta-spacer.with-status {
+ width: 4.5rem;
}
-/* Replying Preview Banner above Input Footer */
-.chats-page .replying-preview-banner {
- background: var(--bg-white);
- border-top: 1px solid var(--border);
- padding: 0.75rem 1.5rem;
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 1rem;
- box-sizing: border-box;
+/* An edited label widens the room by its own text: a hidden copy sits in the spacer ahead of the fixed part. */
+.chats-page .meta-spacer:has(.meta-spacer-edited) {
+ width: auto;
+ overflow: hidden;
+ padding-inline-end: 3.25rem;
}
-.chats-page .replying-preview-content {
- flex: 1;
- border-inline-start: 4px solid var(--primary);
- padding-inline-start: 0.75rem;
- display: flex;
- flex-direction: column;
- min-width: 0;
+.chats-page .meta-spacer.with-status:has(.meta-spacer-edited) {
+ padding-inline-end: 4.5rem;
}
-.chats-page .replying-to-title {
- font-size: 0.8125rem;
- font-weight: 700;
- color: var(--primary-text);
- /* Same treatment as `.replying-to-body` below. Without it a quoted name with no break opportunity
- keeps its box but paints straight through the close button and out of the panel. */
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
+.chats-page .meta-spacer-edited {
+ visibility: hidden;
+ font-size: 0.6875rem;
+ padding-inline-end: 0.25rem;
}
-.chats-page .replying-to-body {
- font-size: 0.875rem;
- color: var(--text-secondary);
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- unicode-bidi: plaintext;
- align-self: flex-start;
- max-width: 100%;
+.chats-page .message-meta {
+ position: absolute;
+ inset-inline-end: 0;
+ bottom: -0.3125rem;
+ display: inline-flex;
+ align-items: center;
+ gap: 0.1875rem;
+ white-space: nowrap;
}
-.chats-page .btn-close-reply {
- background: transparent;
- border: none;
- color: var(--text-muted);
- cursor: pointer;
- padding: 0.375rem;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- transition: all 0.2s;
+.chats-page .message-edited,
+.chats-page .message-time {
+ font-size: 0.6875rem;
+ color: var(--chat-meta);
}
-.chats-page .btn-close-reply:hover {
- background: var(--bg-light);
- color: var(--text-primary);
+.chats-page .message-bubble.outgoing .message-edited,
+.chats-page .message-bubble.outgoing .message-time {
+ color: var(--chat-meta-out);
}
-/* Revoked / Deleted message type */
-.chats-page .message-bubble.revoked-type {
- font-style: italic;
- opacity: 0.6;
+/* A styled status bubble sets its own inline background + white text; let its timestamp inherit
+ instead of staying the muted gray meant for the default bubble. */
+.chats-page .message-bubble[style] .message-edited,
+.chats-page .message-bubble[style] .message-time {
+ color: inherit;
+ opacity: 0.75;
+}
+
+.chats-page .message-status-icon {
+ display: inline-flex;
+ color: var(--chat-meta);
}
-[data-theme='dark'] .chats-page .message-actions-menu,
-[data-theme='dark'] .chats-page .reaction-quick-popover,
-[data-theme='dark'] .chats-page .message-reactions-badge {
- background: #202c33;
- border-color: #2f3b43;
+.chats-page .message-status-icon.read {
+ color: var(--chat-tick-read);
}
-@media (prefers-color-scheme: dark) {
- :root:not([data-theme='light']) .chats-page .message-actions-menu,
- :root:not([data-theme='light']) .chats-page .reaction-quick-popover,
- :root:not([data-theme='light']) .chats-page .message-reactions-badge {
- background: #202c33;
- border-color: #2f3b43;
- }
+.chats-page .message-status-icon.failed {
+ color: var(--error-text);
}
/* Inline code inside a message body. */
@@@ -2190,20 -1726,44 +2256,24 @@@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
- max-width: 320px;
++ unicode-bidi: plaintext;
++ /* The cap is the smaller of 320px and the room in the quote box: under nowrap the shrink-to-fit width is the
++ whole text, so a bare 320px cap let a long quote paint past a narrow bubble. */
++ max-width: min(320px, 100%);
++ width: fit-content;
}
-.chats-page .messages-list {
- flex: 1;
- padding: 1.5rem;
- overflow-y: auto;
+/* Inbound business prompt buttons (Baileys click-button) */
+.chats-page .message-prompt-buttons {
display: flex;
flex-direction: column;
- gap: 0.75rem;
- align-items: flex-start;
-}
-
-.chats-page .messages-list .message-bubble {
- max-width: 480px;
-}
-
-.chats-page .channel-media {
- max-width: 100%;
- max-height: 320px;
- border-radius: 8px;
- display: block;
- margin-bottom: 0.5rem;
- object-fit: cover;
-}
-
-/* Shown in place of media that cannot be shown: a status media blob that fails to load, or a
- channel post whose media has no URL. */
-.chats-page .status-media-placeholder {
- display: block;
- font-size: 0.85rem;
- color: var(--text-muted);
+ gap: 0.375rem;
+ margin-top: 0.5rem;
margin-bottom: 0.5rem;
+ width: 100%;
}
-/* =============================================================================
- STATUS COMPOSE MODAL
- ============================================================================= */
-.chats-page .status-compose-trigger {
+.chats-page .message-prompt-button {
display: flex;
align-items: center;
justify-content: center;
@@@ -2331,63 -1895,54 +2401,63 @@@
display: flex;
align-items: center;
gap: 0.5rem;
- padding: 0.5rem 0.75rem;
+ padding-block: 0.625rem;
+ padding-inline: 0.75rem;
+ margin-bottom: 0.5rem;
+ background: color-mix(in srgb, var(--chat-bubble-text) 6%, transparent);
+ border-radius: 6px;
+ color: var(--chat-bubble-text);
+ text-decoration: none;
font-size: 0.875rem;
- color: var(--text-primary);
- cursor: pointer;
- border-bottom: 1px solid var(--border);
+ font-weight: 500;
+ word-break: break-all;
}
-.chats-page .status-compose-modal .compose-recipient-row:last-child {
- border-bottom: none;
+.chats-page .chat-document-media:hover {
+ background: color-mix(in srgb, var(--chat-bubble-text) 10%, transparent);
}
-.chats-page .status-compose-modal .compose-recipient-row:hover {
- background: var(--bg-white);
+/* =============================================================================
+ HOVER MENU, REPLIES, REACTIONS, AND DELETIONS
+ ============================================================================= */
+/* Laid over the bubble's top corner, not beside it: in flow it would squeeze a full-width bubble on hover. */
+.chats-page .message-actions-menu {
+ position: absolute;
+ top: 0.375rem;
+ inset-inline-end: 0.375rem;
+ display: none;
+ align-items: center;
+ gap: 0.125rem;
+ background: var(--chat-panel);
+ box-shadow: var(--shadow-md);
+ border-radius: 20px;
+ padding-block: 2px;
+ padding-inline: 4px;
+ z-index: 5;
}
-.chats-page .status-compose-modal .compose-recipients-empty {
- padding: 1rem;
- text-align: center;
- color: var(--text-muted);
- font-size: 0.8125rem;
+.chats-page .message-bubble-container:hover .message-actions-menu,
+.chats-page .room-messages:not([data-pointer]) .message-bubble-container:focus-within .message-actions-menu {
display: flex;
- align-items: center;
- justify-content: center;
}
-.chats-page .status-compose-modal .input-hint {
- display: block;
- font-size: 0.75rem;
- color: var(--text-muted);
- margin-top: 0.375rem;
+/* A bubble is a keyboard stop (ChatThread): the ring says which message the arrow keys act on. */
+.chats-page .message-bubble-container:focus-visible {
- outline: 2px solid var(--chat-accent);
++ outline: 2px solid var(--focus-ring);
+ outline-offset: 2px;
+ border-radius: 8px;
}
-/* =============================================================================
- CHAT ACTIONS: new chat, quick filters, archive, row and room menus, dialogs
- ============================================================================= */
-.chats-page .icon-btn {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- width: 36px;
- height: 36px;
- padding: 0;
+.chats-page .action-btn {
background: transparent;
border: none;
- border-radius: var(--radius, 8px);
- color: var(--text-secondary);
+ color: var(--chat-icon);
cursor: pointer;
- flex-shrink: 0;
+ padding: 5px;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
transition: background 0.15s ease;
}
@@@ -2528,500 -2062,451 +2598,510 @@@
flex-shrink: 0;
}
-.chats-page .chat-item-flags + .chat-unread-badge {
- margin-inline-start: 0.375rem;
+.chats-page .preview-thumbnail,
+.chats-page .preview-file-icon {
+ width: 48px;
+ height: 48px;
+ border-radius: 6px;
+ flex-shrink: 0;
}
-/* A row's chevron: shown on hover, on keyboard focus and while its menu is open. Its room is kept clear on
- every row that has one, so the time does not move when it appears. */
-.chats-page .chat-item-wrap {
- position: relative;
+.chats-page .preview-thumbnail {
+ object-fit: cover;
+}
+
+.chats-page .preview-file-icon {
+ background: var(--chat-panel);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 1.5rem;
+}
+
+.chats-page .preview-file-info {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
}
-.chats-page .chat-item-wrap.has-menu .chat-item-top {
- padding-inline-end: 1.75rem;
+.chats-page .preview-filename {
+ font-size: 0.875rem;
+ font-weight: 600;
+ color: var(--text-primary);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
++ unicode-bidi: plaintext;
++ align-self: flex-start;
++ max-width: 100%;
}
-.chats-page .chat-row-menu {
- position: absolute;
- top: 0.75rem;
- inset-inline-end: 0.75rem;
+.chats-page .preview-filesize {
+ font-size: 0.75rem;
+ color: var(--chat-meta);
}
-.chats-page .chat-row-menu-trigger {
+.chats-page .btn-banner-close {
+ background: transparent;
+ border: none;
+ color: var(--chat-icon);
+ cursor: pointer;
+ padding: 0.375rem;
+ border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
- width: 26px;
- height: 26px;
- padding: 0;
- border: 1px solid var(--border);
- border-radius: 6px;
- background: var(--bg-white);
- color: var(--text-secondary);
- cursor: pointer;
- opacity: 0;
- transition: opacity 0.12s ease;
+ flex-shrink: 0;
}
-.chats-page .chat-item-wrap:hover .chat-row-menu-trigger,
-.chats-page .chat-row-menu.open .chat-row-menu-trigger,
-.chats-page .chat-row-menu-trigger:focus-visible {
- opacity: 1;
+.chats-page .btn-banner-close:hover {
+ background: color-mix(in srgb, var(--chat-icon) 14%, transparent);
}
-.chats-page .chat-row-menu-trigger:focus-visible {
- outline: 2px solid var(--focus-ring);
- outline-offset: 1px;
+.chats-page .chats-emoji-picker {
+ max-height: 140px;
+ overflow-y: auto;
}
-/* A touch screen has no hover to reveal the trigger, so it stays visible there. */
-@media (hover: none) {
- .chats-page .chat-row-menu-trigger {
- opacity: 1;
- }
+.chats-page .emoji-grid {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.25rem;
}
-/* The row's and the room's menus share their entries (ChatActionList). */
-.chats-page .room-header-actions {
- margin-inline-start: auto;
+.chats-page .emoji-btn {
+ background: transparent;
+ border: none;
+ font-size: 1.375rem;
+ padding: 0.375rem;
+ border-radius: 8px;
+ cursor: pointer;
display: flex;
align-items: center;
- gap: 0.25rem;
- flex-shrink: 0;
+ justify-content: center;
}
-.chats-page .room-menu {
- position: relative;
+.chats-page .emoji-btn:hover {
+ background: var(--chat-hover);
}
-.chats-page .chat-row-menu-popover,
-.chats-page .room-menu-popover {
- position: absolute;
- top: calc(100% + 0.375rem);
- inset-inline-end: 0;
- z-index: 30;
- min-width: 240px;
- padding: 0.375rem;
+.chats-page .replying-preview-content {
+ flex: 1;
+ min-width: 0;
+ background: var(--chat-panel);
+ border-inline-start: 4px solid var(--chat-quote-accent);
+ border-radius: 6px;
+ padding-block: 0.375rem;
+ padding-inline: 0.75rem;
display: flex;
flex-direction: column;
- background: var(--bg-white);
- border: 1px solid var(--border);
- border-radius: 12px;
- box-shadow: var(--shadow-lg);
}
-.chats-page .chat-row-menu-group,
-.chats-page .room-menu-group {
- display: flex;
- flex-direction: column;
+.chats-page .replying-to-title {
+ font-size: 0.8125rem;
+ font-weight: 700;
+ color: var(--chat-pill-active-text);
+ /* Same treatment as `.replying-to-body` below. Without it a quoted name with no break opportunity
+ keeps its box but paints straight through the close button and out of the panel. */
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
-.chats-page .chat-row-menu-popover button,
-.chats-page .room-menu-popover button {
- display: flex;
- align-items: center;
- gap: 0.75rem;
- padding-block: 0.5rem;
- padding-inline: 0.75rem;
- border: none;
- border-radius: 8px;
- background: transparent;
- color: var(--text-primary);
- font: inherit;
+.chats-page .replying-to-body {
font-size: 0.875rem;
- text-align: start;
+ color: var(--chat-meta);
white-space: nowrap;
- cursor: pointer;
+ overflow: hidden;
+ text-overflow: ellipsis;
++ unicode-bidi: plaintext;
++ align-self: flex-start;
++ max-width: 100%;
}
-.chats-page .chat-row-menu-popover button:hover:not(:disabled),
-.chats-page .room-menu-popover button:hover:not(:disabled) {
- background: var(--bg-light);
+.chats-page .room-input-footer {
+ background: var(--chat-panel-header);
+ padding-block: 0.625rem;
+ padding-inline: 1rem;
+ box-sizing: border-box;
+ flex-shrink: 0;
}
-/* A one-step background change does not show keyboard focus, so the entry also gets a ring. */
-.chats-page .chat-row-menu-popover button:focus-visible,
-.chats-page .room-menu-popover button:focus-visible {
- background: var(--primary-soft);
- outline: 2px solid var(--focus-ring);
- outline-offset: -2px;
+.chats-page .input-form {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
}
-.chats-page .chat-row-menu-popover button svg,
-.chats-page .room-menu-popover button svg {
- color: var(--text-secondary);
+.chats-page .btn-input-accessory {
+ background: transparent;
+ border: none;
+ color: var(--chat-icon);
+ cursor: pointer;
+ width: 42px;
+ height: 42px;
+ padding: 0;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
flex-shrink: 0;
+ transition: background 0.15s;
}
-.chats-page .chat-row-menu-popover button:disabled,
-.chats-page .room-menu-popover button:disabled {
- cursor: not-allowed;
- opacity: 0.6;
+.chats-page .btn-input-accessory:hover:not(:disabled),
+.chats-page .btn-input-accessory.active {
+ background: color-mix(in srgb, var(--chat-icon) 14%, transparent);
}
-.chats-page .chat-row-menu-popover hr,
-.chats-page .room-menu-popover hr {
- width: 100%;
- margin-block: 0.25rem;
- border: none;
- border-top: 1px solid var(--border);
+.chats-page .btn-input-accessory.active {
+ color: var(--chat-accent);
}
-/* A disabled entry carries the reason under its label. */
-.chats-page .chat-action-label {
- display: flex;
- flex-direction: column;
- white-space: normal;
+.chats-page .btn-input-accessory:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
}
-.chats-page .chat-action-label small {
- max-width: 16rem;
- font-size: 0.75rem;
- color: var(--text-muted);
+.chats-page .btn-input-accessory.inside {
+ width: 36px;
+ height: 36px;
}
-/* New chat / new group panel (sidebar sub-view) */
-.chats-page .new-chat-panel {
+.chats-page .message-input-pill {
flex: 1;
- min-height: 0;
+ min-width: 0;
display: flex;
- flex-direction: column;
+ align-items: center;
+ gap: 0.25rem;
+ padding-block: 0;
+ padding-inline: 1rem 0.25rem;
+ height: 46px;
+ box-sizing: border-box;
+ background: var(--chat-panel);
+ border: 1px solid var(--chat-divider);
+ border-radius: 24px;
+ transition:
+ border-color 0.15s,
+ box-shadow 0.15s;
}
-.chats-page .new-chat-header {
- display: flex;
- align-items: center;
- gap: 0.5rem;
- padding: 1rem 1.25rem;
- border-bottom: 1px solid var(--border);
- font-size: 1rem;
- font-weight: 600;
+.chats-page .message-input-pill:focus-within {
- border-color: var(--chat-accent);
++ border-color: var(--focus-ring);
+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--chat-accent) 15%, transparent);
+}
+
- .chats-page .message-text-input {
++.chats-page .message-input-pill .message-text-input {
+ flex: 1;
+ /* An input keeps its intrinsic width as its automatic minimum, which pinned the whole composer wider than
+ a narrow pane and pushed the send button outside the layout's clip. The floor replaces that with one small
+ enough to let the composer fit and large enough to keep a caret and a few characters visible. */
+ min-width: 64px;
+ padding: 0;
+ border: none;
+ background: none;
+ font-size: 0.9375rem;
color: var(--text-primary);
+ outline: none;
}
-.chats-page .new-chat-search {
- margin-block: 0.75rem 0;
- margin-inline: 1.25rem;
+.chats-page .message-text-input::placeholder {
+ color: var(--chat-meta);
}
-/* The clear button at the end of a search field: a small icon button whose block margin keeps it inside the
- height of the line, so the field does not grow when it appears. */
-.chats-page .search-clear {
+.chats-page .btn-send-message {
display: flex;
align-items: center;
justify-content: center;
- width: 28px;
- height: 28px;
- margin-block: -0.5rem;
+ width: 46px;
+ height: 46px;
padding: 0;
+ background: var(--chat-accent);
border: none;
- border-radius: 6px;
- background: transparent;
- color: var(--text-muted);
+ border-radius: 50%;
+ color: #fff;
cursor: pointer;
flex-shrink: 0;
+ transition:
+ background 0.15s,
+ transform 0.1s,
+ opacity 0.15s;
}
-.chats-page .search-clear:hover {
- background: var(--border);
- color: var(--text-primary);
-}
-
-.chats-page .search-clear:focus-visible {
- outline: 2px solid var(--focus-ring);
- outline-offset: 1px;
-}
-
-.chats-page .new-chat-hint {
- margin-block: 0.375rem 0;
- margin-inline: 1.25rem;
- font-size: 0.8125rem;
- color: var(--text-muted);
-}
-
-.chats-page .new-chat-section-label {
- padding-block: 0.875rem 0.375rem;
- padding-inline: 1.25rem;
- font-size: 0.75rem;
- font-weight: 600;
- letter-spacing: 0.04em;
- text-transform: uppercase;
- color: var(--primary-text);
-}
-
-/* The panel's rows are buttons: they take the list row's look, not the global button's. */
-.chats-page button.chat-item-card {
- width: 100%;
- background: transparent;
- border: none;
- border-bottom: 1px solid var(--border);
- color: inherit;
- font: inherit;
- text-align: start;
-}
-
-.chats-page button.chat-item-card:disabled {
- cursor: progress;
- opacity: 0.75;
+.chats-page .btn-send-message:hover:not(:disabled) {
+ background: var(--chat-accent-hover);
}
-.chats-page .action-row .chat-item-name {
- font-weight: 500;
+.chats-page .btn-send-message:active:not(:disabled) {
+ transform: scale(0.94);
}
-.chats-page .chat-avatar.action-avatar {
- background: var(--primary);
- border-color: var(--primary);
- color: #0f172a;
+.chats-page .btn-send-message:disabled {
+ /* Keep the brand silhouette readable while clearly inactive — a bare gray-on-gray glyph
+ reads as "no button here" rather than "send, disabled". */
+ opacity: 0.55;
+ cursor: not-allowed;
}
-.chats-page .select-check {
- width: 20px;
- height: 20px;
- box-sizing: border-box;
- margin-inline-start: auto;
- border: 2px solid var(--border);
- border-radius: 5px;
- display: flex;
- align-items: center;
- justify-content: center;
+/* =============================================================================
+ CONTACT INFO PANEL
+ ============================================================================= */
+.chats-page .contact-info-panel {
+ width: 340px;
flex-shrink: 0;
- color: #fff;
+ display: flex;
+ flex-direction: column;
+ background: var(--chat-panel);
+ border-inline-start: 1px solid var(--chat-divider);
}
-.chats-page .select-check.checked {
- background: var(--primary);
- border-color: var(--primary);
+.chats-page .contact-info-header {
+ height: 64px;
+ display: flex;
+ align-items: center;
+ gap: 0.75rem;
+ padding-block: 0;
+ padding-inline: 0.75rem;
+ background: var(--chat-panel-header);
+ border-bottom: 1px solid var(--chat-divider);
+ font-weight: 500;
+ color: var(--text-primary);
+ box-sizing: border-box;
+ flex-shrink: 0;
}
-.chats-page .new-group-fields {
+.chats-page .contact-info-body {
display: flex;
flex-direction: column;
- gap: 0.625rem;
- padding-block: 0.875rem 0;
- padding-inline: 1.25rem;
+ align-items: center;
+ padding-block: 1.75rem;
+ padding-inline: 1.5rem;
+ overflow-y: auto;
+ text-align: center;
}
-.chats-page .new-group-name {
- padding-block: 0.625rem;
- padding-inline: 0.75rem;
- border: 1px solid var(--border);
- border-radius: var(--radius, 8px);
- background: var(--bg-light);
+.chats-page .contact-info-body h3 {
+ margin-block: 1rem 0.25rem;
+ font-size: 1.25rem;
+ font-weight: 500;
color: var(--text-primary);
+ word-break: break-word;
+}
+
+.chats-page .contact-info-sub {
+ margin: 0;
+ color: var(--chat-meta);
font-size: 0.9375rem;
- outline: none;
}
-.chats-page .new-group-name:focus {
- border-color: var(--focus-ring);
- background: var(--bg-white);
+.chats-page .contact-info-list {
+ width: 100%;
+ margin-block: 1.5rem 0;
+ padding-top: 1rem;
+ border-top: 1px solid var(--chat-divider);
+ text-align: start;
}
-.chats-page .participant-chips {
- display: flex;
- flex-wrap: wrap;
- gap: 0.375rem;
- max-height: 96px;
- overflow-y: auto;
+.chats-page .contact-info-list dt {
+ font-size: 0.8125rem;
+ color: var(--chat-meta);
+ margin-top: 0.875rem;
}
-.chats-page .participant-chip {
- display: inline-flex;
+.chats-page .contact-info-list dt:first-child {
+ margin-top: 0;
+}
+
+.chats-page .contact-info-list dd {
+ margin-block: 0.125rem 0;
+ margin-inline: 0;
+ font-size: 0.9375rem;
+ color: var(--text-primary);
+ display: flex;
align-items: center;
gap: 0.25rem;
- padding-block: 0.125rem;
- padding-inline: 0.625rem 0.25rem;
- border-radius: 999px;
- background: var(--primary-soft);
- color: var(--primary-text);
+ min-width: 0;
+}
+
- .chats-page .contact-info-list dd.mono span {
++.chats-page .contact-info-list dd.mono bdi {
+ font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
font-size: 0.8125rem;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ min-width: 0;
}
-.chats-page .participant-chip button {
+/* =============================================================================
+ CHANNELS AND STATUS: read-only post panes
+ ============================================================================= */
+.chats-page .channel-room {
+ flex: 1;
+ min-height: 0;
display: flex;
- padding: 2px;
- border: none;
- border-radius: 50%;
- background: transparent;
- color: inherit;
- cursor: pointer;
+ flex-direction: column;
+ height: 100%;
}
-.chats-page .new-group-footer {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 0.75rem;
- padding: 0.75rem 1.25rem;
- border-top: 1px solid var(--border);
+.chats-page .chats-room-header {
+ color: var(--chat-icon);
}
-.chats-page .new-group-count {
- font-size: 0.875rem;
- color: var(--text-muted);
+/* The pane icon's only in-flow sibling here is the heading, which has never opted out of shrinking,
+ so without this opt-out the row takes width from the icon as well. The heading absorbs most of the
+ deficit but not all of it, and on the narrowest pane the icon is squeezed to a couple of pixels. */
+.chats-page .chats-room-header > svg {
+ flex-shrink: 0;
}
-.chats-page .new-group-create {
- display: inline-flex;
- align-items: center;
- gap: 0.375rem;
- padding-block: 0.5rem;
- padding-inline: 1rem;
- border: none;
- border-radius: var(--radius, 8px);
- background: var(--primary);
- color: #0f172a;
+.chats-page .chats-room-header h2 {
+ font-size: 1rem;
font-weight: 600;
- cursor: pointer;
+ color: var(--text-primary);
+ text-transform: none;
+ letter-spacing: normal;
+ margin: 0;
+ /* `overflow: hidden` is the load-bearing declaration: it both clips and zeroes this flex item's automatic
+ minimum, so no min-width is needed here or on an ancestor. Without it the other two are inert and a long
+ title runs past the panel edge. */
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
-.chats-page .new-group-create:disabled {
- opacity: 0.55;
- cursor: not-allowed;
+.chats-page .messages-list {
+ flex: 1;
+ min-height: 0;
+ padding: 1.5rem;
+ overflow-y: auto;
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ align-items: flex-start;
+ background-color: var(--chat-wallpaper);
+ background-image: var(--chat-wallpaper-pattern);
+ background-size: 240px 240px;
}
-/* Group info dialog (the global .modal card, inside the page) */
-.chats-page .group-info-modal {
- max-width: 640px;
+.chats-page .messages-list .message-bubble {
+ max-width: 480px;
}
-.chats-page .group-info-title {
- display: flex;
- align-items: center;
- gap: 0.875rem;
+/* A feed post's time sits under its text: there is no tick to tuck in beside it. */
+.chats-page .messages-list .message-time {
+ display: block;
+ margin-top: 0.25rem;
+ text-align: end;
}
-.chats-page .group-info-tile {
- width: 44px;
- height: 44px;
- border-radius: 12px;
- background: var(--primary);
- color: #0f172a;
+.chats-page .channel-media {
+ max-width: 100%;
+ max-height: 320px;
+ border-radius: 6px;
+ display: block;
+ margin-bottom: 0.5rem;
+ object-fit: cover;
+}
+
+/* Shown in place of media that cannot be shown: a status media blob that fails to load, or a
+ channel post whose media has no URL. */
+.chats-page .status-media-placeholder {
+ display: block;
+ font-size: 0.85rem;
+ color: var(--chat-meta);
+ margin-bottom: 0.5rem;
+}
+
+/* =============================================================================
+ GENERAL CHATS STYLES & ERROR STATES
+ ============================================================================= */
+.chats-page .chats-loading-container,
+.chats-page .chats-error-state {
display: flex;
+ flex-direction: column;
align-items: center;
justify-content: center;
- flex-shrink: 0;
+ background: var(--bg-white);
+ padding-block: 4rem;
+ padding-inline: 2rem;
+ text-align: center;
+ color: var(--text-secondary);
+ flex: 1;
}
-.chats-page .group-info-heading {
- display: flex;
- flex-direction: column;
- min-width: 0;
+.chats-page .chats-error-state h3 {
+ font-size: 1.25rem;
+ margin-block: 1rem 0.5rem;
+ color: var(--text-primary);
}
-.chats-page .group-info-subtitle {
- font-size: 0.875rem;
- font-weight: 400;
+.chats-page .chats-error-state p {
+ font-size: 0.9375rem;
+ max-width: 450px;
+ margin: 0;
color: var(--text-muted);
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
}
-.chats-page .group-info-toolbar {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: 0.75rem;
- padding-block: 1rem 0;
- padding-inline: 1.5rem;
++.chats-page .chats-error-state button {
++ margin-top: 1.5rem;
+ }
+
-.chats-page .group-info-toolbar .chats-tab {
- display: inline-flex;
+.chats-page .text-warn {
+ color: var(--warning-text);
+}
+
+/* Real-time connection-lost banner */
+.chats-page .chats-reconnect-banner {
+ display: flex;
align-items: center;
- gap: 0.375rem;
- padding-inline: 0.875rem;
+ gap: 0.5rem;
+ padding-block: 0.5rem;
+ padding-inline: 1rem;
+ background: rgba(234, 88, 12, 0.1);
+ color: var(--warning-text);
+ font-size: 0.875rem;
+ flex-shrink: 0;
}
-.chats-page .group-info-toolbar .icon-btn {
+.chats-page .chats-reconnect-banner button {
margin-inline-start: auto;
}
-.chats-page .group-info-badge {
- display: inline-flex;
- align-items: center;
- gap: 0.375rem;
- padding-block: 0.375rem;
- padding-inline: 0.75rem;
+/* =============================================================================
+ STATUS COMPOSE MODAL
+ ============================================================================= */
+.chats-page .status-compose-modal .compose-type-toggle {
+ display: flex;
border: 1px solid var(--border);
border-radius: var(--radius, 8px);
- background: var(--bg-light);
- color: var(--text-secondary);
- font-size: 0.8125rem;
+ overflow: hidden;
+ margin-bottom: 1rem;
}
-.chats-page .group-info-badge.admin {
- background: var(--primary-soft);
- border-color: transparent;
- color: var(--primary-text);
+.chats-page .status-compose-modal .compose-type-toggle button {
+ flex: 1;
+ padding-block: 0.625rem;
+ padding-inline: 1rem;
+ font-size: 0.875rem;
+ font-weight: 500;
+ background: var(--bg-white);
+ border: none;
+ cursor: pointer;
+ transition: all 0.2s;
+ color: var(--text-secondary);
}
-.chats-page .group-info-state {
- display: flex;
- justify-content: center;
- padding: 2rem;
- color: var(--text-muted);
+.chats-page .status-compose-modal .compose-type-toggle button:first-child {
+ border-inline-end: 1px solid var(--border);
}
-.chats-page .group-info-form {
- display: flex;
- flex-direction: column;
- gap: 1rem;
+.chats-page .status-compose-modal .compose-type-toggle button.active {
+ background: var(--primary);
- color: white;
++ color: #0f172a;
}
-.chats-page .group-info-field {
+.chats-page .status-compose-modal .compose-field {
display: flex;
flex-direction: column;
gap: 0.375rem;
@@@ -3043,78 -2529,96 +3123,85 @@@
padding-inline: 0.75rem;
border: 1px solid var(--border);
border-radius: var(--radius, 8px);
-- background: var(--bg-light);
++ background-color: var(--bg-light);
color: var(--text-primary);
- font: inherit;
- font-weight: 400;
+ font-size: 0.875rem;
outline: none;
+ box-sizing: border-box;
+ font-family: inherit;
}
-.chats-page .group-info-field textarea {
- min-height: 6rem;
- resize: vertical;
-}
-
-.chats-page .group-info-field input:focus,
-.chats-page .group-info-field textarea:focus,
-.chats-page .group-info-add input:focus,
-.chats-page .chat-dialog-form input:focus {
+.chats-page .status-compose-modal textarea:focus,
+.chats-page .status-compose-modal input:focus,
++.chats-page .status-compose-modal input[type='text']:focus,
++.chats-page .status-compose-modal input[type='url']:focus,
+.chats-page .status-compose-modal select:focus {
- border-color: var(--primary);
- background: var(--bg-white);
+ border-color: var(--focus-ring);
- background: var(--bg-white);
- box-shadow: 0 0 0 3px var(--primary-soft);
++ background-color: var(--bg-white);
+ box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}
-.chats-page .group-info-field input:disabled,
-.chats-page .group-info-field textarea:disabled {
- opacity: 0.7;
- cursor: not-allowed;
+.chats-page .status-compose-modal textarea {
+ min-height: 100px;
+ resize: vertical;
}
-.chats-page .group-info-picture {
+.chats-page .status-compose-modal .compose-row {
display: flex;
- align-items: center;
gap: 1rem;
- padding: 0.875rem;
- border: 1px solid var(--border);
- border-radius: var(--radius, 8px);
- background: var(--bg-light);
- color: var(--text-primary);
- font: inherit;
- font-weight: 400;
- text-align: start;
- cursor: pointer;
}
-.chats-page .group-info-picture:hover:not(:disabled) {
- border-color: var(--primary);
-}
-
-.chats-page .group-info-picture:disabled {
- cursor: default;
-}
-
-.chats-page .chat-avatar.avatar-lg {
- width: 88px;
- height: 88px;
+.chats-page .status-compose-modal .compose-row .compose-field {
+ flex: 1;
}
-.chats-page .group-info-members {
- display: flex;
- flex-direction: column;
- gap: 0.75rem;
+.chats-page .status-compose-modal input[type='color'] {
+ width: 100%;
+ height: 38px;
+ padding: 2px;
+ border: 1px solid var(--border);
+ border-radius: var(--radius, 8px);
+ background: var(--bg-light);
+ cursor: pointer;
+ box-sizing: border-box;
}
-.chats-page .group-info-add {
- display: flex;
- gap: 0.5rem;
++/* The rule above repaints the border over `input:focus` at the same weight, so a focused color input needs its own. */
++.chats-page .status-compose-modal input[type='color']:focus {
++ border-color: var(--focus-ring);
+ }
+
-.chats-page .group-info-add button {
- display: inline-flex;
- align-items: center;
- gap: 0.375rem;
- flex-shrink: 0;
+.chats-page .status-compose-modal input[type='file'] {
+ width: 100%;
+ font-size: 0.8125rem;
+ color: var(--text-secondary);
}
-.chats-page .group-info-count {
- font-size: 0.8125rem;
- font-weight: 600;
+.chats-page .status-compose-modal .compose-image-or {
+ font-size: 0.75rem;
color: var(--text-muted);
+ text-align: center;
+ margin-block: 0.5rem;
}
-.chats-page .group-info-list {
- margin: 0;
- padding: 0;
- list-style: none;
+.chats-page .status-compose-modal .compose-recipients {
+ border: 1px solid var(--border);
+ border-radius: var(--radius, 8px);
+ max-height: 180px;
+ overflow-y: auto;
+ background: var(--bg-light);
+ margin-top: 0.5rem;
}
-.chats-page .group-info-list li {
+.chats-page .status-compose-modal .compose-recipient-row {
display: flex;
align-items: center;
- gap: 0.75rem;
+ gap: 0.5rem;
padding-block: 0.5rem;
+ padding-inline: 0.75rem;
+ font-size: 0.875rem;
+ color: var(--text-primary);
+ cursor: pointer;
border-bottom: 1px solid var(--border);
}
diff --cc dashboard/src/pages/Chats.features.test.ts
index 3b5b76fce,ab492ba19..6cf9db18d
--- a/dashboard/src/pages/Chats.features.test.ts
+++ b/dashboard/src/pages/Chats.features.test.ts
@@@ -1,12 -1,11 +1,12 @@@
-// Render tests for what the chat page offers beyond its data flow, which Chats.test.ts covers: the quick
-// filters, the new-chat panel, and the chat row actions with their dialogs, each with its wire effect. The page is wrapped in the providers
+// Render tests for what the chat page offers beyond its data flow, which Chats.test.ts covers: the session
+// switcher, the contact panel, the message search behind its toggle, the quick filters, the new-chat panel, and
+// the chat row actions with their dialogs, each with its wire effect. The page is wrapped in the providers
// App.tsx uses and the backend is stubbed at the fetch layer; runs under the bare `node --test` runner.
import '../test-helpers/register-hooks.ts';
- import { test, before, afterEach } from 'node:test';
+ import { test, before, afterEach, type TestContext } from 'node:test';
import assert from 'node:assert/strict';
import { createElement } from 'react';
- import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
+ import { QueryClient, QueryClientProvider, focusManager } from '@tanstack/react-query';
import type { Session, Chat } from '../services/api';
import { lastSocket, resetSocketDouble } from '../test-helpers/socket-io-double.ts';
@@@ -34,6 -23,6 +34,18 @@@ let listOffline = false
const SECOND_SESSION: Session = { ...SESSION, id: 'session-3', name: 'Second', phone: '15559876543' };
let listSecond = false;
++// The first account down at load (every session down, with `listOffline`), and an account created after the page
++// read the list, served once a test turns `listCreated` on.
++let mainDown = false;
++const CREATED_SESSION: Session = {
++ ...SESSION,
++ id: 'session-4',
++ name: 'Fresh',
++ phone: '15550007777',
++ status: 'qr_ready',
++};
++let listCreated: Session | null = null;
++
// Responses a test holds back until it releases them, by route name.
const gates = new Map<string, Promise<void>>();
function hold(name: string): () => void {
@@@ -130,13 -186,16 +209,23 @@@ function installFetchStub(): void
gates.get(name)?.then(response) ?? Promise.resolve(response());
if (method === 'GET' && path === '/api/sessions') {
- return Promise.resolve(jsonResponse([SESSION, ...(listSecond ? [SECOND_SESSION] : [])]));
+ return Promise.resolve(
- jsonResponse([SESSION, ...(listSecond ? [SECOND_SESSION] : []), ...(listOffline ? [OFFLINE_SESSION] : [])]),
++ jsonResponse([
++ mainDown ? { ...SESSION, status: 'disconnected' } : SESSION,
++ ...(listSecond ? [SECOND_SESSION] : []),
++ ...(listOffline ? [OFFLINE_SESSION] : []),
++ ...(listCreated ? [listCreated] : []),
++ ]),
+ );
}
if (method === 'GET' && path.startsWith(`${base}/chats?`)) {
- return Promise.resolve(
- jsonResponse([CHAT, ...(listGroup ? [GROUP] : []), ...(listExtra ? [PUSH_ONLY_CHAT, LID_CHAT] : [])]),
+ return gated('chats', () =>
+ jsonResponse([
+ { ...CHAT, ...aliceNow },
+ ...(listGroup ? [GROUP] : []),
+ ...(listExtra ? [PUSH_ONLY_CHAT, LID_CHAT, NUMBER_NAMED_CHAT] : []),
+ ...Array.from({ length: extraLidChats }, (_, n) => extraLidChat(n)),
+ ]),
);
}
const groupPath = `${base}/groups/${encodeURIComponent(GROUP.id)}`;
@@@ -250,11 -380,23 +410,26 @@@ afterEach(async () =>
client.clear();
}
fetchCalls.length = 0;
+ listOffline = false;
listSecond = false;
++ mainDown = false;
++ listCreated = null;
listExtra = false;
listDuplicateContact = false;
+ failContacts = false;
+ failLidPhones = false;
+ failingLidIds.clear();
+ garbleLidPhones = false;
+ numberNotRegistered = false;
+ throttlePhoneLookups = false;
+ phoneLookupTimes.length = 0;
+ extraLidChats = 0;
+ for (const id of Object.keys(lidPhones)) delete lidPhones[id];
+ for (const key of Object.keys(aliceNow)) delete aliceNow[key as keyof Chat];
+ aliceThread = [];
declineWrites = false;
+ declineReads = false;
+ for (const id of Object.keys(pictureFor)) delete pictureFor[id];
gates.clear();
listGroup = false;
groupAdmin = true;
@@@ -278,30 -427,8 +460,82 @@@ function renderPage({ reactStrictMode
);
}
-test('a read-only key is offered no new chat', async () => {
- const { screen } = rtl;
+test('the contact panel opens from the room header and Escape closes it before the room', async () => {
+ const { screen, fireEvent, waitFor, within } = rtl;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+
+ fireEvent.click(within(container.querySelector('.room-header') as HTMLElement).getByText('Alice'));
+ const panel = await waitFor(() => container.querySelector('.contact-info-panel') as HTMLElement);
+ assert.ok(within(panel).getByText(CHAT.id), 'the panel shows the raw chat id');
+
+ fireEvent.keyDown(document, { key: 'Escape' });
+ await waitFor(() => assert.equal(container.querySelector('.contact-info-panel'), null, 'the panel stayed open'));
+ assert.ok(container.querySelector('.room-header'), 'Escape closed the room along with the panel');
+});
+
++test('the contact panel isolates the chat id left to right, so an RTL page keeps "@c.us" at its end', async () => {
++ const { screen, fireEvent, waitFor, within } = rtl;
++ const { container } = renderPage();
++ fireEvent.click(await screen.findByText('Alice'));
++ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
++ fireEvent.click(within(container.querySelector('.room-header') as HTMLElement).getByText('Alice'));
++ const panel = await waitFor(() => container.querySelector('.contact-info-panel') as HTMLElement);
++
++ const id = within(panel).getByText(CHAT.id);
++ assert.equal(id.tagName, 'BDI');
++ assert.equal(id.getAttribute('dir'), 'ltr');
++});
++
++test('the contact panel closes with its room: on closing it, on opening another chat and on a session switch', async () => {
++ const { screen, fireEvent, waitFor, within } = rtl;
++ listGroup = true;
++ listSecond = true;
++ const { container } = renderPage();
++ const panel = () => container.querySelector('.contact-info-panel');
++ const openAliceWithPanel = async () => {
++ fireEvent.click(within(container.querySelector('.chats-sidebar') as HTMLElement).getByText('Alice'));
++ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
++ fireEvent.click(within(container.querySelector('.room-header') as HTMLElement).getByText('Alice'));
++ await waitFor(() => assert.ok(panel(), 'the panel did not open'));
++ };
++ await screen.findByText('Alice');
++
++ // Closing the room closes the panel, and the chat opened again comes without it.
++ await openAliceWithPanel();
++ fireEvent.click(container.querySelector('.room-menu-trigger') as HTMLElement);
++ fireEvent.click(screen.getByRole('button', { name: 'Close chat' }));
++ await waitFor(() => assert.equal(container.querySelector('.room-header'), null, 'the room stayed open'));
++ fireEvent.click(within(container.querySelector('.chats-sidebar') as HTMLElement).getByText('Alice'));
++ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open again'));
++ assert.equal(panel(), null, 'the chat opened again with the panel of its last visit');
++
++ // Another chat opens without it.
++ await openAliceWithPanel();
++ fireEvent.click(within(container.querySelector('.chats-sidebar') as HTMLElement).getByText('Team'));
++ await waitFor(() => assert.equal(container.querySelector('.room-header .room-contact-name')?.textContent, 'Team'));
++ assert.equal(panel(), null, 'the next chat opened with the panel of the last one');
++
++ // A session switch closes it too, and the same chat on the other account opens without it.
++ await openAliceWithPanel();
++ switchSession(container, SECOND_SESSION.name);
++ await waitFor(() => assert.equal(selectedSessionName(container), SECOND_SESSION.name));
++ assert.equal(panel(), null, 'the panel stayed open across the session switch');
++ fireEvent.click(await within(container.querySelector('.chats-sidebar') as HTMLElement).findByText('Alice'));
++ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
++ assert.equal(panel(), null, 'the chat on the other session opened with the panel');
++});
++
+test('the message search sits behind its toggle, and a read-only key is offered neither it nor a new chat', async () => {
+ const { screen, fireEvent } = rtl;
+ renderPage();
+ await screen.findByText('Alice');
+ assert.ok(!screen.queryByLabelText('Search messages…'), 'the search was open before its toggle was pressed');
+ fireEvent.click(screen.getByRole('button', { name: 'Search messages' }));
+ assert.ok(screen.getByLabelText('Search messages…'), 'the toggle did not open the search');
+ rtl.cleanup();
+
window.sessionStorage.setItem('openwa_user_role', 'viewer');
renderPage();
await screen.findByText('Alice');
@@@ -354,6 -480,256 +588,256 @@@ for (const reactStrictMode of [false, t
});
}
+ test('the New chat search clear button returns focus to the field it cleared', async () => {
+ const { screen, fireEvent } = rtl;
+ renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'New chat' }));
+ const field = screen.getByLabelText('Search name or number with country code') as HTMLInputElement;
+ fireEvent.change(field, { target: { value: 'Bo' } });
+ const clear = screen.getByRole('button', { name: 'Clear search' });
+ // A keyboard user reaches the button with Tab and presses Enter on it; the button then leaves the page.
+ clear.focus();
+ fireEvent.click(clear);
+
+ assert.equal(field.value, '');
+ assert.ok(!screen.queryByRole('button', { name: 'Clear search' }), 'the clear button stayed');
+ assert.equal(document.activeElement === field, true, `focus is on "${focusedName()}", not on the field`);
+ });
+
+ // ── The number check answers a phone id, while a contact that moved to privacy-id addressing keeps its conversation
+ // under its @lid: starting a chat with that number has to find it. ──
+
+ const phoneRequests = () =>
+ fetchCalls.filter(c => c.method === 'GET' && /\/contacts\/[^/]+\/phone$/.test(c.path)).map(c => c.path);
+
+ /** Type the number the new chat tests use into the panel and press Start chat. */
+ async function startChatWithTypedNumber(): Promise<void> {
+ const { screen, fireEvent } = rtl;
+ fireEvent.click(screen.getByRole('button', { name: 'New chat' }));
+ fireEvent.change(screen.getByLabelText('Search name or number with country code'), {
+ target: { value: TYPED_NUMBER },
+ });
+ fireEvent.click(await screen.findByRole('button', { name: /^Start chat with/ }));
+ }
+
+ const listedChatCards = (container: HTMLElement) => container.querySelectorAll('.chats-list .chat-item-card').length;
+
+ test('a typed number whose chat the list holds under a privacy id opens that chat, not a new one', async () => {
+ const { screen, waitFor, within } = rtl;
+ listExtra = true;
+ lidPhones[LID_CHAT.id] = '15550009999';
+ const { container } = renderPage();
+ await screen.findByText('Lia');
+ const before = listedChatCards(container);
+ await startChatWithTypedNumber();
+
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the chat did not open'));
+ await within(container.querySelector('.room-header') as HTMLElement).findByText('Lia');
+ assert.equal(listedChatCards(container), before, 'a second chat was added beside the one the list holds');
+ assert.equal(
+ phoneRequests().filter(path => path.includes(encodeURIComponent(LID_CHAT.id))).length,
+ 1,
+ 'the engine was asked about the privacy id more than once',
+ );
+ });
+
+ test('a privacy-id chat of another phone is not mistaken for the number, which opens a new chat', async () => {
+ const { screen, waitFor, within } = rtl;
+ listExtra = true;
+ lidPhones[LID_CHAT.id] = '15550007777';
+ const { container } = renderPage();
+ await screen.findByText('Lia');
+ const before = listedChatCards(container);
+ await startChatWithTypedNumber();
+
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the chat did not open'));
+ await within(container.querySelector('.room-header') as HTMLElement).findByText('15550009999');
+ assert.equal(listedChatCards(container), before + 1, 'the new chat was not added to the list');
+ });
+
+ test('a privacy id the engine cannot resolve right now does not stop a chat from opening', async () => {
+ const { screen, waitFor, within } = rtl;
+ listExtra = true;
+ failLidPhones = true;
+ const { container } = renderPage();
+ await screen.findByText('Lia');
+ await startChatWithTypedNumber();
+
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the chat did not open'));
+ await within(container.querySelector('.room-header') as HTMLElement).findByText('15550009999');
+ assert.ok(!screen.queryByText('Could not check the number'), 'a failed lookup was shown as a failed number check');
+ });
+
+ test('one privacy id whose lookup fails does not hide the chat another privacy id holds', async () => {
+ const { screen, waitFor } = rtl;
+ extraLidChats = 2;
+ // The newer chat's lookup answers 503 while the older one resolves to the typed number.
+ failingLidIds.add(extraLidChat(0).id);
+ lidPhones[extraLidChat(1).id] = '15550009999';
+ const { container } = renderPage();
+ await screen.findByText('Lid 0');
+ const before = listedChatCards(container);
+ await startChatWithTypedNumber();
+
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the chat did not open'));
- assert.equal(container.querySelector('.room-header .room-contact-info h3')?.textContent, 'Lid 1');
++ assert.equal(container.querySelector('.room-header .room-contact-name')?.textContent, 'Lid 1');
+ assert.equal(listedChatCards(container), before, 'a second chat was added beside the one the list holds');
+ });
+
+ test('an answer about a privacy id that the page cannot read does not stop a chat from opening', async () => {
+ const { screen, waitFor, within } = rtl;
+ listExtra = true;
+ garbleLidPhones = true;
+ const { container } = renderPage();
+ await screen.findByText('Lia');
+ await startChatWithTypedNumber();
+
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the chat did not open'));
+ await within(container.querySelector('.room-header') as HTMLElement).findByText('15550009999');
+ assert.ok(!screen.queryByText('Could not check the number'), 'a failed lookup was shown as a failed number check');
+ });
+
+ // ── A phone number inside a sentence is placed in a left-to-right isolate: its plus sign and spaces are neutral to
+ // the bidi algorithm, so in a right-to-left sentence the digit groups would be shown in reverse order. ──
+
+ const LTR_NUMBER = `${String.fromCodePoint(0x2066)}+1 555 000 9999${String.fromCodePoint(0x2069)}`;
+
+ test('the typed number keeps its digit groups together in the start chat label', async () => {
+ const { screen, fireEvent } = rtl;
+ renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'New chat' }));
+ fireEvent.change(screen.getByLabelText('Search name or number with country code'), {
+ target: { value: TYPED_NUMBER },
+ });
+ const start = await screen.findByRole('button', { name: /^Start chat with/ });
+ assert.equal(start.textContent?.includes(LTR_NUMBER), true, `the label is not isolated: "${start.textContent}"`);
+ });
+
+ test('the typed number keeps its digit groups together in the add to group label', async () => {
+ const { screen, fireEvent } = rtl;
+ renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'New chat' }));
+ fireEvent.click(screen.getByRole('button', { name: 'New group' }));
+ fireEvent.change(screen.getByLabelText('Search participants or enter a number'), { target: { value: TYPED_NUMBER } });
+ const add = await screen.findByRole('button', { name: /^Add \S/ });
+ assert.equal(add.textContent?.includes(LTR_NUMBER), true, `the label is not isolated: "${add.textContent}"`);
+ });
+
+ test('the number a check finds unregistered is named inside an isolate in the panel toast', async () => {
+ const { screen, fireEvent } = rtl;
+ numberNotRegistered = true;
+ renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'New chat' }));
+ fireEvent.change(screen.getByLabelText('Search name or number with country code'), {
+ target: { value: TYPED_NUMBER },
+ });
+ fireEvent.click(await screen.findByRole('button', { name: /^Start chat with/ }));
+ const toast = await screen.findByText(/is not registered on WhatsApp/);
+ assert.equal(toast.textContent?.includes(LTR_NUMBER), true, `the toast is not isolated: "${toast.textContent}"`);
+ });
+
+ // A member with no name is named by a phone, in the member's own button labels and in the remove confirmation.
+ const LTR_BOB = `${String.fromCodePoint(0x2066)}+1 555 000 2222${String.fromCodePoint(0x2069)}`;
+
+ test('an unnamed member is named inside an isolate in the group dialog button labels', async () => {
+ const { fireEvent, within } = rtl;
+ listGroup = true;
+ bobUnnamed = true;
+ renderPage();
+ const dialog = await openGroupInfo();
+ fireEvent.click(within(dialog).getByRole('tab', { name: 'Participants' }));
+ assert.ok(within(dialog).getByRole('button', { name: `Remove: ${LTR_BOB}` }), 'the remove label is not isolated');
+ assert.ok(within(dialog).getByRole('button', { name: `Make admin: ${LTR_BOB}` }), 'the admin label is not isolated');
+ });
+
+ test('the remove confirmation names an unnamed member inside an isolate', async () => {
+ const { fireEvent, within } = rtl;
+ listGroup = true;
+ bobUnnamed = true;
+ const confirm = window.confirm;
+ try {
+ renderPage();
+ const dialog = await openGroupInfo();
+ fireEvent.click(within(dialog).getByRole('tab', { name: 'Participants' }));
+ let asked = '';
+ window.confirm = message => {
+ asked = String(message);
+ return false;
+ };
+ fireEvent.click(within(dialog).getByRole('button', { name: /^Remove: / }));
+ assert.equal(asked, `Remove ${LTR_BOB} from the group?`);
+ } finally {
+ window.confirm = confirm;
+ }
+ });
+
+ test('the number a check finds unregistered is named inside an isolate when adding to a group', async () => {
+ const { screen, fireEvent, within } = rtl;
+ listGroup = true;
+ numberNotRegistered = true;
+ renderPage();
+ const dialog = await openGroupInfo();
+ fireEvent.click(within(dialog).getByRole('tab', { name: 'Participants' }));
+ fireEvent.change(within(dialog).getByLabelText('Add a number with country code'), {
+ target: { value: TYPED_NUMBER },
+ });
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Add' }));
+ const toast = await screen.findByText(/is not registered on WhatsApp/);
+ assert.equal(toast.textContent?.includes(LTR_NUMBER), true, `the toast is not isolated: "${toast.textContent}"`);
+ });
+
+ test('only the newest privacy-id chats are asked about, not every one the list holds', async () => {
+ const { screen, waitFor } = rtl;
+ extraLidChats = 60;
+ const { container } = renderPage();
+ await screen.findByText('Lid 0');
+ await startChatWithTypedNumber();
+
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the chat did not open'), { timeout: 8000 });
+ assert.equal(phoneRequests().length, 30, 'the newest 30 privacy ids, no more and no fewer, were asked about');
+ });
+
+ test('privacy ids are asked about at a pace the gateway accepts, and the search ends at the match', async () => {
+ const { screen, waitFor } = rtl;
+ extraLidChats = 40;
+ throttlePhoneLookups = true;
+ // The thirteenth newest holds the number: it is asked about in the third group of five, after ten requests.
+ lidPhones[extraLidChat(12).id] = '15550009999';
+ const { container } = renderPage();
+ await screen.findByText('Lid 0');
+ const before = listedChatCards(container);
+ await startChatWithTypedNumber();
+
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the chat did not open'), { timeout: 8000 });
- assert.equal(container.querySelector('.room-header .room-contact-info h3')?.textContent, 'Lid 12');
++ assert.equal(container.querySelector('.room-header .room-contact-name')?.textContent, 'Lid 12');
+ assert.equal(listedChatCards(container), before, 'a second chat was added beside the one the list holds');
+ assert.equal(phoneRequests().length, 15, 'ids after the match were asked about, or a group was asked twice');
+ });
+
+ test('privacy ids the page already holds answers for are kept for a day and neither asked again nor waited for', async () => {
+ const { screen, waitFor } = rtl;
+ extraLidChats = 10;
+ const { container } = renderPage();
+ await screen.findByText('Lid 0');
+ const { resolvedPhoneQuery } = await import('../hooks/useResolvedPhone.ts');
+ const client = queryClients[0];
+ for (let n = 0; n < extraLidChats; n++) await client.fetchQuery(resolvedPhoneQuery(SESSION.id, extraLidChat(n).id));
+ const held = client.getQueryCache().find({ queryKey: ['resolvedPhone', SESSION.id, extraLidChat(0).id] });
+ assert.equal(held?.gcTime, 24 * 60 * 60 * 1000, 'an answer nothing observes would be collected after minutes');
+ fetchCalls.length = 0;
+ await startChatWithTypedNumber();
+
+ // Two groups of five that reached the gateway would be a second apart.
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the chat did not open in time'), {
+ timeout: 800,
+ });
+ assert.equal(phoneRequests().length, 0, 'an answer the page holds was asked for again');
+ });
+
for (const reactStrictMode of [false, true]) {
test(`a group is created with the picked contacts on Baileys, and whatsapp-web.js is not offered one${reactStrictMode ? ' (StrictMode)' : ''}`, async () => {
const { screen, fireEvent, waitFor, within } = rtl;
@@@ -383,115 -759,6 +867,165 @@@
});
}
+test('the session switcher lists every session with its state, and only a connected one can be picked', async () => {
+ const { screen, fireEvent } = rtl;
+ listOffline = true;
+ renderPage();
+ await screen.findByText('Alice');
+
+ const trigger = screen.getByRole('button', { name: /Main/ });
+ fireEvent.click(trigger);
+ const options = screen.getAllByRole('option');
+ assert.deepEqual(
+ options.map(option => [
+ option.textContent?.includes('Main'),
+ option.getAttribute('aria-selected'),
+ option.matches(':disabled'),
+ ]),
+ [
+ [true, 'true', false],
+ [false, 'false', true],
+ ],
+ );
+ assert.ok(
+ screen.getByRole('img', { name: 'Disconnected' }),
+ 'the offline session does not say why it cannot be opened',
+ );
+
+ fireEvent.change(screen.getByLabelText('Search sessions...'), { target: { value: 'marie' } });
+ assert.equal(screen.getAllByRole('option').length, 1, 'the search did not narrow the list');
+});
+
+test('the session switcher follows live session status: a session that connects can be picked, one that drops cannot', async () => {
+ const { screen, fireEvent, act } = rtl;
+ listOffline = true;
+ listSecond = true;
+ renderPage();
+ await screen.findByText('Alice');
+ const pushStatus = (sessionId: string, status: string) =>
+ act(() => {
+ lastSocket()?.receive('message', {
+ type: 'event',
+ timestamp: new Date(1_700_003_000_000).toISOString(),
+ payload: { event: 'session.status', sessionId, data: { status } },
+ });
+ });
+ const disabledOf = (name: string) =>
+ (screen.getAllByRole('option').find(option => option.textContent?.includes(name)) as HTMLButtonElement).disabled;
+
+ fireEvent.click(screen.getByRole('button', { name: /Main/ }));
+ assert.deepEqual([disabledOf('Main'), disabledOf('Second'), disabledOf('Marie Haas')], [false, false, true]);
+
+ pushStatus(OFFLINE_SESSION.id, 'ready');
+ pushStatus(SECOND_SESSION.id, 'disconnected');
+ assert.equal(disabledOf('Marie Haas'), false, 'a session that connected stayed unpickable');
+ assert.equal(disabledOf('Second'), true, 'a session that dropped could still be picked');
+
+ // The open session stays selected when it drops; the switcher shows its state.
+ pushStatus(SESSION.id, 'disconnected');
+ assert.ok(screen.getByRole('button', { name: /Main/ }), 'the open session left the switcher');
+});
+
++/** Pushes a session.status frame over the socket, as the gateway does on the session feed. */
++const pushSessionStatus = (sessionId: string, status: string) =>
++ rtl.act(() => {
++ lastSocket()?.receive('message', {
++ type: 'event',
++ timestamp: new Date(1_700_003_000_000).toISOString(),
++ payload: { event: 'session.status', sessionId, data: { status } },
++ });
++ });
++
++test('with every session down at load, the first one that connects is selected and its chats load', async () => {
++ const { screen, waitFor } = rtl;
++ mainDown = true;
++ listOffline = true;
++ const { container } = renderPage();
++ await screen.findByText('No connected sessions');
++ assert.ok(!screen.queryByText('Alice'), 'a chat list loaded for a session that is down');
++
++ pushSessionStatus(SESSION.id, 'ready');
++ await waitFor(() => assert.equal(selectedSessionName(container), SESSION.name));
++ await screen.findByText('Alice');
++
++ // A second session that connects later does not take the selection from the first.
++ pushSessionStatus(OFFLINE_SESSION.id, 'ready');
++ await settle();
++ assert.equal(selectedSessionName(container), SESSION.name, 'the selection moved to the session that connected next');
++});
++
++test('a session created after the page loaded joins the switcher, and can be picked once it connects', async () => {
++ const { screen, fireEvent, waitFor } = rtl;
++ const { container } = renderPage();
++ await screen.findByText('Alice');
++ const sessionReads = () => fetchCalls.filter(c => c.method === 'GET' && c.path === '/api/sessions').length;
++ assert.equal(sessionReads(), 1);
++
++ listCreated = CREATED_SESSION;
++ pushSessionStatus(CREATED_SESSION.id, 'qr_ready');
++ await waitFor(() => assert.equal(sessionReads(), 2, 'a status for an unknown session did not read the list again'));
++ fireEvent.click(container.querySelector('.session-switcher-btn') as HTMLElement);
++ const option = () => screen.getAllByRole('option').find(o => o.textContent?.includes(CREATED_SESSION.name));
++ await waitFor(() => assert.ok(option(), 'the new session is not in the switcher'));
++ assert.equal((option() as HTMLButtonElement).disabled, true, 'a session still pairing can be picked');
++
++ // Known now, so its next status is applied from the feed alone.
++ pushSessionStatus(CREATED_SESSION.id, 'ready');
++ assert.equal((option() as HTMLButtonElement).disabled, false, 'the new session stayed unpickable once it connected');
++ assert.equal(sessionReads(), 2, 'a status for a listed session read the list again');
++ assert.equal(selectedSessionName(container), SESSION.name, 'the open session changed');
++});
++
+test('the session switcher links to pairing another number only for a key that may create a session', async () => {
+ const { screen, fireEvent } = rtl;
+ const { MemoryRouter } = await import('react-router-dom');
+ const renderInRouter = () => {
+ const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false, gcTime: 1_000 } } });
+ queryClients.push(queryClient);
+ return rtl.render(
+ createElement(
+ MemoryRouter,
+ null,
+ createElement(
+ QueryClientProvider,
+ { client: queryClient },
+ createElement(RoleProvider, null, createElement(ToastProvider, null, createElement(Chats))),
+ ),
+ ),
+ );
+ };
+
+ renderInRouter();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: /Main/ }));
+ assert.ok(screen.getByText('Pair another number'), 'an unscoped operator key got no pairing link');
+ rtl.cleanup();
+
+ // A session-scoped key is refused on the create route, so the link would end on a page with nothing to do.
+ window.sessionStorage.setItem('openwa_key_scoped', 'true');
+ try {
+ renderInRouter();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: /Main/ }));
+ assert.ok(!screen.queryByText('Pair another number'), 'a session-scoped key got a pairing link');
+ } finally {
+ window.sessionStorage.removeItem('openwa_key_scoped');
+ }
+});
+
+test('Escape closes the session switcher, not the open chat', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+
+ fireEvent.click(screen.getByRole('button', { name: /Main/ }));
+ assert.ok(screen.getByRole('listbox'));
+ fireEvent.keyDown(document, { key: 'Escape' });
+ assert.ok(!screen.queryByRole('listbox'), 'Escape left the switcher open');
+ assert.ok(container.querySelector('.room-header'), 'Escape closed the chat behind the switcher');
+});
+
test('a group row offers its actions, and marking it unread badges the row', async () => {
const { screen, fireEvent, waitFor } = rtl;
listGroup = true;
@@@ -590,54 -986,182 +1253,186 @@@ test('a participant the gateway refuse
);
assert.ok(!screen.queryByText('The action failed'), 'an accepted write was reported as failed');
- refuseMember = true;
- fireEvent.click(within(dialog).getByRole('button', { name: 'Make admin: Bob' }));
+ refuseMember = 'all';
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Remove admin: Bob' }));
await screen.findByText('The action failed');
- await screen.findByText('15550002222: not-authorized');
- assert.equal(promotes(), 2);
+ await screen.findByText(
+ /^demoteParticipants failed for all 1 participant\(s\) in group .*15550002222@c\.us \(403\)$/,
+ );
+ assert.equal(writesTo('demote'), 1);
});
- test('a member who is no admin sees the group read-only, and a viewer key gets no write actions', async () => {
+ test('a participant refused inside a 200 answer is named with the reason it gave', async () => {
const { screen, fireEvent, within } = rtl;
listGroup = true;
- groupAdmin = false;
- window.sessionStorage.setItem('openwa_user_role', 'viewer');
renderPage();
- await screen.findByText('Team');
- // A viewer may look at a 1:1 contact, and nothing else.
- fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
- assert.ok(screen.getByRole('button', { name: 'Contact info' }));
- assert.ok(!screen.queryByRole('button', { name: 'Block contact' }), 'a viewer was offered blocking');
- assert.ok(!screen.queryByRole('button', { name: 'Pin chat' }), 'a viewer was offered pinning');
- fireEvent.keyDown(document, { key: 'Escape' });
- fireEvent.click(screen.getByRole('button', { name: 'Actions for Team' }));
- assert.ok(!screen.queryByRole('button', { name: 'Mark as unread' }), 'a viewer was offered mark-as-unread');
- assert.ok(!screen.queryByRole('button', { name: 'Leave group' }), 'a viewer was offered leaving the group');
- fireEvent.click(screen.getByRole('button', { name: 'Group info' }));
+ const dialog = await openGroupInfo();
+ fireEvent.click(within(dialog).getByRole('tab', { name: 'Participants' }));
- const dialog = await screen.findByRole('dialog');
- await within(dialog).findByText(`Not an admin via ${SESSION.name}`);
- assert.ok((within(dialog).getByDisplayValue('Team') as HTMLInputElement).disabled, 'the name is editable');
- assert.ok((within(dialog).getByRole('button', { name: 'Save changes' }) as HTMLButtonElement).disabled);
+ refuseMember = 'some';
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Make admin: Bob' }));
+ await screen.findByText('The action failed');
+ await screen.findByText('15550002222: not-authorized');
});
- test('a 1:1 row clears its chat and deletes it on whatsapp-web.js, each only after its own confirmation', async () => {
+ test('a number the gateway refuses to add stays in the box, and an accepted one clears it', async () => {
const { screen, fireEvent, waitFor, within } = rtl;
- window.sessionStorage.setItem('openwa_engine_type', 'whatsapp-web.js');
+ listGroup = true;
renderPage();
- await screen.findByText('Alice');
- const chatPath = `/api/sessions/${SESSION.id}/chats`;
+ const dialog = await openGroupInfo();
+ fireEvent.click(within(dialog).getByRole('tab', { name: 'Participants' }));
+ const box = () => within(dialog).getByLabelText('Add a number with country code') as HTMLInputElement;
+ fireEvent.change(box(), { target: { value: TYPED_NUMBER } });
- fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
- // A 1:1 row has no group actions.
- assert.ok(!screen.queryByRole('button', { name: 'Group info' }));
- fireEvent.click(screen.getByRole('button', { name: 'Clear chat' }));
- let dialog = await screen.findByRole('dialog');
- assert.ok(within(dialog).getByText('Delete every message in the chat with Alice?'));
- fireEvent.click(within(dialog).getByRole('button', { name: 'Clear chat' }));
- await waitFor(() =>
- assert.ok(
- fetchCalls.some(c => c.method === 'DELETE' && c.path === `${chatPath}/${encodeURIComponent(CHAT.id)}/messages`),
+ refuseMember = 'all';
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Add' }));
+ await screen.findByText('The action failed');
+ assert.equal(box().value, TYPED_NUMBER, 'the number the gateway refused was cleared');
+
+ refuseMember = false;
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Add' }));
+ await waitFor(() => assert.equal(box().value, '', 'an accepted number stayed in the box'));
+ });
+
+ const notAdminBadge = `Not an admin via ${SESSION.name}`;
+
+ test('an operator who is no admin of a locked group can edit none of its info and manage no member', async () => {
+ const { fireEvent, within } = rtl;
+ listGroup = true;
+ groupAdmin = false;
+ renderPage();
+ const dialog = await openGroupInfo(notAdminBadge);
+ assert.equal(
+ (within(dialog).getByLabelText(/^Group name/) as HTMLInputElement).disabled,
+ true,
+ 'the name is editable',
+ );
+ assert.equal((within(dialog).getByLabelText('Description') as HTMLTextAreaElement).disabled, true);
+ assert.equal((within(dialog).getByRole('button', { name: 'Save changes' }) as HTMLButtonElement).disabled, true);
+
+ fireEvent.click(within(dialog).getByRole('tab', { name: 'Participants' }));
+ assert.ok(!within(dialog).queryByRole('button', { name: /^Remove: / }), 'a member was offered member actions');
+ assert.ok(!within(dialog).queryByRole('button', { name: 'Add' }), 'a member was offered adding a number');
+ });
+
+ test('an operator who is no admin of an unlocked group can edit its info, and still manages no member', async () => {
+ const { fireEvent, waitFor, within } = rtl;
+ listGroup = true;
+ groupAdmin = false;
+ groupLocked = false;
+ renderPage();
+ const dialog = await openGroupInfo(notAdminBadge);
+ fireEvent.change(within(dialog).getByLabelText(/^Group name/), { target: { value: 'Team Nord' } });
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' }));
+ await waitFor(() => assert.equal(groupName, 'Team Nord', 'the name of an unlocked group was not saved by a member'));
+
+ fireEvent.click(within(dialog).getByRole('tab', { name: 'Participants' }));
+ assert.ok(!within(dialog).queryByRole('button', { name: /^Remove: / }), 'a member was offered member actions');
+ });
+
+ test('a changed description is saved on its own through the description route', async () => {
+ const { fireEvent, waitFor, within } = rtl;
+ listGroup = true;
+ renderPage();
+ const dialog = await openGroupInfo();
+ fireEvent.change(within(dialog).getByLabelText('Description'), { target: { value: 'new description' } });
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Save changes' }));
+ await waitFor(() =>
+ assert.deepEqual(fetchCalls.find(c => c.method === 'PUT' && c.path.endsWith('/description'))?.body, {
+ description: 'new description',
+ }),
+ );
+ assert.ok(!fetchCalls.some(c => c.path.endsWith('/subject')), 'an unchanged name was saved');
+ });
+
+ test('removing a member asks first, and sends nothing unless it is confirmed', async () => {
+ const { fireEvent, waitFor, within } = rtl;
+ listGroup = true;
+ const confirm = window.confirm;
+ try {
+ renderPage();
+ const dialog = await openGroupInfo();
+ fireEvent.click(within(dialog).getByRole('tab', { name: 'Participants' }));
+ const removals = () => fetchCalls.filter(c => c.method === 'DELETE' && c.path.endsWith('/participants'));
+
+ const asked: Array<string | undefined> = [];
+ window.confirm = message => {
+ asked.push(message);
+ return false;
+ };
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Remove: Bob' }));
+ assert.deepEqual(asked, ['Remove Bob from the group?']);
+ await settle();
+ assert.deepEqual(removals(), [], 'a member was removed without being confirmed');
+
+ window.confirm = () => true;
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Remove: Bob' }));
+ await waitFor(() =>
+ assert.deepEqual(
+ removals().map(c => c.body),
+ [{ participants: ['[email protected]'] }],
+ ),
+ );
+ } finally {
+ window.confirm = confirm;
+ }
+ });
+
+ // Both engines hand the number over without a device, so this id only reaches the dialog from a synthetic list;
+ // the rule it pins is that the account's own entry is found by its id as well.
+ test('the own account is recognised under an id with a device suffix, and is offered no member actions', async () => {
+ const { fireEvent, within } = rtl;
+ listGroup = true;
+ ownHasDeviceSuffix = true;
+ renderPage();
+ const dialog = await openGroupInfo();
+ fireEvent.click(within(dialog).getByRole('tab', { name: 'Participants' }));
+ const names = Array.from(dialog.querySelectorAll('.group-info-member .name')).map(name => name.textContent);
+ assert.deepEqual(names, ['You', 'Bob']);
+ assert.ok(!within(dialog).queryByRole('button', { name: /: You$/ }), 'the own account was offered member actions');
+ });
+
+ test('a member who is no admin sees the group read-only, and a viewer key gets no write actions', async () => {
+ const { screen, fireEvent, within } = rtl;
+ listGroup = true;
+ groupAdmin = false;
+ window.sessionStorage.setItem('openwa_user_role', 'viewer');
+ renderPage();
+ await screen.findByText('Team');
- // Every 1:1 action writes, so a viewer's 1:1 row carries no menu at all.
- assert.ok(!screen.queryByRole('button', { name: 'Actions for Alice' }), 'a viewer was offered 1:1 actions');
++ // A viewer may look at a 1:1 contact, and nothing else.
++ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
++ assert.ok(screen.getByRole('button', { name: 'Contact info' }));
++ assert.ok(!screen.queryByRole('button', { name: 'Block contact' }), 'a viewer was offered blocking');
++ assert.ok(!screen.queryByRole('button', { name: 'Pin chat' }), 'a viewer was offered pinning');
++ fireEvent.keyDown(document, { key: 'Escape' });
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Team' }));
+ assert.ok(!screen.queryByRole('button', { name: 'Mark as unread' }), 'a viewer was offered mark-as-unread');
+ assert.ok(!screen.queryByRole('button', { name: 'Leave group' }), 'a viewer was offered leaving the group');
+ fireEvent.click(screen.getByRole('button', { name: 'Group info' }));
+
+ const dialog = await screen.findByRole('dialog');
+ await within(dialog).findByText(`Not an admin via ${SESSION.name}`);
+ assert.ok((within(dialog).getByDisplayValue('Team') as HTMLInputElement).disabled, 'the name is editable');
+ assert.ok((within(dialog).getByRole('button', { name: 'Save changes' }) as HTMLButtonElement).disabled);
+ });
+
+ test('a 1:1 row clears its chat and deletes it on whatsapp-web.js, each only after its own confirmation', async () => {
+ const { screen, fireEvent, waitFor, within } = rtl;
+ window.sessionStorage.setItem('openwa_engine_type', 'whatsapp-web.js');
+ renderPage();
+ await screen.findByText('Alice');
+ const chatPath = `/api/sessions/${SESSION.id}/chats`;
+
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ // A 1:1 row has no group actions.
+ assert.ok(!screen.queryByRole('button', { name: 'Group info' }));
+ fireEvent.click(screen.getByRole('button', { name: 'Clear chat' }));
+ let dialog = await screen.findByRole('dialog');
+ assert.ok(within(dialog).getByText('Delete every message in the chat with Alice?'));
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Clear chat' }));
+ await waitFor(() =>
+ assert.ok(
+ fetchCalls.some(c => c.method === 'DELETE' && c.path === `${chatPath}/${encodeURIComponent(CHAT.id)}/messages`),
'the chat was not cleared',
),
);
@@@ -766,12 -1427,11 +1698,16 @@@ test('saving a contact sends its name t
// ── Review regressions: late results stay with their session, declined writes change nothing, and the
// address book decides what is saved and what can be. ──
-/** Switch to another session through the page's session selector. */
-function switchSession(container: HTMLElement, id: string): void {
- rtl.fireEvent.change(container.querySelector('select.session-selector') as HTMLSelectElement, {
- target: { value: id },
- });
+/** Switch to another session through the session switcher. */
++/** The name the session switcher shows for the selected session. */
++const selectedSessionName = (container: HTMLElement) =>
++ container.querySelector('.session-switcher-btn .session-name')?.textContent;
++
+function switchSession(container: HTMLElement, name: string): void {
+ const { fireEvent, within } = rtl;
+ fireEvent.click(container.querySelector('.session-switcher-btn') as HTMLElement);
+ const list = container.querySelector('[role="listbox"]') as HTMLElement;
+ fireEvent.click(within(list).getByRole('option', { name: new RegExp(name) }));
}
const settle = async () => {
@@@ -799,10 -1463,10 +1739,8 @@@ test('a number lookup that answers afte
);
fireEvent.click(screen.getByRole('button', { name: 'Back' }));
- switchSession(container, SECOND_SESSION.id);
- await waitFor(() =>
- assert.equal((container.querySelector('select.session-selector') as HTMLSelectElement).value, SECOND_SESSION.id),
- );
+ switchSession(container, SECOND_SESSION.name);
- await waitFor(() =>
- assert.equal(container.querySelector('.session-switcher-btn .session-name')?.textContent, SECOND_SESSION.name),
- );
++ await waitFor(() => assert.equal(selectedSessionName(container), SECOND_SESSION.name));
release();
await settle();
@@@ -826,11 -1490,11 +1764,9 @@@ test('a group created after the sessio
// Back to the new-chat view, Back again out of the panel, then to the other session.
fireEvent.click(screen.getByRole('button', { name: 'Back' }));
fireEvent.click(screen.getByRole('button', { name: 'Back' }));
- await waitFor(() => assert.equal(container.querySelectorAll('.new-chat-panel').length, 0, 'the panel stayed open'));
- switchSession(container, SECOND_SESSION.id);
- await waitFor(() =>
- assert.equal((container.querySelector('select.session-selector') as HTMLSelectElement).value, SECOND_SESSION.id),
- );
+ await waitFor(() => assert.equal(container.querySelector('.new-chat-panel'), null, 'the panel stayed open'));
+ switchSession(container, SECOND_SESSION.name);
- await waitFor(() =>
- assert.equal(container.querySelector('.session-switcher-btn .session-name')?.textContent, SECOND_SESSION.name),
- );
++ await waitFor(() => assert.equal(selectedSessionName(container), SECOND_SESSION.name));
release();
await settle();
@@@ -848,10 -1512,10 +1784,8 @@@ test("a pin that answers after a switc
await waitFor(() => assert.ok(fetchCalls.some(c => c.path === `/api/sessions/${SESSION.id}/chats/pin`)));
// Both sessions list Alice under the same chat id.
- switchSession(container, SECOND_SESSION.id);
- await waitFor(() =>
- assert.equal((container.querySelector('select.session-selector') as HTMLSelectElement).value, SECOND_SESSION.id),
- );
+ switchSession(container, SECOND_SESSION.name);
- await waitFor(() =>
- assert.equal(container.querySelector('.session-switcher-btn .session-name')?.textContent, SECOND_SESSION.name),
- );
++ await waitFor(() => assert.equal(selectedSessionName(container), SECOND_SESSION.name));
await screen.findByText('Alice');
release();
await settle();
@@@ -892,30 -1677,949 +1947,938 @@@ test('a mark-as-unread the engine decli
assert.ok(!screen.queryByLabelText('Marked as unread'), 'the row was badged although the chat was not marked');
});
- test('a contact Baileys knows by push name only is unsaved: Unknown lists it, and its menu offers Save', async () => {
- const { screen, fireEvent } = rtl;
- listExtra = true;
- renderPage();
- await screen.findByText('Bobby');
+ // ── A write the engine declines (HTTP 200 with { success: false }) is a failure: nothing changes, and the page
+ // says so. Pin and archive are the routes of this set that can decline today; the others always answer success,
+ // and the page holds them to the same rule. ──
+
+ interface DeclinedCase {
+ title: string;
+ /** What the gateway holds before the page opens. */
+ setup?: () => void;
+ failure: string;
+ /** The success message that must not appear. */
+ success: string;
+ act: () => Promise<void>;
+ unchanged: () => void;
+ }
- fireEvent.click(screen.getByRole('button', { name: 'Unknown' }));
- assert.ok(screen.getByText('Bobby'), 'the push-name-only contact left the Unknown filter');
- assert.ok(!screen.queryByText('Alice'), 'a saved contact is listed as unknown');
+ /** Click the confirming button of the dialog that is open. */
+ const confirmDialog = async (name: string) => {
+ const { screen, fireEvent, within } = rtl;
+ fireEvent.click(within(await screen.findByRole('dialog')).getByRole('button', { name }));
+ };
- fireEvent.click(screen.getByRole('button', { name: 'Actions for Bobby' }));
- assert.ok(screen.getByRole('button', { name: /^Save contact/ }));
- assert.ok(!screen.queryByRole('button', { name: /^Rename contact/ }), 'an unsaved contact is offered Rename');
- });
+ const DECLINED_CASES: DeclinedCase[] = [
+ {
+ title: 'pin',
+ failure: 'Could not pin the chat. WhatsApp keeps at most three chats pinned.',
+ success: 'Pinned',
+ act: async () => pickRowAction('Alice', 'Pin chat'),
+ unchanged: () => assert.ok(!rtl.screen.queryByRole('img', { name: 'Pinned' }), 'the row was pinned'),
+ },
+ {
+ title: 'archive',
+ failure: 'Could not change the archive',
+ success: 'Chat archived',
+ act: async () => pickRowAction('Alice', 'Archive chat'),
+ unchanged: () => assert.ok(rtl.screen.getByText('Alice'), 'the chat left the main list'),
+ },
+ {
+ title: 'mute',
+ failure: 'Could not change the notifications',
+ success: 'Muted',
+ act: async () => {
+ pickRowAction('Alice', 'Mute notifications');
+ await confirmDialog('Mute notifications');
+ },
+ unchanged: () => {
+ assert.ok(!rtl.screen.queryByRole('img', { name: 'Muted' }), 'the row was muted');
+ assert.ok(rtl.screen.getByRole('dialog'), 'the dialog closed on a declined mute');
+ },
+ },
+ {
+ title: 'contact save',
+ failure: 'Could not save the contact',
+ success: 'Contact saved',
+ act: async () => {
+ await pickRowActionOnceLoaded('Alice', 'Rename contact');
+ const dialog = await rtl.screen.findByRole('dialog');
+ rtl.fireEvent.change(rtl.within(dialog).getByLabelText('First name'), { target: { value: 'Alicia' } });
+ rtl.fireEvent.click(rtl.within(dialog).getByRole('button', { name: 'Save' }));
+ },
+ unchanged: () => {
+ assert.ok(rtl.screen.getByText('Alice'), 'the row was renamed');
+ assert.ok(rtl.screen.getByRole('dialog'), 'the dialog closed on a declined save');
+ },
+ },
+ {
+ title: 'block',
+ failure: 'Could not change the block',
+ success: 'Alice blocked',
+ act: async () => {
+ pickRowAction('Alice', 'Block contact');
+ await confirmDialog('Block contact');
+ },
+ unchanged: () => assert.ok(rtl.screen.getByRole('dialog'), 'the dialog closed on a declined block'),
+ },
+ {
+ title: 'unblock',
+ setup: () => {
+ blockedIds = [CHAT.id];
+ },
+ failure: 'Could not change the block',
+ success: 'Alice unblocked',
+ act: async () => pickRowAction('Alice', 'Unblock contact'),
+ unchanged: () => undefined,
+ },
+ {
+ title: 'leave',
+ failure: 'Could not leave the group',
+ success: 'Left "Team"',
+ act: async () => {
+ pickRowAction('Team', 'Leave group');
+ await confirmDialog('Leave group');
+ },
+ unchanged: () => assert.ok(rtl.screen.getByRole('dialog'), 'the dialog closed on a declined leave'),
+ },
+ ];
+
+ for (const declined of DECLINED_CASES) {
+ test(`a declined ${declined.title} is reported as a failure and changes nothing`, async () => {
+ const { screen } = rtl;
+ listGroup = true;
+ declineWrites = true;
+ declined.setup?.();
+ renderPage();
+ await screen.findByText('Team');
+ await declined.act();
+ await screen.findByText(declined.failure);
+ assert.ok(screen.getByText('WhatsApp declined the change.'), 'the reason was not shown');
+ assert.ok(!screen.queryByText(declined.success), 'a declined change was announced as done');
+ declined.unchanged();
+ });
+ }
- test('a chat keyed by a privacy id offers Save contact disabled, with the reason, and sends nothing', async () => {
- const { screen, fireEvent } = rtl;
- listExtra = true;
- renderPage();
- await screen.findByText('Lia');
- fireEvent.click(screen.getByRole('button', { name: 'Actions for Lia' }));
- const save = screen.getByRole('button', { name: /^Save contact/ }) as HTMLButtonElement;
- assert.equal(save.disabled, true, 'Save is offered for a @lid chat');
- assert.match(save.textContent ?? '', /privacy id \(@lid\)/);
+ // ── A request that answers after the session was switched changes nothing on the session now selected, which
+ // can list a chat under the same id. ──
+
+ test("a contact save that answers after a switch renames nothing on the other session's row", async () => {
+ const { screen, fireEvent, waitFor, within } = rtl;
+ listSecond = true;
+ const release = hold('saveContact');
+ const { container } = renderPage();
+ await screen.findByText('Alice');
+ await pickRowActionOnceLoaded('Alice', 'Rename contact');
+ const dialog = await screen.findByRole('dialog');
+ fireEvent.change(within(dialog).getByLabelText('First name'), { target: { value: 'Alicia' } });
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Save' }));
+ await waitFor(() => assert.ok(fetchCalls.some(c => c.method === 'PUT' && c.path.includes('/contacts/'))));
+
- switchSession(container, SECOND_SESSION.id);
- await waitFor(() =>
- assert.equal((container.querySelector('select.session-selector') as HTMLSelectElement).value, SECOND_SESSION.id),
- );
++ switchSession(container, SECOND_SESSION.name);
++ await waitFor(() => assert.equal(selectedSessionName(container), SECOND_SESSION.name));
+ await screen.findByText('Alice');
+ release();
+ await settle();
+ await settle();
+ assert.ok(screen.getByText('Alice'), "the other session's row lost its name");
+ assert.ok(!screen.queryByText('Alicia'), "A's save renamed B's row");
+ });
+
+ test("a mute that answers after a switch mutes nothing on the other session's row", async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ listSecond = true;
+ const release = hold('mute');
+ const { container } = renderPage();
+ await screen.findByText('Alice');
+ pickRowAction('Alice', 'Mute notifications');
+ await confirmDialog('Mute notifications');
+ await waitFor(() => assert.ok(fetchCalls.some(c => c.path.endsWith('/chats/mute'))));
+
- switchSession(container, SECOND_SESSION.id);
- await waitFor(() =>
- assert.equal((container.querySelector('select.session-selector') as HTMLSelectElement).value, SECOND_SESSION.id),
- );
++ switchSession(container, SECOND_SESSION.name);
++ await waitFor(() => assert.equal(selectedSessionName(container), SECOND_SESSION.name));
+ await screen.findByText('Alice');
+ release();
+ await settle();
+ await settle();
+ assert.ok(!screen.queryByRole('img', { name: 'Muted' }), "B's row was muted by A's late answer");
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ assert.ok(screen.getByRole('button', { name: 'Mute notifications' }), "B's menu offers Unmute");
+ });
+
+ for (const kind of ['clear', 'delete'] as const) {
+ test(`a ${kind} that answers after a switch leaves the other session's chat of the same id as it was`, async () => {
+ const { screen, waitFor } = rtl;
+ window.sessionStorage.setItem('openwa_engine_type', 'whatsapp-web.js');
+ listSecond = true;
+ const release = hold(kind === 'clear' ? 'clearChat' : 'deleteChat');
+ const { container } = renderPage();
+ await screen.findByText('Alice');
+ pickRowAction('Alice', kind === 'clear' ? 'Clear chat' : 'Delete chat');
+ await confirmDialog(kind === 'clear' ? 'Clear chat' : 'Delete chat');
+ await waitFor(() =>
+ assert.ok(fetchCalls.some(c => c.path.endsWith(kind === 'clear' ? '/messages' : '/chats/delete'))),
+ );
+
- switchSession(container, SECOND_SESSION.id);
- await waitFor(() =>
- assert.equal((container.querySelector('select.session-selector') as HTMLSelectElement).value, SECOND_SESSION.id),
- );
++ switchSession(container, SECOND_SESSION.name);
++ await waitFor(() => assert.equal(selectedSessionName(container), SECOND_SESSION.name));
+ await screen.findByText('Alice');
+ release();
+ await settle();
+ await settle();
+ assert.ok(screen.getByText('Alice'), "A's answer removed B's chat");
+ assert.ok(screen.getAllByText('hello from alice').length > 0, "A's answer emptied B's preview");
+ });
+ }
+
+ // ── A chat list asked for before one of the page's own changes answers with the flags from before it, and must
+ // not undo that change. ──
+
+ const chatListReads = () =>
+ fetchCalls.filter(c => c.method === 'GET' && c.path.startsWith(`/api/sessions/${SESSION.id}/chats?`)).length;
+
+ const RELOAD_RACES: Array<{ title: string; engine?: string; act: () => Promise<void>; shows: () => void }> = [
+ {
+ title: 'an archive',
+ act: async () => pickRowAction('Alice', 'Archive chat'),
+ shows: () => assert.ok(!rtl.screen.queryByText('Alice'), 'the archived chat is back in the main list'),
+ },
+ {
+ title: 'a pin',
+ act: async () => pickRowAction('Alice', 'Pin chat'),
+ shows: () => assert.ok(rtl.screen.getByRole('img', { name: 'Pinned' }), 'the pinned chat lost its pin'),
+ },
+ {
+ title: 'a mute',
+ act: async () => {
+ pickRowAction('Alice', 'Mute notifications');
+ await confirmDialog('Mute notifications');
+ },
+ shows: () => assert.ok(rtl.screen.getByRole('img', { name: 'Muted' }), 'the muted chat lost its mute'),
+ },
+ {
+ title: 'a mark as unread',
+ act: async () => pickRowAction('Alice', 'Mark as unread'),
+ shows: () => assert.ok(rtl.screen.getByLabelText('Marked as unread'), 'the chat marked unread reads as read'),
+ },
+ {
+ title: 'a rename',
+ act: async () => {
+ await pickRowActionOnceLoaded('Alice', 'Rename contact');
+ const dialog = await rtl.screen.findByRole('dialog');
+ rtl.fireEvent.change(rtl.within(dialog).getByLabelText('First name'), { target: { value: 'Alicia' } });
+ rtl.fireEvent.click(rtl.within(dialog).getByRole('button', { name: 'Save' }));
+ },
+ shows: () => assert.ok(rtl.screen.getByText('Alicia'), 'the renamed chat has its old name back'),
+ },
+ {
+ title: 'a delete',
+ engine: 'whatsapp-web.js',
+ act: async () => {
+ pickRowAction('Alice', 'Delete chat');
+ await confirmDialog('Delete chat');
+ },
+ shows: () => assert.ok(!rtl.screen.queryByText('Alice'), 'the deleted chat is back in the sidebar'),
+ },
+ ];
+
+ for (const race of RELOAD_RACES) {
+ test(`a chat list asked for before ${race.title} does not undo it when it answers`, async () => {
+ const { screen, waitFor } = rtl;
+ if (race.engine) window.sessionStorage.setItem('openwa_engine_type', race.engine);
+ renderPage();
+ await screen.findByText('Alice');
+ const release = hold('chats');
+ // An edit in a chat that was never opened asks for the list again, and the answer is held back.
+ receiveEvent('message.edited', {
+ messageId: 'wamid.edit.1',
+ chatId: CHAT.id,
+ body: 'edited',
+ timestamp: 1_700_001_000,
+ });
+ await waitFor(() => assert.equal(chatListReads(), 2, 'the edit did not ask for the list'));
+
+ await race.act();
+ await waitFor(race.shows);
+ // The list was asked for before the change, so it still holds the flags from before it.
+ release();
+ await settle();
+ await settle();
+ race.shows();
+ });
+ }
+
+ test('a chat that writes again after its delete is listed by the list that message asks for', async () => {
+ const { screen, waitFor } = rtl;
+ window.sessionStorage.setItem('openwa_engine_type', 'whatsapp-web.js');
+ renderPage();
+ await screen.findByText('Alice');
+ const release = hold('chats');
+ receiveEvent('message.edited', {
+ messageId: 'wamid.edit.2',
+ chatId: CHAT.id,
+ body: 'edited',
+ timestamp: 1_700_001_000,
+ });
+ await waitFor(() => assert.equal(chatListReads(), 2, 'the edit did not ask for the list'));
+
+ pickRowAction('Alice', 'Delete chat');
+ await confirmDialog('Delete chat');
+ await waitFor(() => assert.ok(!screen.queryByText('Alice'), 'the chat was not deleted'));
+ // The conversation is gone, so its next message finds no row and asks for the list again.
+ receiveFromAlice('wamid.after.delete', 'hello again');
+
+ release();
+ await waitFor(() => assert.equal(chatListReads(), 3, 'the message did not ask for the list'));
+ await screen.findByText('Alice');
+ });
+
+ test('a chat list asked for before Mark as unread does not mark a chat that was opened and read since', async () => {
+ const { screen, fireEvent, waitFor, within } = rtl;
+ const { container } = renderPage();
+ await screen.findByText('Alice');
+ const release = hold('chats');
+ receiveEvent('message.edited', {
+ messageId: 'wamid.edit.unread',
+ chatId: CHAT.id,
+ body: 'edited',
+ timestamp: 1_700_001_000,
+ });
+ await waitFor(() => assert.equal(chatListReads(), 2, 'the edit did not ask for the list'));
+
+ pickRowAction('Alice', 'Mark as unread');
+ await screen.findByLabelText('Marked as unread');
+ // Opening the chat is what reads it again, and clears the mark.
+ fireEvent.click(screen.getByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.ok(!screen.queryByLabelText('Marked as unread'), 'opening the chat kept its mark'));
+
+ release();
+ await settle();
+ await settle();
+ assert.ok(!screen.queryByLabelText('Marked as unread'), 'the earlier list put the unread mark back on the open chat');
+ fireEvent.click(container.querySelector('.room-menu-trigger') as HTMLElement);
+ const menu = container.querySelector('.room-menu-popover') as HTMLElement;
+ assert.ok(within(menu).getByRole('button', { name: 'Mark as unread' }), 'the room menu lost Mark as unread');
+ });
+
+ test('a chat list asked for before a chat was opened does not bring its old unread count back', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ aliceNow.unreadCount = 2;
+ const { container } = renderPage();
+ await screen.findByLabelText('2 unread messages');
+ const release = hold('chats');
+ receiveEvent('message.edited', {
+ messageId: 'wamid.edit.count',
+ chatId: '[email protected]',
+ body: 'edited',
+ timestamp: 1_700_001_000,
+ });
+ await waitFor(() => assert.equal(chatListReads(), 2, 'the edit did not ask for the list'));
+
+ fireEvent.click(screen.getByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.ok(!screen.queryByLabelText('2 unread messages'), 'opening the chat kept its badge'));
+ release();
+ await settle();
+ await settle();
+ assert.ok(!screen.queryByLabelText('2 unread messages'), 'the earlier list put the old unread count back');
+ });
+
+ test('a chat list asked for after a change is taken as it comes, so a later change elsewhere shows', async () => {
+ const { screen, waitFor } = rtl;
+ renderPage();
+ await screen.findByText('Alice');
+ pickRowAction('Alice', 'Archive chat');
+ await waitFor(() => assert.ok(!screen.queryByText('Alice'), 'the chat was not archived'));
+
+ // The phone takes the chat out of the archive, and the next list is asked for after the change here.
+ receiveEvent('message.edited', {
+ messageId: 'wamid.edit.2',
+ chatId: CHAT.id,
+ body: 'edited',
+ timestamp: 1_700_001_000,
+ });
+ await waitFor(() => assert.equal(chatListReads(), 2, 'the edit did not ask for the list'));
+ await waitFor(() => assert.ok(screen.getByText('Alice'), 'the list asked for later did not bring the chat back'));
+ });
+
+ test('a message that reaches a chat after a change keeps its row when an earlier list answers', async () => {
+ const { screen, waitFor } = rtl;
+ renderPage();
+ await screen.findByText('Alice');
+ const release = hold('chats');
+ receiveEvent('message.edited', {
+ messageId: 'wamid.edit.3',
+ chatId: CHAT.id,
+ body: 'edited',
+ timestamp: 1_700_001_000,
+ });
+ await waitFor(() => assert.equal(chatListReads(), 2, 'the edit did not ask for the list'));
+ pickRowAction('Alice', 'Mark as unread');
+ await screen.findByLabelText('Marked as unread');
+
+ // The first message into a chat marked unread counts as one, which the earlier list's flags must not undo.
+ receiveFromAlice('wamid.live.after', 'after the mark');
+ await screen.findByLabelText('1 unread message');
+ release();
+ await settle();
+ await settle();
+ assert.ok(screen.getByLabelText('1 unread message'), 'the earlier list put the old unread state over the frame');
+ assert.ok(screen.getByText('after the mark'), 'the earlier list rolled the preview back');
+ });
+
+ // ── The live history read of an opened chat. ──
+
+ // Baileys answers 501 to it, so every chat opened there logged a failed call in the browser console. An engine
+ // the page does not know is still asked: skipping it would drop the backfill on an engine that has it.
+ for (const [engine, asked] of [
+ ['baileys', false],
+ ['whatsapp-web.js', true],
+ [null, true],
+ ] as const) {
+ test(`opening a chat ${asked ? 'asks' : 'does not ask'} ${engine ?? 'an unknown engine'} for live history`, async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ if (engine) window.sessionStorage.setItem('openwa_engine_type', engine);
+ else window.sessionStorage.removeItem('openwa_engine_type');
+ aliceThread = [threadRow(1)];
+ renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await screen.findByText('message 1');
+ const history = () => fetchCalls.filter(c => c.method === 'GET' && /\/messages\/[^/]+\/history/.test(c.path));
+ if (asked) await waitFor(() => assert.equal(history().length, 1, 'the live history was not read once'));
+ else assert.equal(history().length, 0, 'the engine that answers 501 was asked for live history');
+ });
+ }
+
+ // ── What clearing and deleting a chat leave behind on the page. ──
+
+ test('clearing a chat empties its preview and refreshes the thread that is open', async () => {
+ const { screen, fireEvent, waitFor, within } = rtl;
+ window.sessionStorage.setItem('openwa_engine_type', 'whatsapp-web.js');
+ aliceThread = [threadRow(1)];
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await screen.findByText('message 1');
+
+ pickRowAction('Alice', 'Clear chat');
+ await confirmDialog('Clear chat');
+ await waitFor(() =>
+ assert.ok(!screen.queryByText('message 1'), 'the open thread kept the messages that were cleared'),
+ );
+ assert.ok(!screen.queryByText('hello from alice'), 'the row kept the preview of a cleared chat');
+ const sidebar = container.querySelector('.chats-sidebar') as HTMLElement;
+ assert.ok(within(sidebar).getByText('Alice'), 'clearing removed the chat from the list');
+ });
+
+ test('deleting a chat drops its cached thread along with the row', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ window.sessionStorage.setItem('openwa_engine_type', 'whatsapp-web.js');
+ aliceThread = [threadRow(1)];
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await screen.findByText('message 1');
+ // The room is closed first: removing a query an open room still observes leaves a gc timer on the removed
+ // query that nothing can clear, which holds the test process open for minutes.
+ fireEvent.click(screen.getByRole('button', { name: 'Back' }));
+ await waitFor(() => assert.ok(!container.querySelector('.room-header'), 'the room did not close'));
+ const thread = () => queryClients[0].getQueryData(['messages', SESSION.id, CHAT.id]);
+ assert.ok(thread(), 'the thread was not cached');
+
+ pickRowAction('Alice', 'Delete chat');
+ await confirmDialog('Delete chat');
+ await waitFor(() => assert.ok(!screen.queryByText('Alice'), 'the deleted chat stayed in the list'));
+ assert.equal(thread(), undefined, 'the deleted chat kept its thread in the cache');
+ });
+
+ // ── Switching session leaves nothing of the session that was left open: the dialogs and the archive view belong
+ // to it (the new chat panel too, which hides the session selector: see Chats.test.ts). ──
+
+ const LEFT_OPEN: Array<{ title: string; open: () => Promise<void>; gone: (container: HTMLElement) => boolean }> = [
+ {
+ title: 'group info dialog',
+ open: async () => {
+ pickRowAction('Team', 'Group info');
+ await rtl.screen.findByRole('dialog');
+ },
+ gone: () => !rtl.screen.queryByRole('dialog'),
+ },
+ {
+ title: 'confirmation dialog',
+ open: async () => {
+ pickRowAction('Alice', 'Block contact');
+ await rtl.screen.findByRole('dialog');
+ },
+ gone: () => !rtl.screen.queryByRole('dialog'),
+ },
+ {
+ title: 'mute dialog',
+ open: async () => {
+ pickRowAction('Alice', 'Mute notifications');
+ await rtl.screen.findByRole('dialog');
+ },
+ gone: () => !rtl.screen.queryByRole('dialog'),
+ },
+ {
+ title: 'contact dialog',
+ open: async () => {
+ await pickRowActionOnceLoaded('Alice', 'Rename contact');
+ await rtl.screen.findByRole('dialog');
+ },
+ gone: () => !rtl.screen.queryByRole('dialog'),
+ },
+ {
+ title: 'archive view',
+ open: async () => {
+ pickRowAction('Alice', 'Archive chat');
+ await rtl.waitFor(() => assert.ok(!rtl.screen.queryByText('Alice')));
+ rtl.fireEvent.click(rtl.screen.getByRole('button', { name: /^Archived/ }));
+ await rtl.screen.findByText('Alice');
+ },
+ // The other session holds no archived chat, so its list is the main one, with Alice in it.
+ gone: () => !rtl.screen.queryByText('Archived chats') && Boolean(rtl.screen.queryByText('Alice')),
+ },
+ ];
+
+ for (const left of LEFT_OPEN) {
+ test(`switching session closes the ${left.title} of the session that was left`, async () => {
+ const { screen, waitFor } = rtl;
+ listSecond = true;
+ listGroup = true;
+ const { container } = renderPage();
+ await screen.findByText('Team');
+ await left.open();
+
- switchSession(container, SECOND_SESSION.id);
- await waitFor(() =>
- assert.equal((container.querySelector('select.session-selector') as HTMLSelectElement).value, SECOND_SESSION.id),
- );
++ switchSession(container, SECOND_SESSION.name);
++ await waitFor(() => assert.equal(selectedSessionName(container), SECOND_SESSION.name));
+ await screen.findByText('Alice');
+ await waitFor(() => assert.ok(left.gone(container), `the ${left.title} stayed open on the other session`));
+ });
+ }
+
+ test('opening a chat from the new chat panel clears the filter and the search, so the chat is listed', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const { container } = renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'Groups' }));
+ fireEvent.change(screen.getByPlaceholderText('Search chats...'), { target: { value: 'zzz' } });
+ assert.ok(!screen.queryByText('Alice'), 'the filter and the search hid nothing');
+
+ fireEvent.click(screen.getByRole('button', { name: 'New chat' }));
+ fireEvent.click(await screen.findByRole('button', { name: /Bob/ }));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the chat did not open'));
+ const list = container.querySelector('.chats-list') as HTMLElement;
+ await waitFor(() => assert.ok(list.textContent?.includes('Bob'), 'the opened chat is not in the list'));
+ assert.equal(screen.getByRole('button', { name: 'All' }).getAttribute('aria-pressed'), 'true');
+ assert.equal((screen.getByPlaceholderText('Search chats...') as HTMLInputElement).value, '');
+ });
+
+ test('a search finds an archived chat, which the list itself keeps in the archive view', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ renderPage();
+ await screen.findByText('Alice');
+ pickRowAction('Alice', 'Archive chat');
+ await waitFor(() => assert.ok(!screen.queryByText('Alice'), 'the archived chat stayed in the main list'));
+
+ fireEvent.change(screen.getByPlaceholderText('Search chats...'), { target: { value: 'Alice' } });
+ await screen.findByText('Alice');
+ });
+
+ // ── Menus close on a press outside them and on Escape; Escape leaves the open chat alone. ──
+
+ test("a row's menu closes on a press outside it and stays open for a press inside it", async () => {
+ const { screen, fireEvent } = rtl;
+ const { container } = renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ fireEvent.mouseDown(container.querySelector('.chat-row-menu-popover') as HTMLElement);
+ assert.ok(container.querySelector('.chat-row-menu-popover'), 'a press inside closed the menu');
+ fireEvent.mouseDown(document.body);
+ assert.ok(!container.querySelector('.chat-row-menu-popover'), 'a press outside left the menu open');
+ });
+
+ test("the room's menu closes on a press outside it and on Escape, and Escape leaves the room open", async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ const trigger = container.querySelector('.room-menu-trigger') as HTMLElement;
+ const menuOpen = () => Boolean(container.querySelector('.room-menu-popover'));
+
+ fireEvent.click(trigger);
+ fireEvent.mouseDown(container.querySelector('.room-menu-popover') as HTMLElement);
+ assert.ok(menuOpen(), 'a press inside closed the menu');
+ fireEvent.mouseDown(document.body);
+ assert.ok(!menuOpen(), 'a press outside left the menu open');
+
+ fireEvent.click(trigger);
+ assert.ok(menuOpen());
+ fireEvent.keyDown(document, { key: 'Escape' });
+ assert.ok(!menuOpen(), 'Escape left the menu open');
+ assert.ok(container.querySelector('.room-header'), 'Escape closed the room along with the menu');
+ });
+
+ test('a read-only key does not read the blocklist, which only an operator can act on', async () => {
+ const { screen } = rtl;
+ window.sessionStorage.setItem('openwa_user_role', 'viewer');
+ renderPage();
+ await screen.findByText('Alice');
+ await settle();
+ assert.ok(!fetchCalls.some(c => c.path.endsWith('/contacts/blocked')), 'a viewer key read the blocklist');
+ });
+
+ test('a contact Baileys knows by push name only is unsaved: Unknown lists it, and its menu offers Save', async () => {
+ const { screen, fireEvent } = rtl;
+ listExtra = true;
+ renderPage();
+ await screen.findByText('Bobby');
+
+ fireEvent.click(screen.getByRole('button', { name: 'Unknown' }));
+ await screen.findByText('Bobby');
+ assert.ok(!screen.queryByText('Alice'), 'a saved contact is listed as unknown');
+
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Bobby' }));
+ assert.ok(screen.getByRole('button', { name: /^Save contact/ }));
+ assert.ok(!screen.queryByRole('button', { name: /^Rename contact/ }), 'an unsaved contact is offered Rename');
+ });
+
+ test("the contact dialog follows the address book the menu read, not the chat's name", async () => {
+ const { screen, fireEvent, within } = rtl;
+ listExtra = true;
+ renderPage();
+ await screen.findByText('Bobby');
+
+ // Known to Baileys by a bare push name: unsaved, so Save, and the push name is no name to start from.
+ pickRowAction('Bobby', 'Save contact');
+ let dialog = await screen.findByRole('dialog');
+ assert.equal(dialog.querySelector('h2')?.textContent, 'Save contact');
+ assert.equal((within(dialog).getByLabelText('First name') as HTMLInputElement).value, '');
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Cancel' }));
+
+ // Saved under a name that reads like a number: Rename, with nothing to start from.
+ await pickRowActionOnceLoaded('+1 555 000 3333', 'Rename contact');
+ dialog = await screen.findByRole('dialog');
+ assert.equal(dialog.querySelector('h2')?.textContent, 'Rename contact');
+ assert.equal((within(dialog).getByLabelText('First name') as HTMLInputElement).value, '');
+ });
+
+ test('a contact dialog opened before the address book lands starts from the saved name once it does', async () => {
+ const { screen, fireEvent, waitFor, within } = rtl;
+ const release = hold('contacts');
+ aliceNow.name = 'Alice Smith';
+ renderPage();
+ await screen.findByText('Alice Smith');
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice Smith' }));
+ // Until the book lands the entry reads the default.
+ fireEvent.click(screen.getByRole('button', { name: /^Save contact/ }));
+ const dialog = await screen.findByRole('dialog');
+ const value = (label: string) => (within(dialog).getByLabelText(label) as HTMLInputElement).value;
+ assert.equal(dialog.querySelector('h2')?.textContent, 'Save contact');
+ assert.equal(value('First name'), '');
+
+ release();
+ await waitFor(() => assert.equal(dialog.querySelector('h2')?.textContent, 'Rename contact'));
+ assert.equal(value('First name'), 'Alice', 'the Rename dialog opened with an empty name');
+ assert.equal(value('Last name (optional)'), 'Smith');
+ });
+
+ for (const [field, other] of [
+ ['First name', 'Last name (optional)'],
+ ['Last name (optional)', 'First name'],
+ ]) {
+ test(`a ${field.toLowerCase()} typed before the address book lands is kept when it does`, async () => {
+ const { screen, fireEvent, waitFor, within } = rtl;
+ const release = hold('contacts');
+ aliceNow.name = 'Alice Smith';
+ renderPage();
+ await screen.findByText('Alice Smith');
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice Smith' }));
+ fireEvent.click(screen.getByRole('button', { name: /^Save contact/ }));
+ const dialog = await screen.findByRole('dialog');
+ fireEvent.change(within(dialog).getByLabelText(field), { target: { value: 'Zed' } });
+
+ release();
+ await waitFor(() => assert.equal(dialog.querySelector('h2')?.textContent, 'Rename contact'));
+ const value = (label: string) => (within(dialog).getByLabelText(label) as HTMLInputElement).value;
+ assert.equal(value(field), 'Zed', 'what was typed was lost');
+ // The other field keeps what it showed, so the typed and the saved name never mix.
+ assert.equal(value(other), '');
+ });
+ }
+
+ test("the contact dialog's Save button submits its form, so Enter in a name field saves", async () => {
+ const { screen, fireEvent, waitFor, within } = rtl;
+ renderPage();
+ await screen.findByText('Alice');
+ await pickRowActionOnceLoaded('Alice', 'Rename contact');
+ const dialog = await screen.findByRole('dialog');
+ const form = dialog.querySelector('form') as HTMLFormElement;
+ const save = within(dialog).getByRole('button', { name: 'Save' }) as HTMLButtonElement;
+ // A browser submits a form on Enter through its submit button, which has to belong to that form. The Save
+ // button sits in the dialog's footer, outside the form element.
+ assert.ok(save.type === 'submit' && save.form === form, 'Enter in a name field has no submit button to press');
+
+ fireEvent.change(within(dialog).getByLabelText('First name'), { target: { value: 'Alicia' } });
+ fireEvent.click(save);
+ await waitFor(() =>
+ assert.deepEqual(
+ fetchCalls.filter(c => c.method === 'PUT' && c.path.includes('/contacts/')).map(c => c.body),
+ [{ firstName: 'Alicia' }],
+ 'a click on Save did not send the name exactly once',
+ ),
+ );
+ });
+
+ // ── The address book is read when a surface needs it, not when the page opens. ──
+
+ const contactReads = () =>
+ fetchCalls.filter(c => c.method === 'GET' && c.path.startsWith(`/api/sessions/${SESSION.id}/contacts?`));
+
+ test('opening the page reads no address book', async () => {
+ const { screen } = rtl;
+ renderPage();
+ await screen.findByText('Alice');
+ await settle();
+ assert.equal(contactReads().length, 0, 'the page walked the address book on mount');
+ });
+
+ test('the first menu to open reads the address book once, and its Save entry then follows it', async () => {
+ const { screen, fireEvent } = rtl;
+ renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ await screen.findByRole('button', { name: 'Rename contact' });
+ assert.equal(contactReads().length, 1);
+
+ fireEvent.keyDown(document, { key: 'Escape' });
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ await settle();
+ assert.equal(contactReads().length, 1, 'a second menu read the address book again');
+ });
+
+ test('switching session after a menu opened reads no address book for the new session', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ listSecond = true;
+ const { container } = renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ await screen.findByRole('button', { name: 'Rename contact' });
+ fireEvent.keyDown(document, { key: 'Escape' });
+ const readsOn = (id: string) =>
+ fetchCalls.filter(c => c.method === 'GET' && c.path.startsWith(`/api/sessions/${id}/contacts?`)).length;
+ assert.equal(readsOn(SESSION.id), 1);
+
- switchSession(container, SECOND_SESSION.id);
- await waitFor(() =>
- assert.equal((container.querySelector('select.session-selector') as HTMLSelectElement).value, SECOND_SESSION.id),
- );
++ switchSession(container, SECOND_SESSION.name);
++ await waitFor(() => assert.equal(selectedSessionName(container), SECOND_SESSION.name));
+ await screen.findByText('Alice');
+ await settle();
+ await settle();
+ assert.equal(readsOn(SECOND_SESSION.id), 0, 'the new session paid for an address book nobody asked for');
+
+ // A menu on the new session asks for its own.
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ await screen.findByRole('button', { name: 'Rename contact' });
+ assert.equal(readsOn(SECOND_SESSION.id), 1);
+ });
+
+ test('coming back to a session whose menu opened on an earlier visit reads no address book', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ listSecond = true;
+ const { container } = renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ await screen.findByRole('button', { name: 'Rename contact' });
+ fireEvent.keyDown(document, { key: 'Escape' });
+ const readsOn = (id: string) =>
+ fetchCalls.filter(c => c.method === 'GET' && c.path.startsWith(`/api/sessions/${id}/contacts?`)).length;
+ assert.equal(readsOn(SESSION.id), 1);
- const selectedSession = () => (container.querySelector('select.session-selector') as HTMLSelectElement).value;
+
- switchSession(container, SECOND_SESSION.id);
- await waitFor(() => assert.equal(selectedSession(), SECOND_SESSION.id));
++ switchSession(container, SECOND_SESSION.name);
++ await waitFor(() => assert.equal(selectedSessionName(container), SECOND_SESSION.name));
+ await screen.findByText('Alice');
+ // Past the cache's hold on the session left (these tests keep a query one second once nothing watches it).
+ await new Promise(resolve => setTimeout(resolve, 1_500));
+
- switchSession(container, SESSION.id);
- await waitFor(() => assert.equal(selectedSession(), SESSION.id));
++ switchSession(container, SESSION.name);
++ await waitFor(() => assert.equal(selectedSessionName(container), SESSION.name));
+ await screen.findByText('Alice');
+ await settle();
+ await settle();
+ assert.equal(readsOn(SESSION.id), 1, 'coming back read an address book no menu asked for');
+
+ // A menu on this visit asks again.
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ await screen.findByRole('button', { name: 'Rename contact' });
+ assert.equal(readsOn(SESSION.id), 2);
+ });
+
+ test("a group's menu has no use for the address book and does not read it", async () => {
+ const { screen, fireEvent } = rtl;
+ listGroup = true;
+ renderPage();
+ await screen.findByText('Team');
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Team' }));
+ await screen.findByRole('button', { name: 'Group info' });
+ await settle();
+ assert.equal(contactReads().length, 0, "a group's menu read the address book");
+ });
+
+ test("a read-only key's room menu has no entry that reads the address book, so it does not read it", async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ window.sessionStorage.setItem('openwa_user_role', 'viewer');
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ fireEvent.click(container.querySelector('.room-menu-trigger') as HTMLElement);
+ await screen.findByRole('button', { name: 'Copy chat ID' });
+ await settle();
+ assert.equal(contactReads().length, 0, 'a viewer key walked the address book to open a menu that cannot use it');
+ });
+
+ test("the room's menu asks for the address book as well", async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ assert.equal(contactReads().length, 0);
+ fireEvent.click(container.querySelector('.room-menu-trigger') as HTMLElement);
+ await screen.findByRole('button', { name: 'Rename contact' });
+ assert.equal(contactReads().length, 1);
+ });
+
+ test('the Unknown filter waits for the address book instead of listing nothing', async () => {
+ const { screen, fireEvent } = rtl;
+ listExtra = true;
+ const release = hold('contacts');
+ renderPage();
+ await screen.findByText('Bobby');
+ assert.equal(contactReads().length, 0);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Unknown' }));
+ assert.ok(screen.getByText('Loading chats...'), 'the filter did not wait for the address book');
+ assert.ok(!screen.queryByText('No chats match this filter'), 'the filter claimed no chat matches');
+ release();
+ await screen.findByText('Bobby');
+ assert.ok(!screen.queryByText('Alice'), 'a saved contact is listed as unknown');
+ });
+
+ test('the Unknown filter says the address book could not be read, and Retry reads it again', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ listExtra = true;
+ failContacts = true;
+ renderPage();
+ await screen.findByText('Bobby');
+ fireEvent.click(screen.getByRole('button', { name: 'Unknown' }));
+
+ await screen.findByText('Could not load contacts');
+ assert.ok(!screen.queryByText('No chats match this filter'), 'a failed read was reported as no matching chat');
+ assert.equal(contactReads().length, 1);
+ assert.equal(screen.getByRole('button', { name: 'Retry' }).querySelector('.animate-spin'), null);
+
+ // The retry keeps the keyboard where it was while the read runs, and says it is busy.
+ failContacts = false;
+ const release = hold('contacts');
+ const retry = screen.getByRole('button', { name: 'Retry' });
+ retry.focus();
+ fireEvent.click(retry);
+ await waitFor(() => assert.equal(contactReads().length, 2));
+ assert.equal(document.activeElement === retry, true, `focus is on "${focusedName()}", not on Retry`);
+ assert.equal(retry.getAttribute('aria-disabled'), 'true');
+ // A sighted operator sees it too: a spinner beside the label, and nothing like it before the press.
+ assert.equal(retry.getAttribute('aria-busy'), 'true');
+ assert.ok(retry.querySelector('.animate-spin'), 'the running retry shows no spinner');
+
+ release();
+ await screen.findByText('Bobby');
+ assert.ok(!screen.queryByText('Could not load contacts'), 'the failed state stayed after the read succeeded');
+ assert.ok(!screen.queryByText('Alice'), 'a saved contact is listed as unknown');
+ });
+
+ test('a later address book read that fails keeps the Unknown list it already has', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ listExtra = true;
+ renderPage();
+ await screen.findByText('Bobby');
+ fireEvent.click(screen.getByRole('button', { name: 'Unknown' }));
+ await screen.findByText('Bobby');
+
+ failContacts = true;
+ await queryClients[0].invalidateQueries({ queryKey: ['contacts', SESSION.id] });
+ await waitFor(() => assert.equal(contactReads().length, 2));
+ await settle();
+ assert.ok(screen.getByText('Bobby'), 'the list it had was dropped');
+ assert.ok(!screen.queryByText('Could not load contacts'), 'a failed refresh hid a list that was still good');
+ });
+
+ test('the address book is not read again when the window regains focus, unless the last read failed', async () => {
+ const { screen, fireEvent, act, waitFor } = rtl;
+ renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ await screen.findByRole('button', { name: 'Rename contact' });
+ const regainFocus = () =>
+ act(() => {
+ focusManager.setFocused(false);
+ focusManager.setFocused(true);
+ });
+
+ // Stale, as it is five minutes on, yet not worth another walk of every contact.
+ await queryClients[0].invalidateQueries({ queryKey: ['contacts', SESSION.id], refetchType: 'none' });
+ regainFocus();
+ await settle();
+ assert.equal(contactReads().length, 1, 'focus walked the address book again');
+
+ // A read that failed is tried again on the next focus.
+ rtl.cleanup();
+ failContacts = true;
+ renderPage();
+ await screen.findByText('Alice');
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Alice' }));
+ await waitFor(() => assert.equal(contactReads().length, 2));
+ failContacts = false;
+ regainFocus();
+ await screen.findByRole('button', { name: 'Rename contact' });
+ assert.equal(contactReads().length, 3);
+ });
+
+ test('Save contact is offered again for the open privacy-id chat once the engine knows its phone, with no reload', async t => {
+ const { screen, fireEvent, act, waitFor, within } = rtl;
+ let clock = 1_800_000_000_000;
+ t.mock.method(Date, 'now', () => clock);
+ listExtra = true;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Lia'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ // The route answers null for an id it found no phone for and for a lookup that failed alike.
+ await waitFor(() => assert.ok(phoneRequests().length >= 1, 'the phone was not asked for'));
+ fireEvent.click(container.querySelector('.room-menu-trigger') as HTMLElement);
+ const saveEntry = () =>
+ within(container.querySelector('.room-menu-popover') as HTMLElement).getByRole('button', {
+ name: /^Save contact/,
+ }) as HTMLButtonElement;
+ assert.equal(saveEntry().disabled, true, 'Save contact is offered without a phone to save under');
+
+ // The engine answers a minute later, and the open menu follows once the window is focused again.
+ lidPhones[LID_CHAT.id] = '15550004444';
+ clock += 61_000;
+ act(() => {
+ focusManager.setFocused(false);
+ focusManager.setFocused(true);
+ });
+ // The check reads the page and changes nothing: a callback that touched the DOM would re-run itself forever.
+ await waitFor(() =>
+ assert.equal(saveEntry().disabled, false, 'Save contact stayed disabled after the engine answered'),
+ );
+ });
+
+ test('a chat keyed by a privacy id offers Save contact disabled, with the reason, and sends nothing', async () => {
+ const { screen, fireEvent } = rtl;
+ listExtra = true;
+ renderPage();
+ await screen.findByText('Lia');
+ fireEvent.click(screen.getByRole('button', { name: 'Actions for Lia' }));
+ const save = screen.getByRole('button', { name: /^Save contact/ }) as HTMLButtonElement;
+ assert.equal(save.disabled, true, 'Save is offered for a @lid chat');
+ assert.match(save.textContent ?? '', /privacy id \(@lid\)/);
fireEvent.click(save);
assert.ok(!screen.queryByRole('dialog'), 'the save dialog opened for a @lid chat');
assert.ok(!fetchCalls.some(c => c.method === 'PUT' && c.path.includes('/contacts/')), 'a @lid id was sent');
@@@ -970,6 -2674,459 +2933,457 @@@ test('Mark as unread waits for an autom
assert.equal(readsOf(CHAT.id).length, 1, 'another automatic read followed the unread mark');
});
+ // ── Baileys acknowledges the messages a read names, so the page names them. ──
+
+ const readBodies = (chatId: string) => readsOf(chatId).map(c => c.body);
+
+ test('on Baileys the automatic read names the incoming messages of the thread, newest included', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ aliceThread = [threadRow(1), threadRow(2, 'outgoing'), threadRow(3), threadRow(4)];
+ renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(readsOf(CHAT.id).length >= 1, 'opening the chat did not mark it read'), {
+ timeout: 3_000,
+ });
+ await screen.findByText('message 4');
+ await waitFor(() => assert.ok(readBodies(CHAT.id).at(-1) !== undefined), { timeout: 3_000 });
+ assert.deepEqual(readBodies(CHAT.id).at(-1), {
+ chatId: CHAT.id,
+ messageIds: ['wamid.in.1', 'wamid.in.3', 'wamid.in.4'],
+ });
+ });
+
+ test('a message that arrives later is the only one the next read names', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ aliceThread = [threadRow(1), threadRow(2)];
+ renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await screen.findByText('message 2');
+ await waitFor(
+ () => assert.deepEqual(readBodies(CHAT.id).at(-1), { chatId: CHAT.id, messageIds: ['wamid.in.1', 'wamid.in.2'] }),
+ {
+ timeout: 3_000,
+ },
+ );
+ fetchCalls.length = 0;
+
+ receiveFromAlice('wamid.live.1', 'a live one');
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1), { timeout: 3_000 });
+ assert.deepEqual(readBodies(CHAT.id), [{ chatId: CHAT.id, messageIds: ['wamid.live.1'] }]);
+ });
+
+ test('a thread that loads after the opening read is read again with its ids', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ aliceThread = [threadRow(1), threadRow(2)];
+ const release = hold('thread');
+ renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ // The opening read is due before the thread has come, so it names nothing.
+ await waitFor(() => assert.deepEqual(readBodies(CHAT.id), [{ chatId: CHAT.id }]), { timeout: 3_000 });
+
+ release();
+ await screen.findByText('message 2');
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 2), { timeout: 3_000 });
+ assert.deepEqual(readBodies(CHAT.id).at(-1), { chatId: CHAT.id, messageIds: ['wamid.in.1', 'wamid.in.2'] });
+ });
+
+ test('on whatsapp-web.js the read names no message, since the engine reads the whole chat', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ window.sessionStorage.setItem('openwa_engine_type', 'whatsapp-web.js');
+ aliceThread = [threadRow(1), threadRow(2)];
+ renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await screen.findByText('message 2');
+ await waitFor(() => assert.ok(readsOf(CHAT.id).length >= 1), { timeout: 3_000 });
+ assert.deepEqual(readBodies(CHAT.id), [{ chatId: CHAT.id }]);
+ });
+
+ /** Make the document read as hidden (a background tab) or visible again, as the browser does before `visibilitychange`. */
+ function setTabHidden(hidden: boolean): void {
+ if (hidden) {
+ Object.defineProperty(document, 'visibilityState', { value: 'hidden', configurable: true });
+ Object.defineProperty(document, 'hidden', { value: true, configurable: true });
+ } else {
+ delete (document as unknown as Record<string, unknown>).visibilityState;
+ delete (document as unknown as Record<string, unknown>).hidden;
+ }
+ }
+
+ /** A frame the gateway's socket delivers, as the page's realtime handlers receive it. */
+ function receiveEvent(event: string, data: Record<string, unknown>): void {
+ rtl.act(() =>
+ lastSocket()?.receive('message', {
+ type: 'event',
+ timestamp: new Date(1_700_002_000_000).toISOString(),
+ payload: { event, sessionId: SESSION.id, data },
+ }),
+ );
+ }
+
+ /** A message from Alice, delivered the way the gateway's socket delivers one. */
+ function receiveFromAlice(id: string, body: string): void {
+ receiveEvent('message.received', {
+ id,
+ chatId: CHAT.id,
+ from: CHAT.id,
+ to: 'me',
+ body,
+ type: 'text',
+ fromMe: false,
+ timestamp: 1_700_001_900,
+ });
+ }
+
+ test('a message that reaches the open chat while the tab is hidden is marked read once the tab is visible', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1, 'opening the chat did not mark it read'), {
+ timeout: 3_000,
+ });
+ fetchCalls.length = 0;
+
+ setTabHidden(true);
+ try {
+ receiveFromAlice('wamid.hidden.1', 'are you there?');
+ await screen.findAllByText('are you there?');
+ // Past the quiet window the read would have gone out.
+ await new Promise(resolve => setTimeout(resolve, 1_000));
+ assert.deepEqual(readsOf(CHAT.id), [], 'a hidden tab sent a read receipt');
+ } finally {
+ setTabHidden(false);
+ }
+ rtl.act(() => {
+ document.dispatchEvent(new window.Event('visibilitychange'));
+ });
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1, 'the withheld read did not follow'), { timeout: 3_000 });
+ assert.ok(!screen.queryByLabelText(/unread message/), 'the open chat was badged');
+ });
+
+ test('a list asked for before the open chat read went out leaves no badge on it once the read did', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1, 'opening the chat did not mark it read'), {
+ timeout: 3_000,
+ });
+
+ // What the gateway reports for Alice: one unread message from the moment it arrived until a read reaches it.
+ const readsAtArrival = readsOf(CHAT.id).length;
+ Object.defineProperty(aliceNow, 'unreadCount', {
+ enumerable: true,
+ configurable: true,
+ get: () => (readsOf(CHAT.id).length > readsAtArrival ? 0 : 1),
+ });
+ const listReads = () => fetchCalls.filter(c => c.method === 'GET' && c.path.includes('/chats?')).length;
+ // The tab is visible: the read is due a debounce after the message, and a list asked for inside it still counts it.
+ receiveFromAlice('wamid.visible.badge', 'are you there?');
+ const before = listReads();
+ receiveEvent('message.edited', {
+ messageId: 'wamid.edit.visible',
+ chatId: '[email protected]',
+ body: 'edited',
+ timestamp: 1_700_001_000,
+ });
+ await waitFor(() => assert.ok(listReads() > before, 'the edit did not reload the list'), { timeout: 3_000 });
+ await settle();
+ assert.equal(readsOf(CHAT.id).length, readsAtArrival, 'the read went out before the list was asked for');
+
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, readsAtArrival + 1, 'the read did not go out'), {
+ timeout: 3_000,
+ });
+ await settle();
+ await settle();
+ assert.ok(!screen.queryByLabelText('1 unread message'), 'the open chat keeps a badge after its read went out');
+ });
+
+ test('a read the engine declines leaves the open chat showing what the gateway still counts', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1, 'opening the chat did not mark it read'), {
+ timeout: 3_000,
+ });
+
+ declineReads = true;
+ const readsAtArrival = readsOf(CHAT.id).length;
+ aliceNow.unreadCount = 1;
+ const listReads = () => fetchCalls.filter(c => c.method === 'GET' && c.path.includes('/chats?')).length;
+ receiveFromAlice('wamid.declined', 'are you there?');
+ const before = listReads();
+ receiveEvent('message.edited', {
+ messageId: 'wamid.edit.declined',
+ chatId: '[email protected]',
+ body: 'edited',
+ timestamp: 1_700_001_000,
+ });
+ await waitFor(() => assert.ok(listReads() > before, 'the edit did not reload the list'), { timeout: 3_000 });
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, readsAtArrival + 1, 'the read did not go out'), {
+ timeout: 3_000,
+ });
+ await settle();
+ await settle();
+ assert.ok(screen.queryByLabelText('1 unread message'), 'a read nothing acknowledged hid the count the gateway keeps');
+ });
+
+ test('a chat left before its read is acknowledged keeps the unread count it gathered meanwhile', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ listExtra = true;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1, 'opening the chat did not mark it read'), {
+ timeout: 3_000,
+ });
+
+ // A message into the open chat queues its read; the chat is left, and another message arrives before the read.
+ const readsAtArrival = readsOf(CHAT.id).length;
+ receiveFromAlice('wamid.first', 'are you there?');
+ fireEvent.click(screen.getByText('Bobby'));
- await waitFor(() =>
- assert.equal(container.querySelector('.room-header .room-contact-info h3')?.textContent, 'Bobby'),
- );
++ await waitFor(() => assert.equal(container.querySelector('.room-header .room-contact-name')?.textContent, 'Bobby'));
+ receiveFromAlice('wamid.second', 'hello?');
+ await waitFor(() => assert.ok(screen.queryByLabelText('1 unread message'), 'the chat left did not gather a count'));
+
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, readsAtArrival + 1, 'the queued read did not go out'), {
+ timeout: 3_000,
+ });
+ await settle();
+ await settle();
+ assert.ok(screen.queryByLabelText('1 unread message'), 'the read of a chat left hid the count it gathered since');
+ });
+
+ test('a tab that comes back a second time with nothing new owes no second read', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1, 'opening the chat did not mark it read'), {
+ timeout: 3_000,
+ });
+ fetchCalls.length = 0;
+ const visibilityChanged = () =>
+ rtl.act(() => {
+ document.dispatchEvent(new window.Event('visibilitychange'));
+ });
+
+ try {
+ setTabHidden(true);
+ receiveFromAlice('wamid.hidden.twice', 'are you there?');
+ await screen.findAllByText('are you there?');
+ await new Promise(resolve => setTimeout(resolve, 1_000));
+ assert.deepEqual(readsOf(CHAT.id), [], 'a hidden tab sent a read receipt');
+ setTabHidden(false);
+ visibilityChanged();
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1, 'the withheld read did not follow'), {
+ timeout: 3_000,
+ });
+ // Let anything the first return queued go out before counting the second.
+ await new Promise(resolve => setTimeout(resolve, 300));
+
+ fetchCalls.length = 0;
+ setTabHidden(true);
+ visibilityChanged();
+ setTabHidden(false);
+ visibilityChanged();
+ await new Promise(resolve => setTimeout(resolve, 1_800));
+ assert.deepEqual(readsOf(CHAT.id), [], 'a tab that saw nothing new sent a read when it came back');
+ } finally {
+ setTabHidden(false);
+ }
+ });
+
+ test('a list reload while the tab is hidden badges nothing on the open chat once the tab is visible and the read went out', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1, 'opening the chat did not mark it read'), {
+ timeout: 3_000,
+ });
+
+ // What the gateway reports for Alice: one unread message from the moment it arrived until a read reaches it.
+ let readsAtArrival = Number.POSITIVE_INFINITY;
+ Object.defineProperty(aliceNow, 'unreadCount', {
+ enumerable: true,
+ configurable: true,
+ get: () => (readsOf(CHAT.id).length > readsAtArrival ? 0 : 1),
+ });
+ const listReads = () => fetchCalls.filter(c => c.method === 'GET' && c.path.includes('/chats?')).length;
+ setTabHidden(true);
+ try {
+ readsAtArrival = readsOf(CHAT.id).length;
+ receiveFromAlice('wamid.hidden.badge', 'are you there?');
+ await screen.findAllByText('are you there?');
+ // Past the quiet window: the read is withheld, so the gateway still counts the message.
+ await new Promise(resolve => setTimeout(resolve, 1_000));
+ assert.equal(readsOf(CHAT.id).length, readsAtArrival, 'a hidden tab sent a read receipt');
+
+ // An edit in a chat that was never opened asks for the list, which now reports the unread message. A badge on
+ // the chat nobody is looking at is accepted while the tab is hidden.
+ const before = listReads();
+ receiveEvent('message.edited', {
+ messageId: 'wamid.edit.badge',
+ chatId: '[email protected]',
+ body: 'edited',
+ timestamp: 1_700_001_000,
+ });
+ await waitFor(() => assert.ok(listReads() > before, 'the edit did not reload the list'), { timeout: 3_000 });
+ await settle();
+ } finally {
+ setTabHidden(false);
+ }
+ rtl.act(() => {
+ document.dispatchEvent(new window.Event('visibilitychange'));
+ });
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, readsAtArrival + 1, 'the withheld read did not follow'), {
+ timeout: 3_000,
+ });
+ await settle();
+ assert.ok(!screen.queryByLabelText('1 unread message'), 'the open chat still shows an unread badge after its read');
+ assert.equal(readsOf(CHAT.id).length, readsAtArrival + 1, 'more than one read went out');
+ });
+
+ test('a tab that was hidden but sees no message owes no read when it is visible again', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1), { timeout: 3_000 });
+ fetchCalls.length = 0;
+
+ setTabHidden(true);
+ setTabHidden(false);
+ rtl.act(() => {
+ document.dispatchEvent(new window.Event('visibilitychange'));
+ });
+ await new Promise(resolve => setTimeout(resolve, 1_000));
+ assert.deepEqual(readsOf(CHAT.id), []);
+ });
+
+ test("the open room's menu offers Mark as unread for a chat that was opened with unread messages", async () => {
+ const { screen, fireEvent, waitFor, within } = rtl;
+ aliceNow.unreadCount = 2;
+ const { container } = renderPage();
+ await screen.findByLabelText('2 unread messages');
+ fireEvent.click(screen.getByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.ok(!screen.queryByLabelText('2 unread messages'), 'opening the chat kept its badge'));
+
+ fireEvent.click(container.querySelector('.room-menu-trigger') as HTMLElement);
+ const menu = container.querySelector('.room-menu-popover') as HTMLElement;
+ assert.ok(within(menu).getByRole('button', { name: 'Mark as unread' }), 'the room menu lacks Mark as unread');
+ });
+
+ test("the open room's menu follows the chat list when a reload brings a change made elsewhere", async () => {
+ const { screen, fireEvent, act, waitFor, within } = rtl;
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+
+ // The phone pins the chat, and a reconnect reloads the list.
+ aliceNow.pinned = true;
+ const socket = lastSocket();
+ assert.ok(socket, 'the page opened no socket');
+ act(() => socket.receive('disconnect', 'transport close'));
+ act(() => socket.receive('connect'));
+ await screen.findByRole('img', { name: 'Pinned' });
+
+ fireEvent.click(container.querySelector('.room-menu-trigger') as HTMLElement);
+ const menu = container.querySelector('.room-menu-popover') as HTMLElement;
+ assert.ok(within(menu).getByRole('button', { name: 'Unpin chat' }), 'the room menu kept offering Pin chat');
+ });
+
+ // The Clipboard API is missing over plain HTTP on a LAN address (and in jsdom); the house helper falls back to a
+ // hidden textarea and execCommand.
+ async function copyChatIdWith(t: TestContext, copied: boolean): Promise<ReturnType<typeof t.mock.fn>> {
+ const { screen, fireEvent, waitFor } = rtl;
+ const copy = t.mock.fn(() => copied);
+ const hadExecCommand = Object.getOwnPropertyDescriptor(document, 'execCommand');
+ Object.defineProperty(document, 'execCommand', { value: copy, configurable: true, writable: true });
+ t.after(() => {
+ if (hadExecCommand) Object.defineProperty(document, 'execCommand', hadExecCommand);
+ else delete (document as unknown as Record<string, unknown>).execCommand;
+ });
+ assert.equal(navigator.clipboard, undefined);
+
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ fireEvent.click(container.querySelector('.room-menu-trigger') as HTMLElement);
+ fireEvent.click(screen.getByRole('button', { name: 'Copy chat ID' }));
+ return copy;
+ }
+
+ test('Copy chat ID works where navigator.clipboard does not exist', async t => {
+ const copy = await copyChatIdWith(t, true);
+ await rtl.screen.findByText('Chat ID copied');
+ assert.equal(copy.mock.callCount(), 1);
+ assert.ok(!rtl.screen.queryByText('Could not copy to clipboard'));
+ });
+
+ test('Copy chat ID leaves keyboard focus on the room menu button when the fallback copy runs', async t => {
+ // A browser puts focus in the textarea that select() acts on; jsdom does not.
+ t.mock.method(window.HTMLTextAreaElement.prototype, 'select', function (this: HTMLTextAreaElement) {
+ this.focus();
+ });
+ await copyChatIdWith(t, true);
+ await rtl.screen.findByText('Chat ID copied');
+ assert.equal(focusedName(), 'More actions', 'focus fell to the page');
+ });
+
+ test('Copy chat ID says so when the copy did not happen', async t => {
+ const copy = await copyChatIdWith(t, false);
+ await rtl.screen.findByText('Could not copy to clipboard');
+ assert.equal(copy.mock.callCount(), 1);
+ assert.ok(!rtl.screen.queryByText('Chat ID copied'));
+ });
+
+ test('a chat marked unread is read again once it is opened', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const { container } = renderPage();
+ await screen.findByText('Alice');
+ pickRowAction('Alice', 'Mark as unread');
+ await screen.findByLabelText('Marked as unread');
+ fetchCalls.length = 0;
+
+ fireEvent.click(screen.getByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1, 'opening the chat did not read it again'), {
+ timeout: 3_000,
+ });
+ assert.ok(!screen.queryByLabelText('Marked as unread'), 'the badge stayed after the chat was opened');
+ });
+
+ test('a message that reaches the open chat while Mark as unread is out is not read automatically', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ const release = hold('unread');
+ const { container } = renderPage();
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(container.querySelector('.room-header'), 'the room did not open'));
+ await waitFor(() => assert.equal(readsOf(CHAT.id).length, 1, 'opening the chat did not mark it read'), {
+ timeout: 3_000,
+ });
+
+ pickRowAction('Alice', 'Mark as unread');
+ await waitFor(() =>
+ assert.ok(
+ fetchCalls.some(c => c.path.endsWith('/chats/unread')),
+ 'the mark was not sent',
+ ),
+ );
+ fetchCalls.length = 0;
+ receiveFromAlice('wamid.during.1', 'while the mark is out');
+ await screen.findAllByText('while the mark is out');
+ // Past the quiet window, so a read queued by that message would have gone out.
+ await new Promise(resolve => setTimeout(resolve, 1_000));
+ release();
+ await settle();
+ assert.deepEqual(readsOf(CHAT.id), [], 'the message was read automatically and undid the mark');
+ });
+
test('on Baileys neither the row nor the room menu offers Clear chat or Delete chat (#1891)', async () => {
const { screen, fireEvent, waitFor, within } = rtl;
const { container } = renderPage();
diff --cc dashboard/src/pages/Chats.test.ts
index a74e1170b,b3b797cfb..51ac202c0
--- a/dashboard/src/pages/Chats.test.ts
+++ b/dashboard/src/pages/Chats.test.ts
@@@ -1043,6 -1020,53 +1048,53 @@@ test('a reconnect whose refetch fails w
);
});
+ test('a reload asked for before the reconnect zeroed the open row does not bring the gap count back', async () => {
+ const { screen, fireEvent, within, act, waitFor } = rtl;
+ const { container } = renderChats();
- await screen.findByText('Main (15551234567)');
++ await waitFor(() => assert.equal(selectedSessionId(container), SESSION.id));
+ fireEvent.click(await screen.findByText('Alice'));
+ await within(container.querySelector('.room-messages') as HTMLElement).findByText('hello from alice');
+ await new Promise(resolve => setTimeout(resolve, 1_000));
+ resetFetchCalls();
+
+ // Every snapshot counts Alice's gap messages, as the gateway does until it has processed the read.
+ const snapshot = [{ ...CHAT, unreadCount: 4, lastMessage: 'sent during the gap' }, CHAT_2];
+ const answers: Array<() => void> = [];
+ chatsResponder = () =>
+ new Promise<Response>(resolve => {
+ answers.push(() => resolve(jsonResponse(snapshot)));
+ });
+ const edit = () =>
+ receiveEvent('message.edited', {
+ messageId: 'wamid.carol.1',
+ chatId: CHAT_2.id,
+ body: 'edited',
+ timestamp: 1_700_003_000,
+ });
+ edit();
+ await waitFor(() => assert.equal(answers.length, 1));
+ const socket = lastSocket();
+ assert.ok(socket, 'expected the page to have opened a socket');
+ act(() => socket.receive('disconnect', 'transport close'));
+ act(() => socket.receive('connect'));
+ await flush();
+ answers[0]();
+ await screen.findByText('sent during the gap');
+ await waitFor(() => assert.equal(answers.length, 2), { timeout: 3_000 }); // the reconnect's own reload is out
+
+ // Another event asks for a list while it is out; that one starts the moment the reconnect's lands.
+ edit();
+ answers[1]();
+ // The row is zeroed with the reload, well before the read it sends is due.
+ await flush();
+ await flush();
+ assert.ok(!screen.queryByLabelText('4 unread messages'), 'the open chat was badged');
+ await waitFor(() => assert.equal(answers.length, 3), { timeout: 3_000 });
+ answers[2]();
+ await new Promise(resolve => setTimeout(resolve, 300));
+ assert.ok(!screen.queryByLabelText('4 unread messages'), 'the gap count came back on the open chat');
+ });
+
test('a reconnect refetch that settles after the open chat was left keeps its unread count', async () => {
const { screen, fireEvent, within, act, waitFor } = rtl;
const { container } = renderChats();
@@@ -2165,6 -2248,28 +2259,30 @@@ async function clickSearchHit(container
fireEvent.click(hit);
}
-test('a search hit in another session closes the new chat panel of the session that was left', async () => {
++// The New chat panel replaces the whole sidebar, the session switcher and the message search toggle included, so
++// nothing reaches another session while it is open: no hit can switch the session under the panel. Once it is
++// closed, a hit in another session switches to it and the panel stays closed.
++test('the New chat panel leaves no way to another session, and a hit after it closes switches without it', async () => {
+ const { screen, fireEvent, waitFor } = rtl;
+ twoSessions = true;
+ searchHits = [{ ...THIRD_SESSION_HIT, sessionId: SESSION_2.id }];
+ try {
+ const { container } = renderChats();
+ await screen.findByText('Alice');
- // The panel replaces the sidebar lists, session selector included, so a hit is the way to another session.
+ fireEvent.click(screen.getByRole('button', { name: 'New chat' }));
+ assert.ok(container.querySelector('.new-chat-panel'), 'the panel did not open');
++ assert.equal(container.querySelector('.session-switcher-btn'), null, 'the session switcher is reachable');
++ assert.equal(screen.queryByRole('button', { name: 'Search messages' }), null, 'the message search is reachable');
+
++ fireEvent.click(screen.getByRole('button', { name: 'Back' }));
+ await clickSearchHit(container);
- await waitFor(() =>
- assert.ok(!container.querySelector('.new-chat-panel'), 'the panel stayed open on the other session'),
- );
- const select = container.querySelector('select.session-selector') as HTMLSelectElement;
- assert.equal(select.value, SESSION_2.id);
++ await waitFor(() => assert.equal(selectedSessionId(container), SESSION_2.id));
++ assert.equal(container.querySelector('.new-chat-panel'), null, 'the panel came back on the other session');
+ } finally {
+ twoSessions = false;
+ }
+ });
+
test('a search hit in a session that is not connected stays on the selected session', async () => {
const { screen, waitFor } = rtl;
thirdSessionStatus = 'disconnected';
@@@ -3079,3 -3255,420 +3260,423 @@@ test('a live sidebar row survives movem
assert.equal(rtl.screen.getAllByText('Updated during paging').length, 1);
assert.ok(rtl.screen.queryByLabelText('3 unread messages'));
});
+
+ // ── Reading position of a thread ─────────────────────────────────────────────
+
+ const ROOM_HEIGHT = 600;
+ /** What a reaction badge adds to the thread. */
+ const BADGE_PX = 20;
+
+ /**
+ * Scroll geometry for every `.room-messages` the page mounts, clamped to the content as a browser clamps it. The
+ * room unmounts when a session switch closes its chat, so a shim on one element (makeScrollable) would arrive
+ * after the restore it is meant to see. Content height is the bubbles, as in makeScrollable.
+ */
+ function installRoomGeometry(bubblePx: number = BUBBLE_PX): () => void {
+ const proto = window.HTMLDivElement.prototype;
+ const inherited = Object.getOwnPropertyDescriptors(window.Element.prototype);
+ const tops = new WeakMap<Element, number>();
+ const isRoom = (el: Element): boolean => el.classList.contains('room-messages');
+ const contentHeight = (el: Element): number =>
+ el.querySelectorAll('.message-bubble').length * bubblePx +
+ el.querySelectorAll('.message-reactions-badge').length * BADGE_PX;
+ const maxTop = (el: Element): number => Math.max(0, contentHeight(el) - ROOM_HEIGHT);
+ Object.defineProperties(proto, {
+ scrollHeight: {
+ configurable: true,
+ get(this: Element) {
+ return isRoom(this) ? contentHeight(this) : inherited.scrollHeight.get!.call(this);
+ },
+ },
+ clientHeight: {
+ configurable: true,
+ get(this: Element) {
+ return isRoom(this) ? ROOM_HEIGHT : inherited.clientHeight.get!.call(this);
+ },
+ },
+ scrollTop: {
+ configurable: true,
+ get(this: Element) {
+ return isRoom(this) ? Math.min(tops.get(this) ?? 0, maxTop(this)) : inherited.scrollTop.get!.call(this);
+ },
+ set(this: Element, value: number) {
+ if (isRoom(this)) tops.set(this, Math.max(0, Math.min(value, maxTop(this))));
+ else inherited.scrollTop.set!.call(this, value);
+ },
+ },
+ });
+ return () => {
+ for (const key of ['scrollHeight', 'clientHeight', 'scrollTop'] as const) {
+ delete (proto as unknown as Record<string, unknown>)[key];
+ }
+ };
+ }
+
+ test('a chat opened in another session starts at its newest message, not at the offset left in the first', async () => {
+ const { screen, fireEvent, within } = rtl;
+ twoSessions = true;
+ // Session 2 lists Carol too, a contact both accounts share.
+ chatsResponder = sessionId =>
+ Promise.resolve(
+ jsonResponse(sessionId === SESSION.id ? [CHAT, CHAT_2] : [CHAT, { ...CHAT_2, lastMessage: 'carol on two' }]),
+ );
+ const restoreGeometry = installRoomGeometry();
+ try {
+ const { container } = renderChats();
+ const thread = await openPagedChat(container);
+ assert.equal(thread.scrollTop, thread.scrollHeight - thread.clientHeight, 'a first visit did not open at the end');
+
+ thread.scrollTop = 900; // the reader goes back through Carol's history in the first session
+ fireEvent.scroll(thread);
+
- const selector = container.querySelector('select.session-selector') as HTMLSelectElement;
- fireEvent.change(selector, { target: { value: SESSION_2.id } });
++ selectSession(container, SESSION_2.id);
+ await screen.findByText('carol on two');
+ fireEvent.click(screen.getByText('Carol'));
+ const second = container.querySelector('.room-messages') as HTMLElement;
+ await within(second).findByText('paged message 119');
+ assert.equal(
+ second.scrollTop,
+ second.scrollHeight - second.clientHeight,
+ "Carol opened in the second session at the offset left in the first session's thread",
+ );
+
+ // The first session's own position is still there when the reader comes back to it.
- fireEvent.change(selector, { target: { value: SESSION.id } });
++ selectSession(container, SESSION.id);
+ await screen.findByText('hello from carol');
+ fireEvent.click(screen.getByText('Carol'));
+ const back = container.querySelector('.room-messages') as HTMLElement;
+ await within(back).findByText('paged message 119');
+ assert.equal(back.scrollTop, 900, "the first session's position was lost");
+ } finally {
+ restoreGeometry();
+ twoSessions = false;
+ }
+ });
+
+ // A live message in the open chat follows a reader who is at the bottom, whoever sent it: the contact, or the
+ // account itself (the phone, an API client, an automation).
+ for (const fromMe of [false, true]) {
+ test(`a live message ${fromMe ? 'from the account itself' : 'from the contact'} scrolls a reader at the bottom to it`, async () => {
+ const { within, waitFor } = rtl;
+ const restoreGeometry = installRoomGeometry();
+ try {
+ const { container } = renderChats();
+ const thread = await openPagedChat(container);
+ const newest = (): number => thread.scrollHeight - thread.clientHeight;
+ assert.equal(thread.scrollTop, newest(), 'a first visit did not open at the end');
+
+ receiveEvent(fromMe ? 'message.sent' : 'message.received', {
+ id: 'wamid.live.follow',
+ chatId: CHAT_2.id,
+ from: fromMe ? 'me' : CHAT_2.id,
+ to: fromMe ? CHAT_2.id : 'me',
+ body: 'live follow',
+ type: 'text',
+ fromMe,
+ timestamp: 1_700_001_500,
+ });
+ await within(thread).findByText('live follow');
+ await waitFor(() => assert.equal(thread.scrollTop, newest(), 'the new message was left below the fold'));
+ } finally {
+ restoreGeometry();
+ }
+ });
+ }
+
+ test('a live message from the account itself leaves a reader of older messages where they are', async () => {
+ const { fireEvent, within } = rtl;
+ const restoreGeometry = installRoomGeometry();
+ try {
+ const { container } = renderChats();
+ const thread = await openPagedChat(container);
+ thread.scrollTop = 900;
+ fireEvent.scroll(thread);
+
+ receiveEvent('message.sent', {
+ id: 'wamid.live.reading',
+ chatId: CHAT_2.id,
+ from: 'me',
+ to: CHAT_2.id,
+ body: 'live while reading',
+ type: 'text',
+ fromMe: true,
+ timestamp: 1_700_001_500,
+ });
+ await within(thread).findByText('live while reading');
+ await flush();
+ assert.equal(thread.scrollTop, 900);
+ } finally {
+ restoreGeometry();
+ }
+ });
+
+ test('a message sent from the page scrolls the thread to it, whatever the reader was reading', async () => {
+ const { screen, fireEvent, within, waitFor } = rtl;
+ const restoreGeometry = installRoomGeometry();
+ try {
+ const { container } = renderChats();
+ const thread = await openPagedChat(container);
+ thread.scrollTop = 900;
+ fireEvent.scroll(thread);
+
+ fireEvent.change(screen.getByPlaceholderText('Type a message...'), { target: { value: 'sent from the page' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ await within(thread).findByText('sent from the page');
+ await waitFor(() =>
+ assert.equal(
+ thread.scrollTop,
+ thread.scrollHeight - thread.clientHeight,
+ 'the thread stayed where the reader was',
+ ),
+ );
+ } finally {
+ restoreGeometry();
+ }
+ });
+
+ // A message that merges into a row the thread already holds adds no row, so it must not leave the thread waiting for
+ // one: the next commit that grows it would be taken for that row.
+ test('the echo of a send from the page, after its response, does not take a reader paging upward to the bottom', async () => {
+ const { screen, fireEvent, within, waitFor } = rtl;
+ resetFetchCalls();
+ // Bubbles are 8px, so the older page is about as tall as the thread's whole scroll range, as a page of 100 rows is.
+ const bubblePx = 8;
+ const restoreGeometry = installRoomGeometry(bubblePx);
+ try {
+ const { container } = renderChats();
+ const thread = await openPagedChat(container);
+
+ fireEvent.change(screen.getByPlaceholderText('Type a message...'), { target: { value: 'reply from the page' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ await within(thread).findByText('reply from the page');
+ await waitFor(() => assert.ok(findFetchCall('POST', `/api/sessions/${SESSION.id}/messages/send-text`)));
+ await flush(); // the response has reconciled the placeholder under its real id
+ receiveEvent('message.sent', {
+ id: sendTextId,
+ chatId: CHAT_2.id,
+ from: 'me',
+ to: CHAT_2.id,
+ body: 'reply from the page',
+ type: 'text',
+ fromMe: true,
+ timestamp: 1_700_001_500,
+ });
+ await flush();
+ assert.equal(within(thread).getAllByText('reply from the page').length, 1, 'the echo added a second row');
+
+ // The reader goes back through the history; the older page lands above them.
+ const releaseOlderPage = holdOlderPage();
+ thread.scrollTop = 0;
+ fireEvent.scroll(thread);
+ await waitFor(() => assert.ok(thread.querySelector('.messages-loading-older')));
+ releaseOlderPage();
+ await within(thread).findByText('paged message 0');
+ await waitFor(() => assert.equal(thread.querySelector('.messages-loading-older') === null, true));
+ assert.equal(
+ thread.scrollTop,
+ PAGED_OLDEST.length * bubblePx,
+ 'the reader was not held on the message they were on',
+ );
+ } finally {
+ restoreGeometry();
+ }
+ });
+
+ test('a message delivered twice leaves a reader just above the bottom where they are when the thread grows', async () => {
+ const { fireEvent, within, waitFor } = rtl;
+ const restoreGeometry = installRoomGeometry();
+ try {
+ const { container } = renderChats();
+ const thread = await openPagedChat(container);
+ thread.scrollTop = thread.scrollHeight - thread.clientHeight - 60; // inside the 100px band that follows
+ fireEvent.scroll(thread);
+ const reader = thread.scrollTop;
+
+ // The newest row arrives again: the cache merges it, and the thread does not grow.
+ receiveEvent('message.received', {
+ id: 'wamid.paged.119',
+ chatId: CHAT_2.id,
+ from: CHAT_2.id,
+ to: 'me',
+ body: 'paged message 119',
+ type: 'text',
+ fromMe: false,
+ timestamp: 1_700_001_119,
+ });
+ await flush();
+ assert.equal(thread.querySelectorAll('.message-bubble').length, PAGE_SIZE, 'the duplicate added a row');
+
+ // Something else grows the thread: a reaction badge under a bubble.
+ receiveEvent('message.reaction', {
+ messageId: 'wamid.paged.119',
+ chatId: CHAT_2.id,
+ reaction: '👍',
+ senderId: CHAT_2.id,
+ reactions: { [CHAT_2.id]: '👍' },
+ });
+ await waitFor(() => assert.ok(thread.querySelector('.message-reactions-badge')));
+ await within(thread).findByText('paged message 119');
+ assert.equal(thread.scrollTop, reader, 'the reader was taken to the bottom by a commit that was not a new message');
+ } finally {
+ restoreGeometry();
+ }
+ });
+
+ test('a message sent from the page scrolls a chat reopened at its saved spot to it', async () => {
+ const { screen, fireEvent, within, waitFor } = rtl;
+ const restoreGeometry = installRoomGeometry();
+ try {
+ const { container } = renderChats();
+ const thread = await openPagedChat(container);
+ thread.scrollTop = 900; // the reader's spot in Carol's thread
+ fireEvent.scroll(thread);
+
+ fireEvent.click(await screen.findByText('Alice'));
+ await within(container.querySelector('.room-header') as HTMLElement).findByText('Alice');
+ fireEvent.click(await screen.findByText('Carol'));
+ await within(container.querySelector('.room-messages') as HTMLElement).findByText('paged message 119');
+ assert.equal(thread.scrollTop, 900, 'Carol did not reopen at the spot the reader left');
+
+ fireEvent.change(screen.getByPlaceholderText('Type a message...'), { target: { value: 'sent at the saved spot' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ await within(thread).findByText('sent at the saved spot');
+ await waitFor(() =>
+ assert.equal(
+ thread.scrollTop,
+ thread.scrollHeight - thread.clientHeight,
+ 'the sent message was left below the fold',
+ ),
+ );
+ } finally {
+ restoreGeometry();
+ }
+ });
+
+ test('a message sent while a chat with a saved spot loads again opens the chat at it', async () => {
+ const { screen, fireEvent, within, waitFor } = rtl;
+ resetFetchCalls();
+ // Forty more of Alice's messages, so her thread scrolls.
+ firstPageExtra = Array.from({ length: 40 }, (_, i) => ({
+ ...DB_MESSAGE,
+ id: `db-extra-${i}`,
+ waMessageId: `wamid.extra.${i}`,
+ body: `alice extra ${i}`,
+ timestamp: 1_700_000_100 + i,
+ createdAt: new Date((1_700_000_100 + i) * 1000).toISOString(),
+ }));
+ const restoreGeometry = installRoomGeometry();
+ try {
+ const { container } = renderChats();
- await screen.findByText('Main (15551234567)');
++ await waitFor(() => assert.equal(selectedSessionId(container), SESSION.id));
+ fireEvent.click(await screen.findByText('Alice'));
+ const thread = container.querySelector('.room-messages') as HTMLElement;
+ await within(thread).findByText('alice extra 39');
+ thread.scrollTop = 300; // the reader's spot in Alice's thread
+ fireEvent.scroll(thread);
+
+ fireEvent.click(await screen.findByText('Carol'));
+ await within(thread).findByText('paged message 119');
+ // Alice's thread leaves the cache while the reader is elsewhere, and her first page is slow to come back.
+ queryClient!.removeQueries({ queryKey: ['messages', SESSION.id, CHAT.id] });
+ let releaseFirstPage!: () => void;
+ firstPageGate = new Promise<void>(resolve => {
+ releaseFirstPage = resolve;
+ });
+ fireEvent.click(await screen.findByText('Alice'));
+ await waitFor(() => assert.ok(thread.querySelector('.messages-loading')));
+
+ fireEvent.change(screen.getByPlaceholderText('Type a message...'), { target: { value: 'sent while loading' } });
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ await waitFor(() => assert.ok(findFetchCall('POST', `/api/sessions/${SESSION.id}/messages/send-text`)));
+ await flush();
+ releaseFirstPage();
+ await within(thread).findByText('sent while loading');
+ assert.equal(
+ thread.scrollTop,
+ thread.scrollHeight - thread.clientHeight,
+ 'the message sent while the chat loaded was left below the fold',
+ );
+ } finally {
+ restoreGeometry();
+ }
+ });
+
+ // ── Live feed subscription ───────────────────────────────────────────────────
+
+ const MESSAGE_FEED_EVENTS = [
+ 'message.received',
+ 'message.sent',
+ 'message.ack',
+ 'message.reaction',
+ 'message.revoked',
+ 'message.edited',
+ 'status.received',
+ ];
+
-/** The payload of every frame the page sent over the socket. */
-const feedFrames = (): unknown[] => (lastSocket()?.emitted ?? []).map(frame => frame.args[0]);
++/**
++ * The payload of every frame the page sent over the socket for the message feed. The session feed the switcher
++ * follows (session.status and the like, on the '*' room) is a subscription of its own and is left out.
++ */
++const feedFrames = (): unknown[] =>
++ (lastSocket()?.emitted ?? [])
++ .map(frame => frame.args[0] as { sessionId?: string; events?: string[] })
++ .filter(frame => frame.sessionId !== '*' && !frame.events?.includes('session.status'));
+
+ test("the page joins the open session's message events once connected, and moves to the next session on a switch", async () => {
- const { screen, fireEvent, waitFor } = rtl;
++ const { waitFor } = rtl;
+ twoSessions = true;
+ try {
+ const { container } = renderChats();
- await screen.findByText('Main (15551234567)');
++ await waitFor(() => assert.equal(selectedSessionId(container), SESSION.id));
+ await waitFor(() =>
+ assert.deepEqual(feedFrames(), [{ type: 'subscribe', sessionId: SESSION.id, events: MESSAGE_FEED_EVENTS }]),
+ );
+
- fireEvent.change(container.querySelector('select.session-selector') as HTMLSelectElement, {
- target: { value: SESSION_2.id },
- });
++ selectSession(container, SESSION_2.id);
+ await waitFor(() =>
+ assert.deepEqual(feedFrames().slice(1), [
+ { type: 'unsubscribe', sessionId: SESSION.id },
+ { type: 'subscribe', sessionId: SESSION_2.id, events: MESSAGE_FEED_EVENTS },
+ ]),
+ );
+ } finally {
+ twoSessions = false;
+ }
+ });
+
+ // A failed read of the sessions is not "no connected sessions", which tells the operator to go connect one.
+ test('a failed session list says so and offers the read again, not the no-sessions guidance', async () => {
+ const { screen, fireEvent, within } = rtl;
+ sessionListStatus = 502;
+ renderChats();
+
+ const alert = await screen.findByRole('alert');
+ assert.match(alert.textContent ?? '', /Failed to load sessions/);
+ assert.match(alert.textContent ?? '', /Bad Gateway/);
+ assert.equal(
+ screen.queryByText('No connected sessions') === null,
+ true,
+ 'a failed read claimed there are no sessions',
+ );
+
+ sessionListStatus = null;
+ fireEvent.click(within(alert).getByRole('button', { name: 'Retry' }));
+ await screen.findByText('Alice');
+ assert.equal(screen.queryByRole('alert') === null, true);
+ });
+
+ // A chat list that could not be read is not an empty one: the sidebar alone would read "No chats".
+ test('a failed chat list says so and offers the read again, then clears once a read lands', async () => {
+ const { screen, fireEvent, within } = rtl;
+ chatsResponder = () => Promise.resolve(jsonResponse({ message: 'gateway timeout' }, 504));
+ renderChats();
+
+ const alert = await screen.findByRole('alert');
+ assert.match(alert.textContent ?? '', /Failed to load chats/);
+ assert.match(alert.textContent ?? '', /gateway timeout/);
+
+ chatsResponder = null;
+ fireEvent.click(within(alert).getByRole('button', { name: 'Retry' }));
+ await screen.findByText('Alice');
+ assert.equal(screen.queryByRole('alert') === null, true, 'the failure stayed after the list was read');
+ });
diff --cc dashboard/src/pages/Chats.tsx
index 65fc55222,98e41fff3..6bb2adabd
--- a/dashboard/src/pages/Chats.tsx
+++ b/dashboard/src/pages/Chats.tsx
@@@ -72,10 -74,16 +75,12 @@@ import { useContactStatuses } from '../
import { useChatScrollPosition } from '../hooks/useChatScrollPosition';
import { createTrailingCoalescer } from '../utils/trailingCoalescer';
import { createReloadCoalescer, type ReloadCoalescer } from '../utils/reloadCoalescer';
+ import { copyToClipboard } from '../utils/clipboard';
+ import { statusFontStyle } from '../utils/statusFonts';
import MessageBody from '../components/chats/MessageBody';
import MediaLightbox, { type LightboxItem } from '../components/chats/MediaLightbox';
-import KindIcon from '../components/chats/KindIcon';
+import ChatAvatar from '../components/chats/ChatAvatar';
import ChatSidebar from '../components/chats/ChatSidebar';
-import ChatThread from '../components/chats/ChatThread';
-import ChatComposer, { type StagedAttachment } from '../components/chats/ChatComposer';
-import StatusMedia from '../components/chats/StatusMedia';
-import StatusComposeModal from '../components/chats/StatusComposeModal';
import NewChatPanel from '../components/chats/NewChatPanel';
import GroupInfoDialog from '../components/chats/GroupInfoDialog';
import { MuteChatDialog, SaveContactDialog, type MuteDuration } from '../components/chats/ChatDialogs';
@@@ -194,14 -185,16 +188,17 @@@ export function Chats()
const [searchQuery, setSearchQuery] = useState<string>('');
const [chatFilter, setChatFilter] = useState<ChatListFilter>('all');
- // The new-chat panel replaces the sidebar lists while open; the contact panel sits beside the room,
- // and the room's overflow menu drops from its header.
- // The new-chat panel replaces the sidebar lists while open; the room's overflow menu drops from its header.
++ // The new-chat panel replaces the sidebar lists while open; the contact panel (below, with the open chat) sits
++ // beside the room, and the room's overflow menu drops from its header.
const [showNewChat, setShowNewChat] = useState<boolean>(false);
- const [showContactInfo, setShowContactInfo] = useState<boolean>(false);
const [roomMenuOpen, setRoomMenuOpen] = useState<boolean>(false);
+ const roomMenuRef = useRef<HTMLDivElement | null>(null);
+ const roomMenuTriggerRef = useRef<HTMLButtonElement | null>(null);
// The group whose info dialog is open, from its row's menu or from the open room's.
const [groupDialogChat, setGroupDialogChat] = useState<Chat | null>(null);
- // A destructive row action awaiting confirmation, and whether it is in flight.
+ // A destructive row action awaiting confirmation, and the one whose request is out. A dialog is busy only
+ // while its own request is: the answer of a dialog dismissed meanwhile (Escape, the overlay) neither
+ // disables nor closes the next one, so these are compared by identity, never cleared unconditionally.
const [confirmAction, setConfirmAction] = useState<{
kind: 'leave' | 'clear' | 'delete' | 'block';
chat: Chat;
@@@ -223,6 -222,6 +226,14 @@@
// simply closes the viewer.
const [activeStatusContactId, setActiveStatusContactId] = useState<string | null>(null);
++ // The room whose contact panel is open, by session and chat. The panel belongs to that room and closes with it, on
++ // a session switch and when another chat opens: the next room would otherwise open with it, and below 1200px it
++ // covers the thread. Cleared while rendering, as menuOpenedFor is.
++ const [contactInfoFor, setContactInfoFor] = useState<string>('');
++ const openRoomKey = activeChat ? readKey(selectedSessionId, activeChat.id) : '';
++ if (contactInfoFor !== '' && contactInfoFor !== openRoomKey) setContactInfoFor('');
++ const showContactInfo = contactInfoFor !== '' && contactInfoFor === openRoomKey;
++
// Chats/Channels/Status tab selection. Switching tabs closes whatever conversation is open so a
// press on another tab doesn't leave a Chats-tab room rendered underneath a Channels/Status list.
const [activeTab, setActiveTab] = useState<'chats' | 'channels' | 'status'>('chats');
@@@ -371,26 -380,28 +393,29 @@@
current.showErrorToast(current.t(key), err instanceof Error ? err.message : undefined);
}, []);
- // 1. Fetch available connected sessions on mount
- useEffect(() => {
- const loadSessions = async () => {
- try {
- setLoadingSessions(true);
- const list = await sessionApi.list();
- const readySessions = list.filter(s => s.status === 'ready');
- setSessions(readySessions);
- setListedSessions(list);
- if (readySessions.length > 0) {
- setSelectedSessionId(readySessions[0].id);
- }
- } catch (err) {
- showLoadError('chats.errors.loadSessions', err);
- } finally {
- setLoadingSessions(false);
+ // 1. Fetch available connected sessions on mount. A failed read is not "no connected sessions": the gateway may
+ // simply be restarting, so the page says it could not read them and offers the read again.
+ const [sessionsFailure, setSessionsFailure] = useState<string | null>(null);
+ const loadSessions = useCallback(async () => {
+ try {
+ setLoadingSessions(true);
+ setSessionsFailure(null);
+ const list = await sessionApi.list();
+ const readySessions = list.filter(s => s.status === 'ready');
+ setSessions(readySessions);
++ setListedSessions(list);
+ if (readySessions.length > 0) {
+ setSelectedSessionId(readySessions[0].id);
}
- };
+ } catch (err) {
+ setSessionsFailure(err instanceof Error ? err.message : '');
+ } finally {
+ setLoadingSessions(false);
+ }
+ }, []);
+ useEffect(() => {
void loadSessions();
- }, [showLoadError]);
+ }, [loadSessions]);
// 2. Fetch chats when active session changes. A session switch does not cancel the list still
// loading for the session left behind, so an answer for any session but the latest call's is
@@@ -807,33 -923,6 +937,72 @@@
[queryClient],
);
+ // The session switcher shows every session's state and lets only a ready one be picked, so both lists
+ // follow the live session feed the Sessions page uses (the '*' room, or one room per listed session for
+ // a session-scoped key) instead of the read at mount alone. The open session stays selectable when it
+ // drops, so the page does not switch away under the operator.
+ const listedSessionsRef = useRef(listedSessions);
+ useEffect(() => {
+ listedSessionsRef.current = listedSessions;
+ });
+ const sessionFeedRef = useRef(createSessionFeedState());
+ const [sessionFeedError, setSessionFeedError] = useState<string | null>(null);
- const handleSessionStatus = useCallback((event: { sessionId: string; status: string }) => {
- const status = event.status as Session['status'];
- const withStatus = (session: Session) => (session.id === event.sessionId ? { ...session, status } : session);
- setListedSessions(prev => prev.map(withStatus));
- setSessions(prev => {
- if (status === 'ready') {
- if (prev.some(session => session.id === event.sessionId)) return prev.map(withStatus);
- const listed = listedSessionsRef.current.find(session => session.id === event.sessionId);
- return listed ? [...prev, { ...listed, status }] : prev;
- }
- return prev
- .filter(session => session.id !== event.sessionId || session.id === selectedSessionRef.current)
- .map(withStatus);
- });
++ // A session created after the list was read reports a status the list has no row for. The list is read again,
++ // which brings its name and number along; a status that arrives while that read is out asks for one more after it,
++ // since the read may have been answered before the change.
++ const relistRef = useRef({ running: false, again: false });
++ const relistSessions = useCallback(async () => {
++ const relist = relistRef.current;
++ if (relist.running) {
++ relist.again = true;
++ return;
++ }
++ relist.running = true;
++ try {
++ do {
++ relist.again = false;
++ const list = await sessionApi.list();
++ setSessionsFailure(null);
++ setListedSessions(list);
++ // The open session stays in the switcher when it is down, as it does on a status event.
++ setSessions(list.filter(s => s.status === 'ready' || s.id === selectedSessionRef.current));
++ // With nothing selected (every session was down at load), the first ready session is opened.
++ const firstReady = list.find(s => s.status === 'ready');
++ if (firstReady) setSelectedSessionId(selected => selected || firstReady.id);
++ } while (relist.again);
++ } catch {
++ // The next status event, or a search hit in that session, reads the list again.
++ } finally {
++ relist.running = false;
++ }
+ }, []);
++ const handleSessionStatus = useCallback(
++ (event: { sessionId: string; status: string }) => {
++ if (!listedSessionsRef.current.some(session => session.id === event.sessionId)) {
++ void relistSessions();
++ return;
++ }
++ const status = event.status as Session['status'];
++ const withStatus = (session: Session) => (session.id === event.sessionId ? { ...session, status } : session);
++ setListedSessions(prev => prev.map(withStatus));
++ setSessions(prev => {
++ if (status === 'ready') {
++ if (prev.some(session => session.id === event.sessionId)) return prev.map(withStatus);
++ const listed = listedSessionsRef.current.find(session => session.id === event.sessionId);
++ return listed ? [...prev, { ...listed, status }] : prev;
++ }
++ return prev
++ .filter(session => session.id !== event.sessionId || session.id === selectedSessionRef.current)
++ .map(withStatus);
++ });
++ // loadSessions selects the first ready session; when every session was down at load nothing is selected, so
++ // the first one that connects is (the switcher would be blank and the list empty otherwise).
++ if (status === 'ready') setSelectedSessionId(selected => selected || event.sessionId);
++ },
++ [relistSessions],
++ );
+ const handleServerError = useCallback((frame: { code: string }) => setSessionFeedError(frame.code), []);
+
// The events object must be referentially stable: useWebSocket re-registers its socket handler
// on every identity change, so an inline literal would tear down and re-attach per render.
const wsEvents = useMemo(
@@@ -1210,10 -1264,10 +1389,12 @@@
// One search box drives all three tabs; each matches on its own fields. Plain consts (not useMemo)
// because chats/channelsQuery.data/statusesQuery.data are already stable, query-cached references,
// so re-filtering on every render is cheap. See utils/chatFilters for the two status orderings.
+ // The quick filter narrows the Chats tab further. Archived chats are their own view, as in WhatsApp,
+ // except while searching, which finds a chat wherever it is; pinned chats lead the main list.
// Whether a 1:1 chat's contact is saved comes from the address book (`isMyContact`), not from its
// display name: Baileys names an unsaved contact by its bare push name too. Undefined until it loads.
+ // Reading it walks every contact, and the engine answers each page from all of them, so it is read only when
+ // something needs it: the Unknown filter, or a chat menu (its Save or Rename entry, and the dialog behind it).
const contactsQuery = useQuery({
queryKey: ['contacts', selectedSessionId],
queryFn: () => contactApi.list(selectedSessionId),
@@@ -1394,16 -1490,15 +1617,20 @@@
.catch(failWith('chats.rowActions.blockFailed'));
};
+ const isSavedContact = (chat: Chat) => savedContactKeys?.has(contactKey(chat.id)) ?? false;
+
const rowActions: ChatRowActions = {
+ // Only what a key that can write offers reads the address book (Save or Rename); a read-only menu has no such entry.
+ onMenuOpen: canWrite ? () => setMenuOpenedFor(selectedSessionId) : undefined,
onGroupInfo: setGroupDialogChat,
+ onContactInfo: chat => {
+ setActiveTab('chats');
+ setActiveChat(chat);
- setShowContactInfo(true);
++ setContactInfoFor(readKey(selectedSessionId, chat.id));
+ },
onSaveContact: canWrite ? setContactDialogChat : undefined,
canSaveContact: chat => addressbookIdOf(chat) !== null,
- isSavedContact: chat => savedContactKeys?.has(contactKey(chat.id)) ?? false,
+ isSavedContact,
onTogglePin: canWrite ? chat => void handleTogglePin(chat) : undefined,
onMute: canWrite ? chat => (chat.muted ? void handleMute(chat, null) : setMuteDialogChat(chat)) : undefined,
onToggleArchive: canWrite ? chat => void handleToggleArchive(chat) : undefined,
@@@ -1465,15 -1564,18 +1696,17 @@@
}
};
+ // Closes the room menu from inside it, leaving focus on its button instead of the entry that unmounts.
+ const closeRoomMenu = () => {
+ setRoomMenuOpen(false);
+ roomMenuTriggerRef.current?.focus();
+ };
+
const handleCopyChatId = async () => {
if (!activeChat) return;
- setRoomMenuOpen(false);
- try {
- await navigator.clipboard.writeText(activeChat.id);
- showSuccessToast(t('chats.chatIdCopied'));
- } catch (err) {
- showErrorToast(t('chats.copyFailed'), err instanceof Error ? err.message : undefined);
- }
- closeRoomMenu();
+ // The house helper: over plain HTTP on a LAN address navigator.clipboard does not exist.
+ if (await copyToClipboard(activeChat.id)) showSuccessToast(t('chats.chatIdCopied'));
+ else showErrorToast(t('chats.copyFailed'));
};
// The overflow menu closes on a press outside it, on Escape, and with the chat it belongs to. Escape
@@@ -1534,7 -1636,6 +1767,7 @@@
if (document.querySelector('[role="dialog"], [role="menu"]')) return;
if (activeStatusContactId !== null) setActiveStatusContactId(null);
else if (activeChannel) setActiveChannel(null);
- else if (activeChat && showContactInfo) setShowContactInfo(false);
++ else if (activeChat && showContactInfo) setContactInfoFor('');
else if (activeChat) setActiveChat(null);
else if (showNewChat) setShowNewChat(false);
else return;
@@@ -1621,9 -1745,20 +1877,16 @@@
/>
) : null
}
- formatChatTime={formatChatTime}
chatsTab={{
- loading: loadingChats,
+ // Unknown is decided by the address book: until it loads the list would claim no chat matches, and
+ // when it cannot be read the list says so instead.
+ loading:
+ loadingChats ||
+ (chatFilter === 'unknown' && Boolean(selectedSessionId) && contactsQuery.isPending && !contactsFailed),
+ filterError: contactsFailed
+ ? { retrying: contactsQuery.isFetching, onRetry: () => void contactsQuery.refetch() }
+ : undefined,
chats: filteredChats,
- activeChatId: activeChat?.id,
- pictures: listPics.data,
- onSelectChat: setActiveChat,
filter: chatFilter,
onFilterChange: setChatFilter,
rowActions,
@@@ -1658,36 -1790,35 +1921,36 @@@
<button className="room-back" onClick={() => setActiveChat(null)} aria-label={t('common.back')}>
<ArrowLeft size={20} />
</button>
- <div className="room-avatar">
- {activePp.data ? (
- <img
- src={activePp.data}
- alt=""
- // Signed CDN URLs rotate every few hours; refetch the slice on a stale load.
- onError={() => activePp.refetch()}
- />
- ) : (
- <KindIcon kind={activeChat.kind} />
- )}
- </div>
- <div className="room-contact-info">
- <h3>{activeChat.name || activeChat.id.split('@')[0]}</h3>
- {/* Personal chats show the prettified phone number — local formatting for
- @c.us ids, engine-resolved for @lid privacy ids (which are NOT phones and
- must never be formatted as one). Groups fall back to a semantic label;
- the raw JID follows below for the technical case. */}
- <span className="room-contact-phone">
- {activePhoneText ??
- (activeChat.isGroup ? t('chats.groupSubtitle') : t('chats.privateContactSubtitle'))}
- </span>
- {/* Raw JID preserved for the technical case (the gateway speaks JIDs everywhere:
- webhooks, message rows, lid resolution). Monospace + muted so it doesn't compete
- with the human-facing name/number. */}
- <span className="room-contact-jid" title={activeChat.id}>
- {activeChat.id}
+ {/* The contact itself opens the info panel, as in WhatsApp. */}
+ <button
+ type="button"
+ className="room-contact"
- onClick={() => setShowContactInfo(open => !open)}
++ onClick={() => setContactInfoFor(showContactInfo ? '' : openRoomKey)}
+ title={t('chats.contactInfo')}
+ aria-expanded={showContactInfo}
+ >
+ <ChatAvatar
+ chatId={activeChat.id}
+ pictureUrl={activePp.data}
+ kind={activeChat.kind}
+ size="sm"
+ // Signed CDN URLs rotate every few hours; refetch the slice on a stale load.
+ onImageError={() => activePp.refetch()}
+ />
+ <span className="room-contact-info">
+ <span className="room-contact-name">{activeChatTitle}</span>
+ {/* Personal chats show the prettified phone number — local formatting for
+ @c.us ids, engine-resolved for @lid privacy ids (which are NOT phones and
+ must never be formatted as one). Only under a saved name: an unnamed chat's
+ title already is the number. The raw JID is in the contact panel. */}
+ {activePhoneText && activeChat.name && (
+ <span className="room-contact-phone">
+ <bdi dir="ltr">{activePhoneText}</bdi>
+ </span>
+ )}
</span>
- </div>
+ </button>
+
<div className="room-header-actions">
<div className="room-menu" ref={roomMenuRef}>
<button
@@@ -1704,10 -1839,16 +1971,22 @@@
keys, and the role would promise them. */}
{roomMenuOpen && (
<div className="room-menu-popover">
- {/* The row's actions, then what only an open room needs. */}
- <ChatActions chat={activeChat} actions={rowActions} onPicked={() => setRoomMenuOpen(false)} />
+ {/* The row's actions, then what only an open room needs. The chat comes from the list,
+ which opening it, a reload and the page's own actions keep current, not from the
+ snapshot taken when its row was clicked. */}
+ <ChatActions
+ chat={chats.find(c => c.id === activeChat.id) ?? activeChat}
+ actions={rowActions}
+ onPicked={closeRoomMenu}
+ />
<hr />
-- <button type="button" onClick={() => void handleCopyChatId()}>
++ <button
++ type="button"
++ onClick={() => {
++ closeRoomMenu();
++ void handleCopyChatId();
++ }}
++ >
<Copy size={16} />
{t('chats.copyChatId')}
</button>
@@@ -1718,16 -1859,6 +1997,16 @@@
</div>
)}
</div>
+ <button
+ type="button"
+ className={`icon-btn ${showContactInfo ? 'active' : ''}`}
- onClick={() => setShowContactInfo(open => !open)}
++ onClick={() => setContactInfoFor(showContactInfo ? '' : openRoomKey)}
+ title={t('chats.contactInfo')}
+ aria-label={t('chats.contactInfo')}
+ aria-pressed={showContactInfo}
+ >
+ <PanelRight size={22} />
+ </button>
</div>
</header>
@@@ -1871,69 -2002,7 +2150,73 @@@
<p>{t('chats.placeholderDesc')}</p>
</div>
)}
- </main>
+ </div>
+
+ {/* Contact panel beside the room, toggled from its header. */}
+ {activeChat && showContactInfo && (
+ <aside className="contact-info-panel" aria-label={t('chats.contactInfo')}>
+ <header className="contact-info-header">
+ <button
+ type="button"
+ className="icon-btn"
- onClick={() => setShowContactInfo(false)}
++ onClick={() => setContactInfoFor('')}
+ aria-label={t('common.close')}
+ title={t('common.close')}
+ >
+ <X size={20} />
+ </button>
+ <span>{t('chats.contactInfo')}</span>
+ </header>
+ <div className="contact-info-body">
+ <ChatAvatar
+ chatId={activeChat.id}
+ pictureUrl={activePp.data}
+ kind={activeChat.kind}
+ size="lg"
+ onImageError={() => activePp.refetch()}
+ />
+ <h3>{activeChatTitle}</h3>
+ <p className="contact-info-sub">
+ {activePhoneText ? (
+ <bdi dir="ltr">{activePhoneText}</bdi>
+ ) : activeChat.isGroup ? (
+ t('chats.groupSubtitle')
+ ) : (
+ t('chats.privateContactSubtitle')
+ )}
+ </p>
+ <dl className="contact-info-list">
+ {activePhoneText && (
+ <>
+ <dt>{t('chats.phone')}</dt>
+ <dd>
+ <bdi dir="ltr">{activePhoneText}</bdi>
+ </dd>
+ </>
+ )}
+ {/* Raw JID preserved for the technical case (the gateway speaks JIDs everywhere:
+ webhooks, message rows, lid resolution). */}
+ <dt>{t('chats.chatId')}</dt>
+ <dd className="mono">
- <span title={activeChat.id}>{activeChat.id}</span>
++ {/* Isolated left to right, as the room header once did: in an RTL page the bidi algorithm
++ would otherwise move "@c.us" to the other end of the id. */}
++ <bdi dir="ltr" title={activeChat.id}>
++ {activeChat.id}
++ </bdi>
+ <button
+ type="button"
+ className="icon-btn small"
+ onClick={() => void handleCopyChatId()}
+ title={t('chats.copyChatId')}
+ aria-label={t('chats.copyChatId')}
+ >
+ <Copy size={14} />
+ </button>
+ </dd>
+ </dl>
+ </div>
+ </aside>
+ )}
</div>
)}
diff --cc dashboard/src/select-chevron.test.ts
index 000000000,20ad84f1f..71188a64e
mode 000000,100644..100644
--- a/dashboard/src/select-chevron.test.ts
+++ b/dashboard/src/select-chevron.test.ts
@@@ -1,0 -1,87 +1,87 @@@
+ import { test } from 'node:test';
+ import assert from 'node:assert/strict';
+ import { readFileSync, readdirSync } from 'node:fs';
+ import { fileURLToPath } from 'node:url';
+ import { dirname, join } from 'node:path';
+ import ts from 'typescript';
+
+ // index.css turns the native arrow off (appearance: none) and draws a chevron as the select's
+ // background-image. A later rule that sets the `background` shorthand on a select resets that image to
+ // none, so the select renders as an empty box with no cue that it opens a list. Rules that only mean to
+ // set the fill colour have to use background-color.
+
+ const SRC = dirname(fileURLToPath(import.meta.url));
+
+ function filesUnder(dir: string, ext: string): string[] {
+ return readdirSync(dir, { withFileTypes: true }).flatMap(entry => {
+ const full = join(dir, entry.name);
+ if (entry.isDirectory()) return filesUnder(full, ext);
+ return entry.name.endsWith(ext) ? [full] : [];
+ });
+ }
+
+ // The class names carried by every <select> element in the app.
+ function selectClasses(): Set<string> {
+ const found = new Set<string>();
+ for (const full of filesUnder(SRC, '.tsx')) {
+ const source = ts.createSourceFile(
+ full,
+ readFileSync(full, 'utf8'),
+ ts.ScriptTarget.Latest,
+ true,
+ ts.ScriptKind.TSX,
+ );
+ const walk = (node: ts.Node): void => {
+ if ((ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) && node.tagName.getText() === 'select') {
+ for (const p of node.attributes.properties) {
+ if (
+ ts.isJsxAttribute(p) &&
+ p.name.getText() === 'className' &&
+ p.initializer &&
+ ts.isStringLiteral(p.initializer)
+ )
+ p.initializer.text.split(/\s+/).forEach(c => found.add(c));
+ }
+ }
+ ts.forEachChild(node, walk);
+ };
+ walk(source);
+ }
+ return found;
+ }
+
+ // Does the last compound selector (the element the rule styles) name `select` or a class a select carries?
+ function targetsSelect(selector: string, classes: Set<string>): boolean {
+ const compound =
+ selector
+ .trim()
+ .split(/[\s>+~]+/)
+ .pop() ?? '';
+ const head = compound.replace(/:[\w-]+(\([^)]*\))?/g, '');
+ if (/^select\b/.test(head) || /(?:^|[^\w-])select(?![\w-])/.test(head)) return true;
+ return [...head.matchAll(/\.([\w-]+)/g)].some(m => classes.has(m[1]));
+ }
+
+ test('no rule that styles a select sets the background shorthand', () => {
+ const classes = selectClasses();
- assert.ok(classes.has('session-selector'), 'the scan no longer finds the select classes');
++ assert.ok(classes.has('sessions-select'), 'the scan no longer finds the select classes');
+ const offenders: string[] = [];
+ for (const full of filesUnder(SRC, '.css')) {
+ const css = readFileSync(full, 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');
+ for (const m of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
+ const selectors = m[1].split(',').map(s => s.trim());
+ if (selectors.some(s => targetsSelect(s, classes)) && /(?:^|;)\s*background\s*:/.test(m[2]))
+ offenders.push(`${full.slice(SRC.length + 1)}: ${selectors.join(', ')}`);
+ }
+ }
+ assert.deepEqual(offenders, []);
+ });
+
+ test('the global select rule keeps the chevron room against a page rule that pads the select', () => {
+ const css = readFileSync(join(SRC, 'index.css'), 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');
+ const rule = /(?:^|})\s*select\s*\{([^}]*)\}/.exec(css);
+ assert.ok(rule, 'index.css has no select rule');
+ assert.match(rule[1], /background-image:\s*url\(/);
+ // The chevron sits in the end padding; a page rule with a padding shorthand would otherwise take it back.
+ assert.match(rule[1], /padding-inline-end:\s*2\.5rem\s*!important/);
+ });
diff --cc dashboard/src/theme-contrast.test.ts
index b396a9ce4,629357f83..04b451fbc
--- a/dashboard/src/theme-contrast.test.ts
+++ b/dashboard/src/theme-contrast.test.ts
@@@ -43,37 -43,312 +43,391 @@@ test('dark --error-text clears AA on ev
}
});
+// The chat page's own palette (pages/Chats.css): every text token against every surface it lands on, in the
+// light set and both dark sets. Light --chat-panel is the app's white card, so it resolves through App.css.
+const CHATS_CSS = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'pages', 'Chats.css'), 'utf8');
+const chatBlock = (anchor: string): string => {
+ const from = CHATS_CSS.indexOf(anchor);
+ assert.notEqual(from, -1, `Chats.css no longer contains "${anchor}"`);
+ return CHATS_CSS.slice(from, CHATS_CSS.indexOf('}', from));
+};
++// A dark set only lists what it changes (--chat-accent is one fill in every theme), so a token it leaves out is the
++// light one.
+const chatToken = (block: string, name: string): string =>
+ block.match(new RegExp(`${name}:\\s*var\\(--bg-white\\)`))
+ ? token(blockAfter(':root {'), '--bg-white')
- : token(block, name);
++ : new RegExp(`${name}:`).test(block)
++ ? token(block, name)
++ : chatToken(chatBlock('.chats-page {'), name);
+
+const CHAT_TEXT_ON: Array<[string, string[]]> = [
+ ['--chat-meta', ['--chat-panel', '--chat-hover', '--chat-active', '--chat-bubble-in']],
+ ['--chat-accent-text', ['--chat-panel', '--chat-hover', '--chat-active']],
+ ['--chat-meta-out', ['--chat-bubble-out']],
++ // The active filter pill and the group role chip, and the reply title on the composer banner.
++ ['--chat-pill-active-text', ['--chat-pill-active-bg', '--chat-panel-header']],
++ // Links in a message: the incoming blue is 4.07:1 on the light green and 3.74:1 on the dark one, so an outgoing
++ // bubble has its own.
++ ['--chat-link', ['--chat-bubble-in']],
++ ['--chat-link-out', ['--chat-bubble-out']],
+];
-
- for (const anchor of [
++const CHAT_ANCHORS = [
+ '.chats-page {',
+ "[data-theme='dark'] .chats-page {",
+ ":root:not([data-theme='light']) .chats-page {",
- ]) {
++];
++
++for (const anchor of CHAT_ANCHORS) {
+ test(`chat text clears AA on every surface it lands on (${anchor})`, () => {
+ const block = chatBlock(anchor);
+ for (const [text, surfaces] of CHAT_TEXT_ON) {
+ for (const surface of surfaces) {
+ const ratio = contrast(rgb(chatToken(block, text)), rgb(chatToken(block, surface)));
+ assert.ok(ratio >= 4.5, `${anchor} ${text} is ${ratio.toFixed(2)}:1 on ${surface}`);
+ }
+ }
+ });
+}
++
++const chatRule = (selector: string): string => {
++ const css = CHATS_CSS.replace(/\/\*[\s\S]*?\*\//g, '');
++ for (const m of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
++ if (m[1].split(',').some(s => s.trim() === selector)) return m[2];
++ }
++ assert.fail(`Chats.css has no ${selector} rule`);
++};
++
++test('the outgoing bubble draws its links in their own token', () => {
++ assert.match(chatRule('.chats-page .message-bubble.outgoing .message-text a'), /color:\s*var\(--chat-link-out\)/);
++});
++
++// The pill green is also drawn on tints the rules mix from two tokens: the prompt buttons in an incoming bubble (the
++// dark button measured 4.22:1 in the old green) with their hover and chosen states, and the admin badge in the group
++// dialog. Each fill is read from its rule, so a stronger tint has to keep the text readable too.
++const PILL_TEXT_FILLS = [
++ '.chats-page .chat-filter-pill.active',
++ '.chats-page .group-info-role',
++ '.chats-page .group-info-badge.admin',
++ '.chats-page .message-prompt-button',
++ '.chats-page .message-prompt-button:hover:not(:disabled)',
++ '.chats-page .message-prompt-button.selected',
++];
++
++for (const anchor of CHAT_ANCHORS) {
++ test(`the pill green clears AA on every fill it is drawn on (${anchor})`, () => {
++ const block = chatBlock(anchor);
++ const text = rgb(chatToken(block, '--chat-pill-active-text'));
++ for (const selector of PILL_TEXT_FILLS) {
++ const fill = /(?:^|;)\s*background:\s*([^;]+)/.exec(chatRule(selector))?.[1].trim();
++ assert.ok(fill, `${selector} paints no background`);
++ const plain = /^var\((--[\w-]+)\)$/.exec(fill);
++ const mixed = /^color-mix\(in srgb, var\((--[\w-]+)\) (\d+)%, var\((--[\w-]+)\)\)$/.exec(fill);
++ assert.ok(plain || mixed, `${selector} paints ${fill}, which this test cannot resolve`);
++ const surface = plain
++ ? rgb(chatToken(block, plain[1]))
++ : rgb(chatToken(block, mixed![1])).map(
++ (c, i) =>
++ c * (Number(mixed![2]) / 100) + rgb(chatToken(block, mixed![3]))[i] * (1 - Number(mixed![2]) / 100),
++ );
++ const ratio = contrast(text, surface);
++ assert.ok(ratio >= 4.5, `${anchor} --chat-pill-active-text is ${ratio.toFixed(2)}:1 on ${selector}`);
++ }
++ });
++}
++
+ // The pairs below are the ones the stylesheets build from these tokens and from two literal bubble greens.
+ const PAGES = join(dirname(fileURLToPath(import.meta.url)), 'pages');
+ const read = (file: string): string => readFileSync(join(PAGES, file), 'utf8');
+ const LIGHT = ':root {';
+ const DARK = "[data-theme='dark'] {";
+ // A visitor on a dark OS with no stored theme has no data-theme at all (every first visit, and the signed-out
+ // Login page): they get this block, not DARK, so every dark ratio is checked against both.
+ const DARK_MEDIA = ":root:not([data-theme='light']) {";
+ const DARKS = [DARK, DARK_MEDIA];
+ const valueOf = (block: string, name: string): string => {
+ const raw = block.match(new RegExp(`${name}:\\s*([^;]+);`))?.[1].trim();
+ assert.ok(raw, `${name} is not set in the block`);
+ const alias = /^var\((--[\w-]+)\)$/.exec(raw);
+ return alias ? valueOf(blockAfter(LIGHT), alias[1]) : raw;
+ };
+ const hexOf = (block: string, name: string): string => {
+ const value = valueOf(block, name);
+ assert.match(value, /^#[0-9a-f]{6}$/i, `${name} is ${value}`);
+ return value;
+ };
+ const mix = (over: number[], alpha: number, under: number[]): number[] =>
+ over.map((c, i) => c * alpha + under[i] * (1 - alpha));
+
+ test('--text-muted placeholders clear AA on every input surface in both themes', () => {
+ assert.match(
+ CSS,
+ /input::placeholder,\s*textarea::placeholder\s*\{[^}]*color:\s*var\(--text-muted\)[^}]*opacity:\s*1/,
+ );
+ for (const anchor of [LIGHT, ...DARKS]) {
+ const block = blockAfter(anchor);
+ const text = rgb(hexOf(block, '--text-muted'));
+ for (const surface of ['--bg-white', '--bg-light']) {
+ const ratio = contrast(text, rgb(hexOf(block, surface)));
+ assert.ok(ratio >= 4.5, `${anchor} --text-muted on ${surface} is ${ratio.toFixed(2)}:1`);
+ }
+ }
+ });
+
-test('time stamps and read ticks on the outgoing bubble clear their ratios in both themes', () => {
- const chats = read('Chats.css');
- const light = rgb(/\.chats-page \.message-bubble\.outgoing \{\s*background:\s*(#[0-9a-f]{6})/i.exec(chats)![1]);
- assert.match(chats, /\.message-bubble\.outgoing \.message-time\s*\{\s*color:\s*var\(--text-secondary\)/);
- const secondaryLight = contrast(rgb(hexOf(blockAfter(LIGHT), '--text-secondary')), light);
- assert.ok(secondaryLight >= 4.5, `light time stamp ${secondaryLight.toFixed(2)}:1`);
- const lightTick = /\.chats-page \.message-status-icon\.read\s*\{[^}]*?color:\s*(#[0-9a-f]{6})/i.exec(chats);
- assert.ok(lightTick, 'Chats.css has no light read tick colour');
- const tickLight = contrast(rgb(lightTick[1]), light);
- assert.ok(tickLight >= 4.5, `light read tick ${tickLight.toFixed(2)}:1`);
- // The dark bubble and its read tick are written twice: once under [data-theme='dark'], once for the system theme.
- const escape = (text: string): string => text.replace(/[[\]().]/g, '\\$&');
- for (const [anchor, prefix] of [
- [DARK, "[data-theme='dark'] "],
- [DARK_MEDIA, ":root:not([data-theme='light']) "],
- ]) {
- const bubble = new RegExp(
- `${escape(prefix)}\\.chats-page \\.message-bubble\\.outgoing \\{\\s*background:\\s*(#[0-9a-f]{6})`,
- 'i',
- ).exec(chats);
- assert.ok(bubble, `Chats.css has no outgoing bubble rule under ${prefix}`);
- assert.match(
- chats,
- new RegExp(
- `${escape(prefix)}\\.chats-page \\.message-status-icon\\.read\\s*\\{\\s*color:\\s*var\\(--read-tick\\)`,
- ),
- `Chats.css has no read tick rule under ${prefix}`,
- );
- const dark = rgb(bubble[1]);
- const secondary = contrast(rgb(hexOf(blockAfter(anchor), '--text-secondary')), dark);
- assert.ok(secondary >= 4.5, `${anchor} time stamp ${secondary.toFixed(2)}:1`);
- const tick = contrast(rgb(hexOf(blockAfter(anchor), '--read-tick')), dark);
- assert.ok(tick >= 4.5, `${anchor} read tick ${tick.toFixed(2)}:1 (the glyph is held to the 4.5:1 of text)`);
++// The chat page paints its bubbles from its own palette (--chat-bubble-out), in the light set and both dark sets. The
++// time is text and holds 4.5:1; the delivery ticks are drawn as icons (lucide's Check and CheckCheck in ChatThread),
++// so they hold the 3:1 of a graphic, and delivered and read also differ in aria-label and title.
++test('time stamps and read ticks on the outgoing bubble clear their ratios in every theme', () => {
++ assert.match(chatRule('.chats-page .message-bubble.outgoing .message-time'), /color:\s*var\(--chat-meta-out\)/);
++ assert.match(chatRule('.chats-page .message-status-icon.read'), /color:\s*var\(--chat-tick-read\)/);
++ assert.match(chatRule('.chats-page .message-status-icon'), /color:\s*var\(--chat-meta\)/);
++ const thread = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'components/chats/ChatThread.tsx'), 'utf8');
++ assert.match(thread, /read:\s*<CheckCheck\b/, 'the read tick is no longer an icon, so it needs 4.5:1');
++ for (const anchor of CHAT_ANCHORS) {
++ const block = chatBlock(anchor);
++ const bubble = rgb(chatToken(block, '--chat-bubble-out'));
++ const time = contrast(rgb(chatToken(block, '--chat-meta-out')), bubble);
++ assert.ok(time >= 4.5, `${anchor} time stamp ${time.toFixed(2)}:1`);
++ for (const tick of ['--chat-tick-read', '--chat-meta']) {
++ const ratio = contrast(rgb(chatToken(block, tick)), bubble);
++ assert.ok(ratio >= 3, `${anchor} ${tick} tick ${ratio.toFixed(2)}:1`);
++ }
+ }
+ });
+
+ test('the action required pill clears 4.5:1 on its tint in the dark theme, with one tint on both pages', () => {
+ const tints = [
+ ['Sessions.css', '.sessions-page .status-pill.action_required'],
+ ['Dashboard.css', '.dashboard .status-pill.action_required'],
+ ].map(([file, selector]) => {
+ const rule = new RegExp(
+ `${selector.replace(/[.]/g, '\\.')}[^{]*\\{[^}]*background:\\s*rgba\\(245,\\s*158,\\s*11,\\s*([\\d.]+)\\)`,
+ ).exec(read(file));
+ assert.ok(rule, `${file} has no amber tint for ${selector}`);
+ return Number(rule[1]);
+ });
+ assert.equal(tints[0], tints[1], 'the same status is tinted differently on the two pages');
+ // The tint is the base amber (--warning) over the card; the text is --warning-text, which keeps the base value in dark.
+ for (const anchor of DARKS) {
+ const block = blockAfter(anchor);
+ const tint = mix(rgb(hexOf(blockAfter(LIGHT), '--warning')), tints[0], rgb(hexOf(block, '--bg-white')));
+ const ratio = contrast(rgb(hexOf(block, '--warning-text')), tint);
+ assert.ok(ratio >= 4.5, `${anchor} amber text on a ${tints[0]} tint is ${ratio.toFixed(2)}:1`);
+ }
+ });
+
+ // The detail modal repeats the status as a badge beside its own "Status" label, on the 10 percent tint every other
+ // status badge has (--warning-text is 5.02:1 on it over white) rather than the card pill's 22 percent (4.57:1).
+ test('the action required badge in the session details clears 4.5:1 on its tint in every theme', () => {
+ const rule =
+ /\.sessions-page \.status-badge\.action_required\s*\{[^}]*background:\s*rgba\(245,\s*158,\s*11,\s*([\d.]+)\)/.exec(
+ read('Sessions.css'),
+ );
+ assert.ok(rule, 'Sessions.css has no amber tint for the action required badge');
+ for (const anchor of [LIGHT, ...DARKS]) {
+ const block = blockAfter(anchor);
+ for (const surface of ['--bg-white', '--bg-light']) {
+ const tint = mix(rgb(hexOf(blockAfter(LIGHT), '--warning')), Number(rule[1]), rgb(hexOf(block, surface)));
+ const ratio = contrast(rgb(hexOf(block, '--warning-text')), tint);
+ assert.ok(ratio >= 4.5, `${anchor} badge text on ${rule[1]} over ${surface} is ${ratio.toFixed(2)}:1`);
+ }
+ }
+ });
+
+ // A status badge, pill or hover state paints a translucent tint of its own hue behind a text twin. The twins have to hold
+ // on the heaviest tint any rule paints over white (error 15 percent, success 18, warning 22), not only on the 10
+ // percent one: a rule with a heavier tint needs a darker twin, or a lighter tint.
+ const cssFiles = (dir: string): string[] =>
+ readdirSync(dir, { withFileTypes: true }).flatMap(entry => {
+ const full = join(dir, entry.name);
+ if (entry.isDirectory()) return cssFiles(full);
+ return entry.name.endsWith('.css') ? [full] : [];
+ });
+
+ test('every status text twin clears 4.5:1 on the translucent fill its own rule paints over white', () => {
+ const root = dirname(fileURLToPath(import.meta.url));
+ const light = blockAfter(LIGHT);
+ const white = rgb(hexOf(light, '--bg-white'));
+ let checked = 0;
+ const offenders: string[] = [];
+ for (const file of cssFiles(root)) {
+ const css = readFileSync(file, 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');
+ for (const rule of css.matchAll(/([^{}]+)\{([^{}]*)\}/g)) {
+ const color = /(?:^|;)\s*color:\s*var\((--(?:error|success|warning|primary)-text)\)/.exec(rule[2]);
+ const fill = /(?:^|;)\s*background(?:-color)?:\s*rgba\(\s*(\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)/.exec(rule[2]);
+ if (!color || !fill) continue;
+ checked++;
+ const tint = mix([Number(fill[1]), Number(fill[2]), Number(fill[3])], Number(fill[4]), white);
+ const ratio = contrast(rgb(hexOf(light, color[1])), tint);
+ if (ratio < 4.5) {
+ offenders.push(
+ `${file.slice(root.length + 1)}: ${rule[1].trim()} ${color[1]} ${ratio.toFixed(2)}:1 on ${fill[4]}`,
+ );
+ }
+ }
+ }
+ assert.ok(checked > 40, `the scan saw ${checked} rules`);
+ assert.deepEqual(offenders, []);
+ });
+
+ // A badge inside a tinted card sits on both tints: the Not Registered badge paints 15 percent red over the 4 percent red
+ // of its result card, which leaves --error-text at 4.38:1 where the pair over plain white measured 4.57:1.
+ test('the Not Registered badge clears 4.5:1 on its tint over the tint of its result card', () => {
+ const css = read('NumberChecker.css').replace(/\/\*[\s\S]*?\*\//g, '');
+ const alphaOf = (selector: string): number => {
+ const rule = new RegExp(
+ `${selector.replace(/[.]/g, '\\.')}\\s*\\{[^}]*background:\\s*rgba\\(239,\\s*68,\\s*68,\\s*([\\d.]+)\\)`,
+ ).exec(css);
+ assert.ok(rule, `NumberChecker.css has no red tint for ${selector}`);
+ return Number(rule[1]);
+ };
+ const badge = alphaOf('.number-checker .nc-status-badge.unregistered');
+ const card = alphaOf('.number-checker .nc-result-card.not-found');
+ const light = blockAfter(LIGHT);
+ const red = rgb(hexOf(light, '--error'));
+ // The result card sits in .nc-card, which is --bg-white.
+ const tint = mix(red, badge, mix(red, card, rgb(hexOf(light, '--bg-white'))));
+ const ratio = contrast(rgb(hexOf(light, '--error-text')), tint);
+ assert.ok(ratio >= 4.5, `--error-text on the badge over the card is ${ratio.toFixed(2)}:1`);
+ });
+
+ // WCAG 2.2 SC 1.4.11 asks 3:1 of a keyboard focus indicator against what it is drawn on: the page and card surfaces
+ // and the soft brand tint of a focused menu entry or search hit. The brand fill measured 1.98:1 on white.
+ test('the focus ring clears 3:1 on every surface it is drawn on, in both themes', () => {
+ assert.match(CSS, /--focus-ring:\s*var\(--primary-text\)/);
+ for (const [anchor, tint] of [
+ [LIGHT, 0.12],
+ [DARK, 0.18],
+ [DARK_MEDIA, 0.18],
+ ] as const) {
+ const block = blockAfter(anchor);
+ const ring = rgb(hexOf(block, '--primary-text'));
+ for (const surface of ['--bg-white', '--bg-light']) {
+ const bg = rgb(hexOf(block, surface));
+ const soft = mix(rgb(hexOf(blockAfter(LIGHT), '--primary')), tint, bg);
+ for (const [name, fill] of [
+ ['the surface', bg],
+ ['the soft tint over it', soft],
+ ] as const) {
+ const ratio = contrast(ring, fill);
+ assert.ok(ratio >= 3, `${anchor} ring on ${name} of ${surface} is ${ratio.toFixed(2)}:1`);
+ }
+ }
+ }
+ });
+
+ // The enabled badge of a plugin instance paints --primary-soft, so its text is the brand green twin: --success-text is
+ // a different green, and on the 18 percent tint of the dark theme it measured 4.48:1.
+ test('the enabled badge of a plugin instance clears 4.5:1 on its tint in every theme', () => {
+ const css = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'components/PluginInstances.css'), 'utf8');
+ const rule =
+ /\.plugin-instances \.pi-badge\.on\s*\{[^}]*background:\s*var\(--primary-soft\);[^}]*color:\s*var\((--[\w-]+)\)/.exec(
+ css,
+ );
+ assert.ok(rule, 'PluginInstances.css no longer paints the enabled badge on --primary-soft');
+ for (const [anchor, alpha] of [
+ [LIGHT, 0.12],
+ [DARK, 0.18],
+ [DARK_MEDIA, 0.18],
+ ] as const) {
+ const block = blockAfter(anchor);
+ for (const surface of ['--bg-white', '--bg-light']) {
+ const tint = mix(rgb(hexOf(blockAfter(LIGHT), '--primary')), alpha, rgb(hexOf(block, surface)));
+ const ratio = contrast(rgb(hexOf(block, rule[1])), tint);
+ assert.ok(ratio >= 4.5, `${anchor} ${rule[1]} on the badge over ${surface} is ${ratio.toFixed(2)}:1`);
+ }
+ }
+ });
+
+ test('the search match and the Number Checker highlight pill clear AA in both themes', () => {
+ const search = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'components/GlobalSearch.css'), 'utf8');
+ const mark =
+ /\.global-search-hit-snippet mark\s*\{[^}]*background:\s*var\((--[\w-]+)\);[^}]*?color:\s*(#[0-9a-f]{6})/i.exec(
+ search,
+ );
+ assert.ok(mark, 'GlobalSearch.css no longer styles the match with a hex colour on a token fill');
+ const pill =
+ /\.nc-format-pill\.highlight\s*\{[^}]*background:\s*rgba\(37,\s*211,\s*102,\s*([\d.]+)\)[^}]*?color:\s*var\((--[\w-]+)\)/.exec(
+ read('NumberChecker.css'),
+ );
+ assert.ok(pill, 'NumberChecker.css no longer styles the highlight pill with a token colour');
+ for (const anchor of [LIGHT, ...DARKS]) {
+ const block = blockAfter(anchor);
+ // The amber fill is the same in both themes, so the dark text on it must hold in both.
+ const onAmber = contrast(rgb(mark[2]), rgb(hexOf(blockAfter(LIGHT), mark[1])));
+ assert.ok(onAmber >= 4.5, `${anchor} match text on the amber is ${onAmber.toFixed(2)}:1`);
+ const tint = mix(rgb(hexOf(blockAfter(LIGHT), '--primary')), Number(pill[1]), rgb(hexOf(block, '--bg-white')));
+ const onTint = contrast(rgb(hexOf(block, pill[2])), tint);
+ assert.ok(onTint >= 4.5, `${anchor} pill text on the green tint is ${onTint.toFixed(2)}:1`);
+ }
+ });
+
+ // Opacity over --text-muted is a second fade on a colour that already sits at 4.5:1: at 0.7 it is 2.72:1.
+ test('text that uses --text-muted is not faded again with opacity', () => {
+ const components = join(dirname(fileURLToPath(import.meta.url)), 'components');
+ const sources: [string, string, string][] = [
+ ['Layout.css', readFileSync(join(components, 'Layout.css'), 'utf8'), '.brand-version'],
- ['Chats.css', read('Chats.css'), '.chats-page .room-contact-jid'],
++ // The raw chat id, faded in the old room header, is in the contact panel now.
++ ['Chats.css', read('Chats.css'), '.chats-page .contact-info-list dd.mono bdi'],
+ ['Chats.css', read('Chats.css'), '.chats-page .chat-item-snippet .no-message'],
+ ['Infrastructure.css', read('Infrastructure.css'), '.infrastructure-page .form-group small'],
+ ['Infrastructure.css', read('Infrastructure.css'), '.infrastructure-page .toggle-info small'],
+ ];
+ for (const [file, css, selector] of sources) {
+ const rule = new RegExp(`(?:^|})\\s*${selector.replace(/[.]/g, '\\.')}\\s*\\{([^}]*)\\}`).exec(
+ css.replace(/\/\*[\s\S]*?\*\//g, ''),
+ );
+ assert.ok(rule, `${file} has no ${selector} rule`);
+ assert.doesNotMatch(rule[1], /opacity:/, `${file} ${selector} fades its text`);
+ }
+ });
+
+ test('muted text on a tinted row uses --text-secondary, which clears AA on the tint in both themes', () => {
++ // The chat list rows are no tint: the active one is the opaque --chat-active, on which the chat text tests above
++ // check the time and the preview (--chat-meta) in every theme.
++ assert.match(chatRule('.chats-page .chat-item-card.active'), /background:\s*var\(--chat-active\)/);
+ // [stylesheet, selector, tint alpha in light, tint alpha in dark, surface under the tint]
+ const rules: [string, string, number, number, string][] = [
- ['Chats.css', '.chats-page .chat-item-card.active .chat-item-time', 0.08, 0.08, '--bg-white'],
- ['Chats.css', '.chats-page .chat-item-card.active .chat-item-snippet', 0.08, 0.08, '--bg-white'],
+ // The selected template row is --primary-soft: 12 percent in light, 18 percent in dark.
+ ['Templates.css', '.templates-page .template-list-item.selected .template-list-meta', 0.12, 0.18, '--bg-light'],
+ // The focused search hit is --primary-soft over the results panel, which is --bg-white.
+ [
+ '../components/GlobalSearch.css',
+ '.global-search-hit:focus-visible .global-search-hit-meta',
+ 0.12,
+ 0.18,
+ '--bg-white',
+ ],
+ ];
+ for (const [file, selector, light, dark, surface] of rules) {
+ const rule = new RegExp(`${selector.replace(/[.]/g, '\\.')}[^{]*\\{[^}]*color:\\s*var\\((--[\\w-]+)\\)`).exec(
+ read(file),
+ );
+ assert.ok(rule, `${file} has no colour for ${selector}`);
+ assert.equal(rule[1], '--text-secondary', `${file} ${selector}`);
+ for (const [anchor, alpha] of [
+ [LIGHT, light],
+ [DARK, dark],
+ [DARK_MEDIA, dark],
+ ] as const) {
+ const block = blockAfter(anchor);
+ const tint = mix(rgb(hexOf(blockAfter(LIGHT), '--primary')), alpha, rgb(hexOf(block, surface)));
+ const ratio = contrast(rgb(hexOf(block, '--text-secondary')), tint);
+ assert.ok(ratio >= 4.5, `${anchor} ${selector} is ${ratio.toFixed(2)}:1`);
+ }
+ }
+ });
+
+ test('the batch badge uses --info, which clears the twins range on its tint in both themes', () => {
+ const rule = /\.batch-badge\.pending,\s*\.message-tester \.batch-badge\.processing\s*\{[^}]*color:\s*([^;]+);/.exec(
+ read('MessageTester.css'),
+ );
+ assert.ok(rule, 'MessageTester.css no longer styles the pending badge');
+ assert.equal(rule[1].trim(), 'var(--info)');
+ for (const anchor of [LIGHT, ...DARKS]) {
+ const block = blockAfter(anchor);
+ // The batch panel is --bg-light; the badge paints 12 percent of the blue over it.
+ const tint = mix([59, 130, 246], 0.12, rgb(hexOf(block, '--bg-light')));
+ const ratio = contrast(rgb(hexOf(block, '--info')), tint);
+ assert.ok(ratio >= 4.29, `${anchor} --info on the batch badge is ${ratio.toFixed(2)}:1 (the raw blue was 3.08:1)`);
+ }
+ });
diff --cc docs/17-dashboard-design.md
index 6bdd740eb,16b27294c..5546061f2
--- a/docs/17-dashboard-design.md
+++ b/docs/17-dashboard-design.md
@@@ -108,13 -109,13 +109,14 @@@ mounted for any admin key
```
/ → Dashboard (overview + charts)
/sessions → Sessions (create / start / stop / QR / delete)
-/chats → Chats (Chats / Channels / Status tabs, quick filters and an Archived view on
- Chats; chat list + message thread live via WebSocket; thread pages older
- history in on scroll-up; per-chat menu (pin, mute, archive, mark unread,
- block, leave group; clear and delete on whatsapp-web.js only) [operator];
- group info dialog; new chat / new group [operator]; read-only channel feed
- on whatsapp-web.js)
+/chats → Chats (full height, no page header; session switcher listing every session;
+ Chats / Channels / Status tabs, quick filters and an Archived view on Chats;
+ chat list + message thread live via WebSocket; thread pages older history in
+ on scroll-up; per-chat menu (pin, mute, archive, mark unread, block, leave
+ group; clear and delete on whatsapp-web.js only) [operator]; contact info
+ panel and group info dialog; new chat / new group [operator]; read-only
+ channel feed on whatsapp-web.js)
+ /number-checker → Number Checker (single and bulk check of whether numbers are on WhatsApp) [operator]
/webhooks → Webhooks (per-session webhook endpoints)
/templates → Message Templates
/message-tester → Message Tester (ad-hoc send-* + check-number)
@@@ -392,45 -391,45 +394,46 @@@
### Bespoke components
The UI is built from a small set of project-specific components under `dashboard/src/components/`,
- most with a colocated CSS file. Six top-level components ship none: `ErrorBoundary` styles inline
+ most with a colocated CSS file. Seven top-level components ship none: `ErrorBoundary` styles inline
via `style={{...}}`, `GithubIcon` carries no styling beyond `fill="currentColor"`, `Modal` reuses the
global `.modal-*` rules from `index.css`, `GroupPicker` and `SessionScopePicker` are styled by the
- one page that uses each (`pages/MessageTester.css`, `pages/ApiKeys.css`), and `RoleProvider` renders
- no DOM. Nothing under `chats/` ships its own stylesheet either: those components take their classes
- from `pages/Chats.css`, and `MediaLightbox` adds the `yet-another-react-lightbox` vendor CSS. There
- is no design-system package to pull from.
-
- | Component | File | Responsibility |
- | ---------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
- | `Layout` | `components/Layout.tsx` | App shell: collapsible sidebar nav, mobile drawer, language menu, light/dark/system theme toggle, logout, live version badge |
- | `ToastProvider` / `useToast` | `components/Toast.tsx` | Context-based toast notifications (success/error/warning/info) with de-dup keys |
- | `PageHeader` | `components/PageHeader.tsx` | Shared page title / subtitle / badge / actions header |
- | `Modal` | `components/Modal.tsx` | Accessible dialog (`role="dialog"`, Escape/overlay close, focus trap + restore); uses the global `.modal-*` styles |
- | `CustomSelect` | `components/CustomSelect.tsx` | Keyboard-navigable select replacement (type-ahead, arrow keys) used by Sessions / Logs / Login |
- | `DashboardCharts` | `components/DashboardCharts.tsx` | `recharts`-based message-volume / activity charts on the Dashboard |
- | `FilterBuilder` | `components/FilterBuilder.tsx` | Visual condition builder for webhook event filters |
- | `GlobalSearch` | `components/GlobalSearch.tsx` | Debounced message search behind a toggle in the Chats sidebar header, with all-sessions / current-session scope |
- | `PluginInstances` | `components/PluginInstances.tsx` | Per-plugin instance list: create / edit / delete and secret regeneration |
- | `ErrorBoundary` | `components/ErrorBoundary.tsx` | Top-level React error boundary wrapping the whole app |
- | `GithubIcon` | `components/GithubIcon.tsx` | Inline brand SVG |
- | `GroupPicker` | `components/GroupPicker.tsx` | Searchable multi-select of a session's groups, used by the Message Tester's multi-group send |
- | `SessionScopePicker` | `components/SessionScopePicker.tsx` | Per-key session scope checklist on the API Keys page |
- | `RoleProvider` | `components/RoleProvider.tsx` | Context holding the logged-in key's role, read with `useRole` (`canWrite` gates write actions) |
+ one page that uses each (`pages/MessageTester.css`, `pages/ApiKeys.css`), and `RoleProvider` and
+ `NumberCheckProvider` render no DOM. Nothing under `chats/` ships its own stylesheet either: those
+ components take their classes from `pages/Chats.css`, and `MediaLightbox` adds the
+ `yet-another-react-lightbox` vendor CSS. There is no design-system package to pull from.
+
+ | Component | File | Responsibility |
+ | ---------------------------- | ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
+ | `Layout` | `components/Layout.tsx` | App shell: collapsible sidebar nav, mobile drawer, language menu, light/dark/system theme toggle, logout, live version badge |
+ | `ToastProvider` / `useToast` | `components/Toast.tsx` | Context-based toast notifications (success/error/warning/info) with de-dup keys |
+ | `PageHeader` | `components/PageHeader.tsx` | Shared page title / subtitle / badge / actions header |
+ | `Modal` | `components/Modal.tsx` | Accessible dialog (`role="dialog"`, Escape/overlay close, focus trap + restore); uses the global `.modal-*` styles |
+ | `CustomSelect` | `components/CustomSelect.tsx` | Keyboard-navigable select replacement (type-ahead, arrow keys) used by Sessions / Logs / Login |
+ | `DashboardCharts` | `components/DashboardCharts.tsx` | `recharts`-based message-volume / activity charts on the Dashboard |
+ | `FilterBuilder` | `components/FilterBuilder.tsx` | Visual condition builder for webhook event filters |
-| `GlobalSearch` | `components/GlobalSearch.tsx` | Debounced message-search box in the Chats header, with all-sessions / current-session scope |
++| `GlobalSearch` | `components/GlobalSearch.tsx` | Debounced message search behind a toggle in the Chats sidebar header, with all-sessions / current-session scope |
+ | `PluginInstances` | `components/PluginInstances.tsx` | Per-plugin instance list: create / edit / delete and secret regeneration |
+ | `ErrorBoundary` | `components/ErrorBoundary.tsx` | Top-level React error boundary wrapping the whole app |
+ | `GithubIcon` | `components/GithubIcon.tsx` | Inline brand SVG |
+ | `GroupPicker` | `components/GroupPicker.tsx` | Searchable multi-select of a session's groups, used by the Message Tester's multi-group send |
+ | `SessionScopePicker` | `components/SessionScopePicker.tsx` | Per-key session scope checklist on the API Keys page |
+ | `RoleProvider` | `components/RoleProvider.tsx` | Context holding the logged-in key's role, read with `useRole` (`canWrite` gates write actions) |
+ | `NumberCheckProvider` | `components/NumberCheckProvider.tsx` | Holds the Number Checker's bulk run and its rows above the routes, so leaving the page does not stop a run; read with `useNumberCheck` |
Chat-specific pieces live one level down in `components/chats/`: `MessageBody` (WhatsApp text
-formatting + link detection), `ChatThread` (bubble list, including inbound Baileys prompt buttons
-that call `POST /sessions/:id/messages/click-button`), and `MediaLightbox` (the media viewer, built
-on `yet-another-react-lightbox`). The rest of the room is split the same way: `ChatSidebar`,
-`NewChatPanel` (new chat, and new group on Baileys), `ChatRowMenu` (a chat row's actions;
-`chatActionItems` lists them for the row and for the room's menu alike), `GroupInfoDialog` (a group's
-name, picture, description and participants), `ChatDialogs` (mute and save-contact dialogs),
-`ChatComposer`, `ChatAvatar`, `KindIcon`, `StatusComposeModal` and `StatusMedia`. Prompt choices
-arrive on live `message.received` as top-level `buttons` and are also stored in message
-`metadata.buttons` so a reload can re-render them. Clicking still requires the prompt to be in the
-engine store; an evicted prompt 404s. A read-only key sees the choices disabled and gets no reply,
-react or delete actions, the same as the disabled composer, no New chat button, and of a chat's
-actions only a group's info.
+formatting + link detection), `ChatThread` (bubble list with day separators, including inbound
+Baileys prompt buttons that call `POST /sessions/:id/messages/click-button`), and `MediaLightbox`
+(the media viewer, built on `yet-another-react-lightbox`). The rest of the room is split the same
+way: `ChatSidebar`, `SessionPicker` (the session switcher in the sidebar header), `NewChatPanel`
+(new chat, and new group on Baileys), `ChatRowMenu` (a chat row's actions; `chatActionItems` lists
+them for the row and for the room's menu alike), `GroupInfoDialog` (a group's name, picture,
+description and participants), `ChatDialogs` (mute and save-contact dialogs), `ChatComposer`,
+`ChatAvatar`, `KindIcon`, `StatusComposeModal` and `StatusMedia`. Prompt choices arrive on live
+`message.received` as top-level `buttons` and are also stored in message `metadata.buttons` so a
+reload can re-render them. Clicking still requires the prompt to be in the engine store; an evicted
+prompt 404s. A read-only key sees the choices disabled and gets no reply, react or delete actions,
+the same as the disabled composer, no message search, no New chat button, and of a chat's actions
+only its contact or group info.
The message thread is paged. `useChatMessages` is a `useInfiniteQuery` whose cursor is the number
of DB rows fetched so far, not the length of the rendered list — the thread also carries engine