waybetter-for-x/apps/desktop/src/areas/chat/features.ts
CRT 6d1798038c Chat+ link previews: a link in a chat shows its page's title, text and picture, YouTube playable in place
X's web chat shows a link as a bare card. An X tab on a chat page may now ask native code
(link_preview, x-capture only, chat pages only) for one link's preview. Native code fetches it:
https and public hosts only (addresses checked and pinned), never X's hosts, no cookies or
referrer, redirects re-checked, page head <= 512 KB, images <= 1.5 MB by magic bytes as data:,
30 fetches a minute, memory-only cache. Only the link leaves the page. On by default (owner,
2026-10-10).
2026-10-10 21:47:31 +08:00

31 lines
2.5 KiB
TypeScript

// Chat+: its rows of the feature table (docs/AREA-PLUGINS.md). `FEATURES` is what its card lists;
// `POWER` are the flags Power User turns on besides the defaults. A flag id never changes once it
// shipped. New words go to ./messages.en.json; modules to ./index.ts.
//
// X's chat is a heavy page: every row says `heavy`, so it runs there (nothing else of the app does).
import type { FeatureSpec } from '../../../../../waybetter/packages/runtime/src/featureTable.ts';
import { modules } from '../rows.ts';
const CHAT = ['chat'];
/** The words of a feature's row on the card (./messages.en.json). */
const words = (name: string) => ({ label: `plugin.chat-plus.feature.${name}.label`, description: `plugin.chat-plus.feature.${name}.description` });
export const FEATURES: readonly FeatureSpec[] = [
...modules('chat', '', [
// No surfaces: the list of starred messages opens from any page of X (its star buttons only exist in chats).
{ id: 'chat.bookmarks', heavy: true, ...words('bookmarks'), keywords: 'star starred messages bookmarks saved dm reply jump', permissions: ['storage', 'ui', 'clipboard', 'commands'] },
{ id: 'chat.searchLoaded', surfaces: CHAT, heavy: true, ...words('searchLoaded'), keywords: 'find search in conversation ctrl shift f messages', permissions: ['ui', 'commands'] },
{ id: 'chat.pins', surfaces: CHAT, heavy: true, ...words('pins'), keywords: 'pin pinned label color chats conversations strip', permissions: ['storage', 'ui', 'commands'] },
{ id: 'chat.personFilter', surfaces: CHAT, heavy: true, ...words('personFilter'), keywords: 'group chat person participant filter only from', permissions: ['storage', 'ui', 'commands'] },
// On by default (owner, 2026-10-10): asks native code for the preview of a link on screen (link_preview.rs).
{ id: 'chat.linkPreviews', surfaces: CHAT, heavy: true, default: true, ...words('linkPreviews'), keywords: 'link preview embed youtube card unfurl', permissions: ['ui'] },
{ id: 'chat.keywords', surfaces: CHAT, heavy: true, settings: true, ...words('keywords'), keywords: 'highlight mute words keywords hide messages', permissions: ['storage', 'ui'] },
]),
];
/**
* Flags Power User turns on besides the defaults (this area's advanced features). None of them does
* anything by itself: a star, a pin, a picked person or a word list of the owner's comes first.
*/
export const POWER: readonly string[] = ['chat.bookmarks', 'chat.searchLoaded', 'chat.pins', 'chat.personFilter', 'chat.keywords'];