Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

docs: remove six finished implementation records (#7258)

Jiayuan Zhang814ee0cbf78f
diff --git a/CLAUDE.md b/CLAUDE.md
index 10ca86a14f..169771b22f 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -9,7 +9,7 @@ The source of truth for code naming, i18n glossary, and Chinese product voice is
- `apps/docs/content/docs/developers/conventions.mdx`
- `apps/docs/content/docs/developers/conventions.zh.mdx`
-Read it before editing translations in `packages/views/locales/`, naming routes/packages/files/DB columns/types, or writing Chinese UI/docs copy. Do not rely on `packages/views/locales/glossary.md`; it is only a redirect stub.
+Read it before editing translations in `packages/views/locales/`, naming routes/packages/files/DB columns/types, or writing Chinese UI/docs copy.
## Project Shape
diff --git a/HANDOFF-telegram.md b/HANDOFF-telegram.md
deleted file mode 100644
index cee9ec9072..0000000000
--- a/HANDOFF-telegram.md
+++ /dev/null
@@ -1,101 +0,0 @@
-# Telegram integration implementation notes
-
-Status: complete for the text-message scope described below.
-
-This document records the architecture and operating contract of Multica's
-Telegram channel. Setup instructions for operators live in the localized
-Telegram Bot integration guides under `apps/docs/content/docs/`.
-
-## Product contract
-
-| Area | Behavior |
-| --- | --- |
-| Transport | Telegram Bot API `getUpdates` long polling; no public callback URL is required |
-| Installation | One Telegram bot token belongs to one active Multica workspace and agent |
-| Identity | Every Telegram sender completes a one-time private account binding |
-| Private chat | Text and slash commands are accepted directly |
-| Group chat | A message is accepted when it mentions or replies to the bot; replying to a human additionally requires an explicit bot mention and includes that quoted sender/text |
-| Forum topic | Session and reply routing retain the Telegram topic ID |
-| Conversation | `/new` and `/issue` follow the shared channel command contract; accepted messages persist while unaddressed group chatter is not collected |
-| Replies | The triggering Telegram message is quoted; task output is streamed by editing the first reply |
-| Media | Text-only in this release; addressed non-text input receives an explicit unsupported-message response and creates no task |
-| Token storage | Bot tokens are encrypted with `MULTICA_TELEGRAM_SECRET_KEY` and never returned by management APIs |
-
-## Architecture
-
-The implementation uses the shared channel framework rather than a parallel
-Telegram-specific execution path:
-
-- `channel.Channel`, `channel.Registry`, and `engine.Supervisor` own lifecycle,
- retries, routing, and task dispatch.
-- `server/internal/integrations/telegram/` owns Bot API transport, installation,
- binding, inbound parsing, outbound delivery, Markdown conversion, and reply
- streaming.
-- The generic channel installation, binding, session, and identity tables are
- reused with `channel_type = 'telegram'`.
-- Migrations 349 and 350 extend the issue-origin constraint with
- `telegram_chat` using the repository's two-phase `NOT VALID` / `VALIDATE`
- pattern.
-- `packages/core/` provides the typed management client and React Query keys;
- `packages/views/` provides shared settings, agent integration, and binding
- views; `apps/web/` provides the bind route.
-
-## Safety boundaries
-
-- Installation verifies the token with `getMe` before persistence. Transport
- failures and credential rejection remain distinct so a network outage does
- not encourage unnecessary credential rotation.
-- Long polling refuses bots with an active outgoing webhook and never deletes
- another system's webhook automatically.
-- Group binding links are never posted publicly. A group sender is directed to
- start a private bot chat to complete binding.
-- Human-message quote context is included only when a group member replies and
- explicitly mentions the bot. The quoted sender and text/caption are persisted
- with the accepted instruction; `/new` starts a fresh session without dropping
- that selected quote. Ambient group chatter is never collected.
-- Chat-level edit cooldown and `retry_after` state survive sequential tasks in
- a hard-bounded cache. When capacity pressure compresses an active chat entry,
- its deadline is merged into a conservative per-installation fallback so a
- recreated chat never calls Telegram before the mandatory wait expires.
-- `EventChatDone` only enqueues in-process terminal delivery, so Telegram HTTP
- latency and repeated `retry_after` waits cannot block the synchronous event
- bus or realtime clients. A keyed scheduler preserves per-session FIFO order;
- normally one chat's backoff consumes no worker. If cache pressure compresses
- exact backoff state, other chats under the same Bot installation may be
- conservatively delayed. The terminal queue has fixed count, per-session, and
- byte limits; overflow is rejected and logged without blocking the event bus.
- Per-reply chunk progress prevents successful chunks from being repeated after
- a 429. Non-429 errors remain non-retriable.
-- On shutdown, queued, retry-waiting, and in-flight terminal jobs are abandoned
- after request cancellation, and their local stream/schedule references are
- released. The fixed-capacity in-process queue is not restart-durable.
-- Retry-pending task failures clear the superseded stream without showing a
- terminal failure notice; only a terminal failure changes or sends that notice.
-- Outbound delivery requires authoritative Telegram task provenance and fails
- closed when task or origin lookup cannot be completed.
-- Telegram API errors are sanitized so bot tokens cannot enter logs or API
- responses.
-
-## Verification
-
-The implementation is covered by Go protocol, lifecycle, security, migration,
-and race tests; TypeScript API-schema, query, settings, binding-page, locale,
-and UI tests; production Web/Docs/Desktop builds; and a real private-chat
-Telegram regression covering binding, commands, task execution, issue origin,
-streamed quoted replies, reconnect behavior, UTF-16 content, long replies, and
-the text-only media response.
-
-The detailed evidence and channel capability comparison are maintained in
-`docs/telegram-channel-review-2026-08-08.md`.
-
-## Deployment prerequisites
-
-- Set a 32-byte base64 `MULTICA_TELEGRAM_SECRET_KEY` in the server environment.
-- Ensure the server can reach `https://api.telegram.org/`; the standard Go
- transport honors `HTTPS_PROXY` when a deployment requires one.
-- Apply repository migrations before enabling the integration.
-- Keep Telegram privacy mode enabled unless a deployment deliberately wants
- the bot to receive every group message.
-
-No production deployment, production configuration change, or real-user data
-operation is part of this contribution.
diff --git a/apps/docs/content/docs/developers/conventions.ja.mdx b/apps/docs/content/docs/developers/conventions.ja.mdx
index 27a35d8292..39a0642c5d 100644
--- a/apps/docs/content/docs/developers/conventions.ja.mdx
+++ b/apps/docs/content/docs/developers/conventions.ja.mdx
@@ -94,7 +94,7 @@ Conventional 形式: `feat(scope)`, `fix(scope)`, `refactor(scope)`, `docs`, `te
## 2. i18n 翻訳用語集
-これは、すべての翻訳 PR が**必ず**守らなければならない用語集です。かつては `packages/views/locales/glossary.md` にありましたが、そのファイルは現在ここを指す stub です。
+これは、すべての翻訳 PR が**必ず**守らなければならない用語集です。かつては `packages/views/locales/glossary.md` にありましたが、そのファイルは削除され、このページが置き換えています。
### 中核となる区別: エンティティ vs 概念
diff --git a/apps/docs/content/docs/developers/conventions.ko.mdx b/apps/docs/content/docs/developers/conventions.ko.mdx
index 940c04da71..7f40938c9d 100644
--- a/apps/docs/content/docs/developers/conventions.ko.mdx
+++ b/apps/docs/content/docs/developers/conventions.ko.mdx
@@ -94,7 +94,7 @@ Conventional 형식: `feat(scope)`, `fix(scope)`, `refactor(scope)`, `docs`, `te
## 2. i18n 번역 용어집
-이것은 모든 번역 PR이 **반드시** 지켜야 하는 용어집입니다. 예전에는 `packages/views/locales/glossary.md`에 있었는데, 그 파일은 이제 이곳을 가리키는 stub입니다.
+이것은 모든 번역 PR이 **반드시** 지켜야 하는 용어집입니다. 예전에는 `packages/views/locales/glossary.md`에 있었는데, 그 파일은 삭제되었고 이 페이지가 대체합니다.
### 핵심 구분: 엔티티 vs 개념
diff --git a/apps/docs/content/docs/developers/conventions.mdx b/apps/docs/content/docs/developers/conventions.mdx
index 5eeefda8ed..67ee6bfc2d 100644
--- a/apps/docs/content/docs/developers/conventions.mdx
+++ b/apps/docs/content/docs/developers/conventions.mdx
@@ -105,7 +105,7 @@ Conventional format: `feat(scope)`, `fix(scope)`, `refactor(scope)`, `docs`, `te
## 2. i18n translation glossary
-This is the **mandatory** glossary for every translation PR. It used to live at `packages/views/locales/glossary.md`; that file is now a stub pointing here.
+This is the **mandatory** glossary for every translation PR. It used to live at `packages/views/locales/glossary.md`; that file has been removed and this page replaces it.
### The core distinction: everyday noun vs Multica-specific term
diff --git a/apps/docs/content/docs/developers/conventions.zh.mdx b/apps/docs/content/docs/developers/conventions.zh.mdx
index 6c64e65d0e..a534a13428 100644
--- a/apps/docs/content/docs/developers/conventions.zh.mdx
+++ b/apps/docs/content/docs/developers/conventions.zh.mdx
@@ -105,7 +105,7 @@ Conventional 格式:`feat(scope)`、`fix(scope)`、`refactor(scope)`、`docs`
## 2. i18n 翻译术语表
-这是每个翻译 PR 都必须遵守的术语表。原本在 `packages/views/locales/glossary.md`,那个文件现在是个 stub,指向这一页。
+这是每个翻译 PR 都必须遵守的术语表。原本在 `packages/views/locales/glossary.md`,那个文件已删除,由这一页取代。
### 核心区分:日常词 vs Multica 专有词
diff --git a/apps/mobile/docs/markdown-renderer-research.md b/apps/mobile/docs/markdown-renderer-research.md
deleted file mode 100644
index f6cbfd17d8..0000000000
--- a/apps/mobile/docs/markdown-renderer-research.md
+++ /dev/null
@@ -1,514 +0,0 @@
-# Markdown Renderer Research (RN / Expo)
-
-**Date:** 2026-05-09 (rewritten — initial research had a wrong claim about
-mention syntax, see *Decision Log* below).
-**Scope:** `apps/mobile/` — choosing a markdown renderer for Multica iOS that
-matches the web/desktop feature set.
-
-**Target requirements:**
-
-1. Render the markdown that web/desktop already write to the database
- (issue descriptions + comments) without losing semantic content.
-2. Make `@member` / `@agent` / `#issue` mentions tappable chips.
-3. Make `![alt](url)` images inline + tappable to a lightbox.
-4. Make `!file[name](url)` file references tappable + open via the system.
-
----
-
-## TL;DR
-
-**Use [`react-native-marked`](https://github.com/gmsgowtham/react-native-marked) v8.0.1.** Wrap it behind a thin adapter under `apps/mobile/lib/markdown/`. Override the `link` and `image` renderers — that is *all* the custom rendering we need. Mention detection is a one-line URL prefix check (`mention://`), file detection is a preprocess pass that rewrites `!file[name](url)` to a normal markdown link with a `📎` prefix. Use `expo-image` for inline images and `react-native-image-viewing` for tap-to-lightbox.
-
----
-
-## Critical correction from initial research
-
-The initial draft of this doc claimed mentions were stored as bare `@user` / `#issue` patterns and that mobile needed a custom `marked` inline tokenizer extension to detect them. **This was wrong.**
-
-The actual encoding (see `packages/views/editor/extensions/mention-extension.ts:73`):
-
-```ts
-return `[${prefix}${safeLabel}](mention://${type}/${id})`;
-// emits e.g. [@naiyuan](mention://member/abc-123)
-// [MUL-123](mention://issue/issue-uuid)
-```
-
-Mentions are **already standard markdown links** with a custom URI scheme. So mobile does NOT need a custom tokenizer — overriding `Renderer.link()` to check `href.startsWith("mention://")` is enough. This makes the integration significantly simpler than the initial sketch.
-
----
-
-## What features web actually emits
-
-Web's read-only renderer (`packages/views/editor/readonly-content.tsx`) uses `react-markdown` + this plugin set:
-
-- `remark-gfm` — tables, task lists, strikethrough, autolinks
-- `remark-breaks` — single newline → `<br>`
-- `remark-math` + `rehype-katex` — `$inline$` and `$$block$$` math
-- `rehype-raw` — raw HTML pass-through
-- `rehype-sanitize` — HTML sanitization
-- `lowlight` — code block syntax highlighting
-- `mermaid` — diagrams (lazy loaded)
-
-Plus a preprocess (`packages/views/editor/utils/preprocess.ts`):
-
-1. Legacy mention shortcodes `[@ id="..." label="..."]` → modern `[@Label](mention://...)` form
-2. Bare URL → markdown link (linkify)
-3. File card syntax (`!file[name](url)` and legacy `[name](cdn-url)` lines) → HTML `<div data-type="fileCard">`
-
-### Mobile coverage matrix
-
-| Feature | Mobile V1 | Why |
-|---|---|---|
-| Bold / italic / strikethrough | ✅ | marked.js GFM, no extra cost |
-| Inline `code` / fenced code blocks | ✅ | marked.js core; **no syntax highlight** in V1 (lowlight is ~200KB and not worth it) |
-| Headings (h1-h6) | ✅ | core |
-| Lists (ordered / unordered / **task**) | ✅ | GFM |
-| Block quotes | ✅ | core |
-| Plain links | ✅ | `Renderer.link` override → `Linking.openURL` |
-| **Mention links** (`mention://...`) | ✅ | `Renderer.link` checks prefix → renders chip |
-| **Inline images** (`![alt](url)`) | ⚠️ V2.2 | `Renderer.image` + expo-image. Defer to a separate phase to isolate risk |
-| **Tap-to-lightbox** | ⚠️ V2.2 | `react-native-image-viewing`, single global lightbox provider |
-| **File cards** (`!file[name](url)`) | ✅ | Preprocess to `[📎 name](url)`; ordinary link rendering, tap opens via system |
-| Tables | ⚠️ V2.3 | marked emits tokens; we render simplified vertical layout. Phone screens can't fit wide tables |
-| Autolinks | ✅ | GFM |
-| `remark-breaks` (newline → break) | ✅ | marked.js `breaks: true` option |
-| LaTeX math | ❌ V3+ | KaTeX is heavy + needs custom font shipping; rarely used |
-| Mermaid | ❌ V3+ | webview-only on RN; very heavy; rarely used |
-| Code syntax highlighting | ❌ V3+ | lowlight + theme CSS; nice-to-have not blocker |
-| Raw HTML (`rehype-raw`) | ❌ never | Security boundary; mobile content all comes from web editor anyway |
-
----
-
-## Library evaluation
-
-| Library | Verdict | Notes |
-|---|---|---|
-| **`react-native-marked` v8.0.1** (2026-03-17) | **Pick** | Active (88 releases), TS 99.6%, RN 0.76+ compatible (we're on 0.83), peer dep `react-native-svg` already installed. Custom `Renderer` class + tokenizer extensions give us everything we need |
-| `react-native-markdown-display` | Reject | Stale (last release ~2 years); maintainer recommends migrating away |
-| `react-native-enriched-markdown` (Software Mansion) | Reject (now) | No custom inline component support yet (mention chips would need a roadmap feature). Revisit in 6-12 months |
-| `react-native-awesome-gallery` (lightbox) | Reject | Last release 2024-07, 18+ months stale. Reanimated v3 dependency met but maintenance signal is bad |
-| **`react-native-image-viewing`** (jobtoday) | **Pick for lightbox** | Pure TS, simple API (`<ImageView visible imageIndex images=[]/>`), zero animation deps |
-| **`expo-image`** | **Pick for inline** | First-party Expo, on-disk cache, `contentFit` API, `transition` prop. Same engine the rest of the Multica stack will use for avatars later |
-
----
-
-## Architecture
-
-```
-apps/mobile/
-├── lib/markdown/
-│ ├── index.ts # Public API: <Markdown content="..." />
-│ ├── markdown.tsx # Wraps react-native-marked w/ our renderer + preprocess
-│ ├── renderer.tsx # MulticaRenderer extends Renderer — overrides link, image
-│ ├── preprocess.ts # Mention-shortcode + file-card rewrite, idempotent
-│ ├── mention-chip.tsx # member / agent / issue chip components
-│ ├── markdown-image.tsx # expo-image + auto aspect ratio + tap-to-lightbox dispatch
-│ └── lightbox-provider.tsx # App-level provider + React Context for opening lightbox
-└── components/issue/
- ├── comment-card.tsx # <Text>{content}</Text> → <Markdown content={content}/>
- └── issue-description.tsx # Same swap
-```
-
-The adapter boundary stays thin so swapping the engine later (e.g. once `react-native-enriched-markdown` matures) is a localized change.
-
----
-
-## Mention rendering — the actual pipeline
-
-```tsx
-// lib/markdown/renderer.tsx (sketch)
-class MulticaRenderer extends Renderer {
- link(text: string, href: string) {
- if (href.startsWith("mention://")) {
- const [, , type, id] = href.split("/");
- return <MentionChip key={this.getKey()} type={type} id={id} fallback={text} />;
- }
- return <PlainLink key={this.getKey()} href={href}>{text}</PlainLink>;
- }
- image(uri: string, alt?: string) {
- return <MarkdownImage key={this.getKey()} uri={uri} alt={alt} />;
- }
-}
-```
-
-```tsx
-// lib/markdown/mention-chip.tsx
-function MentionChip({ type, id, fallback }: Props) {
- const { getName, getAvatarUrl } = useActorLookup(); // already exists in mobile
- const { issues } = useIssueListCache(); // mobile-local helper
-
- if (type === "member" || type === "agent") {
- const name = getName(type, id);
- return (
- <Text className="text-primary font-medium">@{name ?? fallback.replace(/^@/, "")}</Text>
- );
- }
- if (type === "issue") {
- const issue = issues.find((i) => i.id === id);
- const onPress = () =>
- router.push(`/${wsSlug}/issue/${id}`);
- return (
- <Text className="text-blue-500" onPress={onPress}>
- {issue?.identifier ?? fallback}
- </Text>
- );
- }
- return <Text>{fallback}</Text>;
-}
-```
-
-The "miss → render fallback string" path matters: in production, member/agent lists are pre-loaded in `[workspace]/_layout.tsx` so cache hit rate is near 100%. The fallback string is the original markdown link text (`@naiyuan` / `MUL-123`) so the user always sees something readable.
-
----
-
-## Image rendering — auto aspect ratio
-
-```tsx
-function MarkdownImage({ uri, alt }: { uri: string; alt?: string }) {
- const { open } = useLightbox();
- const [aspect, setAspect] = useState<number | null>(null);
-
- useEffect(() => {
- Image.getSize(
- uri,
- (w, h) => setAspect(w / h),
- () => setAspect(16 / 9), // fallback when remote 404 / decode fails
- );
- }, [uri]);
-
- return (
- <Pressable onPress={() => open(uri)}>
- <ExpoImage
- source={{ uri }}
- style={{ width: "100%", aspectRatio: aspect ?? 16 / 9, borderRadius: 8 }}
- contentFit="contain"
- transition={150}
- />
- </Pressable>
- );
-}
-```
-
-Using `aspectRatio` rather than fixed `height` avoids layout shift once the image actually loads — the placeholder takes the right space from the start.
-
----
-
-## File card rendering — preprocess into a normal link
-
-```ts
-// lib/markdown/preprocess.ts
-const FILE_LINE_RE = /^!file\[([^\]]+)\]\((https?:\/\/[^)]+)\)$/;
-
-export function preprocessMobileMarkdown(input: string): string {
- return input
- .split("\n")
- .map((line) => {
- const trimmed = line.trim();
- const m = trimmed.match(FILE_LINE_RE);
- if (!m) return line;
- return `[📎 ${m[1]}](${m[2]})`;
- })
- .join("\n");
-}
-```
-
-Then `Renderer.link` opens the URL via `Linking.openURL` — iOS handles PDF/image/zip/etc. via system viewers or share sheet automatically. No custom file-card chip component needed in V1.
-
-**Legacy CDN-hostname-based file detection (`[name](cdn-url)` on its own line)** is deliberately NOT ported. It depends on having `cdnDomain` from config; mobile doesn't bootstrap config that way. Old comments using the legacy form will render as a normal hyperlink — the tap behavior is identical (open in system), only the visual decoration differs. Acceptable degradation.
-
----
-
-## Mention shortcode preprocess (legacy DB rows)
-
-The DB has two mention serializations because of an April 2026 migration:
-
-- **New**: `[@Label](mention://member/id)` — emitted by current Tiptap editor
-- **Legacy**: `[@ id="abc-123" label="Naiyuan"]` — old shortcode form
-
-Mobile must convert legacy → new before parsing, otherwise old comments render the literal shortcode text. Logic is a pure regex transform — `packages/ui/markdown/index.ts` exports `preprocessMentionShortcodes` for web/desktop, but mobile **cannot** import from `@multica/ui/*` (Sharing Principles in `apps/mobile/CLAUDE.md`).
-
-Two options:
-
-| Option | Trade-off |
-|---|---|
-| **A.** Lift the pure function to `@multica/core/markdown/` so all three apps share it | One PR adds a new core module; web/desktop migrate their import path; mobile imports same function. Single source of truth |
-| **B.** Mobile re-implements it (~30 lines) | No web/desktop change; risk of drift if the legacy format ever expands |
-
-**Recommend A.** This is exactly the kind of pure-function-share-zone the monorepo is for, and parity is required (same legacy comment must produce the same mention id on both clients).
-
----
-
-## Lightbox
-
-Single global lightbox provider mounted at `app/(app)/_layout.tsx`:
-
-```tsx
-function LightboxProvider({ children }: { children: ReactNode }) {
- const [images, setImages] = useState<string[]>([]);
- const [index, setIndex] = useState(0);
- const open = (uri: string) => { setImages([uri]); setIndex(0); };
- const close = () => setImages([]);
- return (
- <LightboxContext.Provider value={{ open }}>
- {children}
- <ImageView
- images={images.map((uri) => ({ uri }))}
- imageIndex={index}
- visible={images.length > 0}
- onRequestClose={close}
- />
- </LightboxContext.Provider>
- );
-}
-```
-
-V1 only opens single images. V2 can extend to galleries (all images in one comment shown together) by collecting `![]()` URLs while rendering and passing the array through.
-
----
-
-## Phasing
-
-| Phase | Scope | Days |
-|---|---|---|
-| **V2.1** | preprocess (mention shortcodes + file cards) + plain markdown rendering (bold/italic/code/lists/quotes/headings/links/mention chips). Replaces `<Text>{content}</Text>` in comment-card and issue-description | ~1 |
-| **V2.2** | Inline images via `expo-image` + lightbox via `react-native-image-viewing` | ~0.5 |
-| **V2.3** | Tables (vertical degraded layout), task list checkboxes (read-only), strikethrough | ~0.5 |
-| **V3+** | LaTeX, Mermaid, syntax highlighting — only when product asks for them | per-feature |
-
----
-
-## Reference architectures
-
-### Mattermost mobile (still relevant for image sizing + mention fallback patterns)
-
-[`mattermost/mattermost-mobile`](https://github.com/mattermost/mattermost-mobile)'s pipeline is more complex than ours because they fork commonmark.js for four custom inline syntaxes. We need none of that — our mentions are already standard markdown links. What's still worth lifting from them:
-
-- Image sizing: viewport-width-aware + max-height clamps + tap-to-gallery (we mirror this in `MarkdownImage`)
-- Mention fallback: render the original token text on cache miss (we mirror this in `MentionChip`)
-
-Source files worth glancing at before implementation:
-
-- [`markdown_image/index.tsx`](https://github.com/mattermost/mattermost-mobile/blob/main/app/components/markdown/markdown_image/index.tsx) — viewport sizing, Android clamps
-- [`at_mention/at_mention.tsx`](https://github.com/mattermost/mattermost-mobile/blob/main/app/components/markdown/at_mention/at_mention.tsx) — fallback render
-
-We deliberately don't lift their `transform.ts` (heavy AST manipulations to make commonmark behave like their custom dialect) — our content is already normalized by Tiptap.
-
----
-
-## RN native rendering constraints (May 2026)
-
-This section is the **single source of truth** for what does and does not work
-when styling markdown in React Native. Every rule below is backed by a
-reproducible RN issue thread — these are not design trade-offs, they are
-platform limits of how iOS TextKit + RN's nested-Text flattener interact.
-
-### The nested-`<Text>` rule (the most important one)
-
-**Inline `<Text>` runs nested inside another `<Text>` flatten into a single
-`NSAttributedString` on iOS.** `NSAttributedString` runs only support font /
-color / underline / strikethrough / shadow attributes. Any of the following
-properties on an inline child `<Text>` are **silently ignored OR force the
-run to break out of inline flow** (depending on RN version + New Arch):
-
-- `borderWidth`, `borderColor`, `borderRadius`
-- `padding*`, `margin*`
-- `width`, `height`
-
-This is **not a bug we can wait out** — RN has known about it for 10 years
-and chosen not to fix it because it requires a new layout engine for inline
-runs. Track:
-
-- [`facebook/react-native#10775`](https://github.com/facebook/react-native/issues/10775) (Nov 2016, locked, no fix)
-- [`facebook/react-native#6728`](https://github.com/facebook/react-native/issues/6728) (margin/padding ignored on nested Text)
-- [`facebook/react-native#45925`](https://github.com/facebook/react-native/issues/45925) (Aug 2024, **still open**, reproduces under New Arch / Fabric)
-- [`react-native-community/discussions-and-proposals#695`](https://github.com/react-native-community/discussions-and-proposals/issues/695) (Jul 2023): explicitly states *"React Native ignores padding on inline text elements. Border styles for inline text are not supported. If the inline text has a background color set, it fills the whole line."*
-
-**On iOS New Arch / Fabric specifically, the breakage mode flipped from
-"silently dropped" (Paper) to "force run break" (Fabric).** That is the
-regression we hit shipping inline-code chips with `border` + `py-0.5` —
-each chip pushed to its own line.
-
-**CJK amplifies the symptom but is not a separate bug.** iOS TextKit uses
-UAX #14 / Kinsoku rules that treat every CJK ideograph as a soft-break
-opportunity. When a non-flowable inline span (border'd `<Text>`) sits in a
-CJK paragraph, the break solver pessimistically breaks at every adjacent
-ideograph boundary, exploding a single visual line into 6-7 broken lines.
-Pure-Latin paragraphs would only look slightly ugly; mixed CJK paragraphs
-look catastrophic. **Fix the underlying Text rule, not the symptom.**
-([`facebook/react-native#19193`](https://github.com/facebook/react-native/issues/19193) tracks adjacent CJK baseline drift.)
-
-### Workarounds that actually work — and the ones that don't
-
-| Approach | Status |
-|---|---|
-| Inline `<Text>` with `bg + fontFamily` only | ✅ The native idiom. Mattermost / GitHub mobile / `react-native-marked` all do this for inline code |
-| Inline `<Text>` with `bg + border + padding` | ❌ The bug. **Do not use, ever.** |
-| Wrap chip in `<View>` | ❌ Becomes block-level — collapses paragraph flow, every chip on its own line by definition |
-| `react-native-enriched-markdown` (Software Mansion) | Uses native attributed-string + inline-image hacks; works but no custom inline component slot — already rejected for V1 |
-| Border-on-block-Text (e.g. fenced code block in a `<View>`) | ✅ Borders work fine on `<View>` and on **non-nested** root `<Text>` |
-
-**Translation to web parity expectations:** web's "3-layer chip" (`bg + border + opacity`) is a CSS inline-block affordance that **has no faithful RN equivalent**. Mobile must compensate with a single-layer chip — bumped background opacity is the safe substitute for the missing border.
-
-### `<Text lineBreakStrategyIOS>` for CJK
-
-RN 0.71+ exposes `lineBreakStrategyIOS` to opt the outer paragraph `<Text>`
-into the iOS-native CJK-aware break strategies (`"hangul-word"` /
-`"push-out"`). Applying this on the outermost `<Text>` of a paragraph
-visibly improves CJK wrapping at line edges. Set it on every paragraph
-`<Text>` and every list-item content `<Text>`.
-
-### Tiptap-emitted markdown serialization
-
-[Tiptap's default `clipboardTextSerializer`](https://tiptap.dev/docs/editor/extensions/nodes/hard-break) emits `\n\n` between paragraphs and `\n` only for explicit `HardBreak` nodes (Shift+Enter). Bare single `\n` inside a paragraph is rare in Multica content (everything that lands in our DB went through tiptap). So `marked.lexer({ breaks: true })`:
-
-- Is **harmless** for tiptap content.
-- Is **defensive** for non-tiptap input (paste, IME, future API ingestion paths).
-- Matches web's `remark-breaks` plugin, preserving cross-platform parity.
-
-**Verdict: leave `breaks: true` on.** The exploding-paragraph symptom in
-the May 2026 incident was the nested-Text border bug, not `breaks`.
-
-### Mobile typography scale (verified against Apple HIG)
-
-shadcn / web defaults are too large on phone screens. Calibrated against
-Apple HIG Dynamic Type (Body 17pt, Title 3 20pt, Title 2 22pt, Title 1
-28pt) and verified in GitHub mobile / Linear iOS:
-
-| Element | Mobile class | Rationale |
-|---|---|---|
-| Body / paragraph | `text-sm leading-6` | 14px on 24px line ≈ 1.71 — generous for CJK glyph height; HIG Body Compact. See *Body lineHeight stays at 24* below for why a 2026-05-19 reduction attempt was reverted |
-| Inline code | `text-sm font-mono` | Match body size, mono variant — chip identification is by bg, not size |
-| Block code | `text-sm font-mono` | Same as inline |
-| H1 | `text-xl font-bold` (20px) | HIG Title 3 — markdown H1 inside an issue card is structural, not a screen title |
-| H2 | `text-lg font-semibold` (18px) | One step down from H1; matches GitHub mobile |
-| H3 | `text-base font-semibold` (16px) | Body+1 |
-| H4–H6 | `text-sm font-semibold` | Body, weight to differentiate |
-
-**Body lineHeight stays at 24 (ratio 1.71) — 1.43 reduction reverted same day**
-
-A 2026-05-19 attempt to reduce `MD_LINE.body` from 24 to 20 (ratio 1.71
-→ 1.43) — to fix the inline-code chip's top-heavy visual artifact — was
-**reverted on the same day** after additional research falsified the
-hypothesis.
-
-Falsifying evidence:
-
-1. **Discord / Slack / Telegram / Mattermost mobile all use background +
- monospace** for inline code with NO visible top-heavy artifact —
- confirming the artifact is not an RN+iOS platform-wide problem.
-2. **Upstream issue [#255](https://github.com/software-mansion-labs/react-native-enriched-markdown/issues/255)**
- on `react-native-enriched-markdown` (filed 2026-04-20) is the same
- problem reported by another user: enriched applies hardcoded inline-
- code padding that cannot be turned off via `markdownStyle`. Maintainer
- has not responded, no ETA.
-
-So the chip is the **library's bug**, not a `lineHeight` configuration
-problem. Reducing `lineHeight` shrinks the absolute padding but does
-NOT change the top:bottom asymmetry ratio (still ≈ 4:1 either way),
-because the ratio is set by enriched's internal padding distribution.
-Reducing `lineHeight` only costs us CJK leading without solving the
-artifact.
-
-`leading-6` (1.71) restored. The original PingFang SC argument applies:
-CJK glyphs are taller than SF and benefit from ≥1.5 leading.
-
-**Accepted as a known limitation, tracked in
-`docs/markdown-rendering-adr.md` → Known limitations.**
-
-### List bullet column width
-
-Canonical mobile pattern: 16px hanging indent column for `•` / `1.` —
-`<View>` row of `<Text className="w-4">` for the bullet plus `<View
-className="flex-1">` for content. GitHub mobile and Linear iOS both use
-~16px. Bump to 20px (`w-5`) only for nested lists where deeper indents
-need extra room.
-
-`w-6` (24px, our pre-incident default) leaves visible dead space between
-the bullet and the text.
-
-### Block spacing between paragraphs
-
-`mb-3` (12px) is the right default for the *general* block-to-block
-transition. For consecutive single-line paragraphs in CJK, `mb-2` (8px)
-reads tighter and better. We use a **single block gap** for simplicity —
-12px between everything. Tightening adaptively is a polish item, not a
-correctness one.
-
-### NativeWind 4 specific notes
-
-- Color opacity (`bg-foreground/10`) is computed at build time, not runtime — works fine on `<Text>`.
-- `border` compiles to `borderWidth: 1, borderColor: ...`. NativeWind faithfully forwards both. RN drops them on nested `<Text>`. **Not a NativeWind bug — it's RN.**
-- No NativeWind 4 docs acknowledge nested-Text styling limits — they inherit RN behavior silently. Don't assume a Tailwind class works on `<Text>` just because it works on `<View>`.
-
----
-
-## Decision log
-
-- **2026-05-09 (initial)** — Picked `react-native-marked`. Sketched a mention pipeline with custom marked tokenizer for `@user` / `#issue` patterns.
-- **2026-05-09 (rewrite)** — Discovered `mention-extension.ts:73` actually emits markdown links with `mention://` URI scheme. Replaced the tokenizer-extension plan with a `Renderer.link` override (much simpler). Added image / file / lightbox plans now that the data shape is verified end-to-end. Confirmed `react-native-marked` and `react-native-svg` are still the right primitives in May 2026; chose `react-native-image-viewing` over `react-native-awesome-gallery` (the latter has been stale since 2024-07).
-- **2026-05-09 (engine actually shipped)** — Replaced planned `react-native-marked` adapter with a hand-rolled walker on raw `marked@18` (`render-block.tsx` / `render-inline.tsx` / `ast.ts`, ~450 LOC). Reason: `react-native-marked` v7.0 (Jun 2025) removed the `CustomToken` API needed for inline mention chips; v8 added React-component embedding back but custom inline tokenization is still constrained. Walker keeps total control over mention chips, file cards, and the inline-image-promotion AST pre-pass.
-- **2026-05-09 (Shiki + Expo Go assumption dropped)** — Project moved to dev client (custom native build) — Expo Go-compatible constraint no longer applies. Adopted `react-native-shiki-engine` (JSI Oniguruma + native engine) with reused web Shiki theme JSON (`github-light` / `github-dark`) for **byte-identical syntax highlighting** between web and mobile. Highlighter singleton lives in `lib/markdown/shiki.ts`, prewarmed at app boot.
-- **2026-05-09 (inline code chip incident)** — Shipped 3-layer styling (`bg + border + opacity`) ported from web. CJK paragraphs catastrophically broke into 6-7 lines per chip. Root cause: RN's 10-year-old nested-Text limitation (issues #10775 / #45925 / #6728 — `borderWidth` / `padding` / `margin` are not part of `NSAttributedString`'s expressible attribute set, so iOS TextKit either drops them or breaks the run out of inline flow; New Arch / Fabric flipped the failure mode from "silent drop" to "force break"). CJK amplified the symptom because UAX #14 / Kinsoku treat every ideograph as a soft-break opportunity around the non-flowable run. Fix: drop border + padding from inline code, bump background opacity from `/5` to `/10` to compensate. **Encoded the rule in *RN native rendering constraints* above so this never happens again.**
-
-- **2026-05-19 (RNR theme integration + enriched-markdown dark-default trap)** — Migrated `markdown-style.ts` from static hex constants to a `useMarkdownStyle()` hook driven by `THEME[scheme]` (from `lib/theme.ts`, mirroring `global.css` CSS variables). Non-prose layers (`CodeBlock` / `MarkdownImage`) were already className-driven and only needed dark-mode `--code-surface` (changed from light-mirror `240 4% 92%` to `240 4% 18%`). Two waves of dark-mode bugs uncovered the same root cause:
-
- **First wave** (visible breakage in `MUL-2395` dark screenshot): list items rendered as black-on-black (invisible); inline code showed a white-ish empty outline (no fill).
-
- **Root cause**: `[email protected]`'s `normalizeMarkdownStyle.js` defines `DEFAULT_NORMALIZED_STYLE` — a frozen table of ~30 hardcoded LIGHT-mode color defaults (`#1F2937` text, `#E01E5A` inline code, `#FDF2F4` inline code bg, `#F8D7DA` inline code border, `#4B5563` blockquote, `#FFFFFF` table even row, `#000000` checked task text, etc.). User `markdownStyle` is merged on top — **fields you don't pass keep the hardcoded light value**. There is no "inherit from parent" fallback at the native md4c layer.
-
- The "white outline" on inline code in dark mode was the default `#F8D7DA` (pale pink) border showing against `#0a0a0a` page background.
-
- **Fix**: read the entire `normalizeMarkdownStyle.js` file (~264 LOC), enumerate every color field, set every one explicitly from `THEME[scheme]`. Currently covered: `paragraph/h1–h6/blockquote/list/codeBlock/link/strong/em/strikethrough/underline/code/thematicBreak/table/taskList/math/inlineMath`. Also pass `lineHeight` explicitly on every heading because enriched's heading lineHeight defaults are calibrated to its larger default fontSizes (h1: 36pt for 30pt fontSize) — using mobile's smaller heading fontSizes (h1: 20pt) without overriding lineHeight produces awkwardly tall lines.
-
- **Rule to encode for future maintainers**:
-
- > **Any time `EnrichedMarkdownText`'s `markdownStyle` is extended, audit `normalizeMarkdownStyle.js` in `node_modules/react-native-enriched-markdown/lib/module/` and verify every color field has an explicit `THEME[scheme]` override. Do NOT assume "inherit". When upgrading enriched-markdown (v0.6+), re-run the audit — new fields ship hardcoded light defaults too.**
-
- Inline code background alpha: `12%` on dark is invisible against `#0a0a0a`; bumped to `40%` (`#9ca3af66`) in dark mode while keeping `12%` in light. Border forced to `transparent` to kill the default pink stroke.
-
-- **2026-05-19 (lineHeight 24→20 attempted then REVERTED same day)** — Saw inline-code chip with very top-heavy padding in #MUL-2397 screenshot. Initial hypothesis: paragraph `lineHeight 24` + iOS TextKit descender-flush glyph positioning produced ~4.3:1 top:bottom space ratio. Reduced `MD_LINE.body` 24→20 to compress. **Reverted same day after research falsified the hypothesis**:
- - Discord / Slack / Telegram / Mattermost mobile all use background + monospace inline code with no visible top-heavy artifact ([Discord markdown guide](https://gist.github.com/matthewzring/9f7bbfd102003963f9be7dbcf7d40e51), [Slack docs](https://slack.com/help/articles/202288908-Format-your-messages), [Telegram entities API](https://core.telegram.org/api/entities)) — confirming the artifact is NOT a RN+iOS structural limitation
- - Upstream [`react-native-enriched-markdown#255`](https://github.com/software-mansion-labs/react-native-enriched-markdown/issues/255) — same user-reported problem, maintainer unresponsive — confirms enriched applies hardcoded inline-code padding that can't be turned off
- - Reducing `lineHeight` shrinks absolute padding but doesn't shift the asymmetry ratio (enriched's internal padding distribution is what sets the ratio). Net effect of the reduction: cost CJK leading, didn't fix the chip
- - Restored `MD_LINE.body: 24`. Heading values restored: h1 28, h2 24, h3 22, h4/h5 20, h6 18.
- - **Lesson**: when a chip artifact appears in enriched-markdown output, check upstream issues BEFORE proposing a numeric fix on our side. Chip layout is library-controlled, not consumer-controlled. Now tracked in `docs/markdown-rendering-adr.md` → Known limitations.
-
----
-
-## References
-
-### Libraries
-
-- [`react-native-marked` — GitHub](https://github.com/gmsgowtham/react-native-marked) (v8.0.1, 2026-03-17)
-- [`react-native-marked` — npm](https://www.npmjs.com/package/react-native-marked)
-- [`marked.js` extension API](https://marked.js.org/using_pro)
-- [`expo-image` — Expo docs](https://docs.expo.dev/versions/latest/sdk/image/)
-- [`react-native-image-viewing` — GitHub](https://github.com/jobtoday/react-native-image-viewing)
-- [`react-native-image-viewing` — npm](https://www.npmjs.com/package/react-native-image-viewing)
-- [`react-native-enriched-markdown` — GitHub](https://github.com/software-mansion-labs/react-native-enriched-markdown) (rejected for V1: no custom inline component support)
-
-### In-repo references
-
-- `packages/views/editor/extensions/mention-extension.ts` — actual mention serialization
-- `packages/views/editor/readonly-content.tsx` — web's read-only render plugin set
-- `packages/views/editor/utils/preprocess.ts` — three-step preprocess pipeline web uses
-- `packages/ui/markdown/file-cards.ts` — file-card detection logic (for parity reference)
-- `apps/mobile/data/use-actor-name.ts` — mention name resolution helper (already implemented)
-
-### Reference implementations
-
-- [Mattermost mobile — `app/components/markdown/`](https://github.com/mattermost/mattermost-mobile/tree/main/app/components/markdown)
-- [Rocket.Chat — `@rocket.chat/message-parser`](https://www.npmjs.com/package/@rocket.chat/message-parser)
-
-### RN platform constraint sources (May 2026)
-
-- [RN #10775 — "Border can't be applied to `<Text>` in nested `<Text>`"](https://github.com/facebook/react-native/issues/10775) — Nov 2016, locked, no fix
-- [RN #45925 — Same bug re-filed, **still open**](https://github.com/facebook/react-native/issues/45925) — Aug 2024, reproduces under New Arch
-- [RN #6728 — `margin` / `padding` ignored on nested `<Text>`](https://github.com/facebook/react-native/issues/6728)
-- [discussions-and-proposals #695 — "Inline code blocks"](https://github.com/react-native-community/discussions-and-proposals/issues/695) — Jul 2023, official statement that nested-Text padding/border is unsupported
-- [RN #19193 — Mixed CJK + Latin baseline drift](https://github.com/facebook/react-native/issues/19193) — adjacent CJK rendering quirk
-- [RN Text component docs (current)](https://reactnative.dev/docs/text)
-- [NativeWind 4 — Quirks](https://www.nativewind.dev/docs/core-concepts/quirks) (does not call out nested-Text limits — pure RN issue)
-- [Tiptap — HardBreak node docs](https://tiptap.dev/docs/editor/extensions/nodes/hard-break) — clipboardTextSerializer behavior
-- [Apple HIG — Typography](https://developer.apple.com/design/human-interface-guidelines/typography) — Dynamic Type sizing
-- [Material 3 — Typography scale](https://m3.material.io/styles/typography/applying-type)
diff --git a/apps/mobile/docs/markdown-rendering-adr.md b/apps/mobile/docs/markdown-rendering-adr.md
index e484b5ae82..f988a76bb1 100644
--- a/apps/mobile/docs/markdown-rendering-adr.md
+++ b/apps/mobile/docs/markdown-rendering-adr.md
@@ -2,13 +2,10 @@
**Status**: Accepted
**Date**: 2026-05-19
-**Supersedes**: nothing (formalises what `markdown-renderer-research.md` was
-already documenting in research form)
This is the durable architecture-decision record for how the mobile app
-renders markdown. `markdown-renderer-research.md` continues to hold the
-detailed history and incident log; this file is the **one-page answer**
-to "what are we using and why" with A-tier sources.
+renders markdown — the **one-page answer** to "what are we using and why"
+with A-tier sources.
---
@@ -150,10 +147,11 @@ above` vs `~3pt below` glyphs in chips inside CJK paragraphs (seen in
not** show this asymmetry — confirming the artifact is library-specific.
- **Upstream tracking**: [`software-mansion-labs/react-native-enriched-markdown#255`](https://github.com/software-mansion-labs/react-native-enriched-markdown/issues/255)
(filed 2026-04-20 by `@xindixu`, maintainer unresponsive as of 2026-05-19).
-- **Failed mitigation (reverted)**: reducing `MD_LINE.body` from 24 to
- 20 shrinks absolute padding but does not change the asymmetry ratio —
- net negative (cost CJK leading, didn't fix the chip). See
- `markdown-renderer-research.md` decision log 2026-05-19.
+- **Failed mitigation (reverted 2026-05-19, same day)**: reducing
+ `MD_LINE.body` from 24 to 20 shrinks absolute padding but does not
+ change the asymmetry ratio (still ≈ 4:1 — enriched sets the padding
+ distribution internally) — net negative, cost CJK leading and didn't
+ fix the chip.
**Mitigation applied (2026-05-19)** — inline code rendered WITHOUT a
background:
@@ -256,5 +254,4 @@ React-tree renderer:
- `apps/mobile/lib/markdown/markdown-style.ts` — `useMarkdownStyle()` theme bridge
- `apps/mobile/lib/markdown/code-block.tsx` — Shiki-powered code segment
- `apps/mobile/lib/markdown/markdown-image.tsx` — lightbox-aware image segment
-- `apps/mobile/docs/markdown-renderer-research.md` — full incident log and historical context
- `apps/mobile/CLAUDE.md` — mobile-wide rules including theme/CSS-variable system
diff --git a/apps/mobile/lib/markdown/markdown-style.ts b/apps/mobile/lib/markdown/markdown-style.ts
index 811ac09119..727712d179 100644
--- a/apps/mobile/lib/markdown/markdown-style.ts
+++ b/apps/mobile/lib/markdown/markdown-style.ts
@@ -10,12 +10,12 @@
* `useColorScheme` everything else in the app uses, and rebuilds the
* style object whenever the theme flips.
*
- * Sizing follows the mobile typography scale documented in
- * `apps/mobile/docs/markdown-renderer-research.md` → "Mobile typography
- * scale" (calibrated against Apple HIG; one tier below shadcn web defaults
- * because markdown headings inside an issue card are structural, not
- * screen titles). HIG values are encoded in `MD_FONT` / `MD_LINE` /
- * `MD_GAP` constants — these are NOT RNR tokens to replace; they are
+ * Sizing sits one tier below shadcn web defaults because markdown headings
+ * inside an issue card are structural, not screen titles. The scale is
+ * calibrated against Apple HIG Dynamic Type (Body 17pt, Title 3 20pt,
+ * Title 2 22pt, Title 1 28pt) and cross-checked against GitHub Mobile and
+ * Linear iOS. Those values are encoded in the `MD_FONT` / `MD_LINE` /
+ * `MD_GAP` constants below — these are NOT RNR tokens to replace; they are
* mobile-specific design constants validated by the 2026-05-09 inline-
* code incident.
*/
@@ -25,7 +25,7 @@ import { useColorScheme } from "@/lib/use-color-scheme";
/**
* Typography scale — Apple HIG-calibrated, one tier below shadcn web.
- * See `docs/markdown-renderer-research.md` "Mobile typography scale".
+ * h1 maps to HIG Title 3 (20), h2 one step down (18), h3 body+2 (16).
*/
const MD_FONT = {
body: 14,
@@ -63,9 +63,8 @@ const MD_LINE = {
// chip artifact is library-specific, not RN-platform-wide. Discord /
// Slack / Telegram / Mattermost mobile all use background + mono with
// no visible top-heavy issue, confirming this is enriched's bug, not
- // an RN+iOS structural limitation. See:
- // - docs/markdown-rendering-adr.md "Known limitations"
- // - docs/markdown-renderer-research.md decision log 2026-05-19
+ // an RN+iOS structural limitation. See
+ // docs/markdown-rendering-adr.md "Known limitations".
body: 24,
// Heading lineHeights match each heading's fontSize × ~1.3. We MUST
// pass these explicitly: enriched-markdown's heading defaults are
diff --git a/docs/database-index-audit.md b/docs/database-index-audit.md
deleted file mode 100644
index 47f7700480..0000000000
--- a/docs/database-index-audit.md
+++ /dev/null
@@ -1,88 +0,0 @@
-# Database index audit
-
-This report captures the MUL-6108 baseline generated from PostgreSQL 17.10 at
-the branch base `254a02a79` after migrations 001–299. Re-run
-`scripts/audit-redundant-indexes.sql` against a freshly migrated isolated
-database before acting on it; prefix coverage is a candidate signal, not a drop
-decision.
-
-## Baseline
-
-- Public-schema indexes: 346 before this change, 342 after migrations 300–303.
-- Catalog candidates: 24 distinct indexes (32 candidate/covering pairs).
-- Additional B-tree reverse-scan candidate: 1 (`idx_sys_cron_exec_job_plan`).
-- First batch: remove 3 exact duplicates plus the verified reverse-scan
- candidate. Keep all 21 strict-prefix candidates for later production-plan and
- usage analysis.
-- Keep `idx_task_usage_created_at_legacy`: it has a distinct
- `WHERE updated_at IS NULL` predicate and still supports the legacy branch of
- `rollup_task_usage_hourly_window`.
-
-The catalog query requires matching access method, leading keys, opclasses,
-collations, sort options, predicate and index expressions. `exact` rows match on
-the full key; `prefix` rows match only on the candidate's complete left prefix.
-All 24 catalog candidates below are B-tree indexes with no predicate or
-expression; their candidate key columns use the same opclasses, collations and
-sort options as the covering prefix. The `sys_cron` row is the sole ordering
-exception and is documented separately below.
-
-## Complete candidate list
-
-| Table | Candidate | Relation | Covered by | Decision |
-| --- | --- | --- | --- | --- |
-| `agent` | `idx_agent_workspace` | prefix | `agent_workspace_name_unique`, `idx_agent_workspace_id_keyset` | keep pending evidence |
-| `agent_invocation_target` | `agent_invocation_target_agent_id_idx` | prefix | `agent_invocation_target_agent_id_target_type_target_id_key` | keep pending evidence |
-| `agent_runtime` | `idx_agent_runtime_workspace` | prefix | `idx_agent_runtime_status`, `idx_agent_runtime_workspace_id_keyset` | keep pending evidence |
-| `agent_skill` | `idx_agent_skill_agent` | prefix | `agent_skill_pkey` | keep pending evidence |
-| `agent_task_queue` | `idx_agent_task_queue_issue_id` | prefix | `idx_agent_task_queue_issue_id_keyset` | keep pending evidence |
-| `channel_chat_session_binding` | `idx_channel_chat_session_binding_session` | exact | `channel_chat_session_binding_chat_session_id_key` | drop in 302 |
-| `channel_installation` | `idx_channel_installation_workspace` | prefix | `channel_installation_workspace_id_agent_id_channel_type_key` | keep pending evidence |
-| `comment_reaction` | `idx_comment_reaction_comment_id` | prefix | `comment_reaction_comment_id_actor_type_actor_id_emoji_key` | keep pending evidence |
-| `github_installation` | `idx_github_installation_workspace` | prefix | `github_installation_workspace_id_installation_id_key` | keep pending evidence |
-| `github_pull_request` | `idx_github_pull_request_workspace` | prefix | `github_pull_request_workspace_id_repo_owner_repo_name_pr_nu_key` | keep pending evidence |
-| `issue` | `idx_issue_workspace` | prefix | `idx_issue_status`, `idx_issue_workspace_assignee`, `idx_issue_workspace_id_keyset`, `idx_issue_workspace_number`, `idx_issue_workspace_parent`, `idx_issue_workspace_position`, `uq_issue_workspace_number` | keep pending evidence |
-| `issue` | `idx_issue_workspace_number` | exact | `uq_issue_workspace_number` | drop in 300 |
-| `issue_reaction` | `idx_issue_reaction_issue_id` | prefix | `issue_reaction_issue_id_actor_type_actor_id_emoji_key` | keep pending evidence |
-| `lark_chat_session_binding` | `idx_lark_chat_session_binding_session` | exact | `lark_chat_session_binding_chat_session_id_key` | drop in 303 |
-| `lark_installation` | `idx_lark_installation_workspace` | prefix | `lark_installation_workspace_id_agent_id_key` | keep pending evidence |
-| `member` | `idx_member_workspace` | prefix | `member_workspace_id_user_id_key` | keep pending evidence |
-| `runtime_profile` | `idx_runtime_profile_workspace` | prefix | `runtime_profile_workspace_id_display_name_key` | keep pending evidence |
-| `skill` | `idx_skill_workspace` | prefix | `skill_workspace_id_name_key` | keep pending evidence |
-| `skill_file` | `idx_skill_file_skill` | prefix | `skill_file_skill_id_path_key` | keep pending evidence |
-| `squad_member` | `idx_squad_member_squad` | prefix | `squad_member_squad_id_member_type_member_id_key` | keep pending evidence |
-| `task_usage` | `idx_task_usage_task_id` | prefix | `task_usage_task_id_provider_model_key` | keep pending evidence |
-| `vcs_commit_status` | `idx_vcs_commit_status_lookup` | prefix | `vcs_commit_status_pkey` | keep pending evidence |
-| `vcs_connection` | `idx_vcs_connection_workspace` | prefix | `vcs_connection_workspace_id_instance_url_key` | keep pending evidence |
-| `vcs_pull_request` | `idx_vcs_pull_request_connection` | prefix | `vcs_pull_request_connection_id_repo_owner_repo_name_pr_numb_key` | keep pending evidence |
-| `sys_cron_executions` | `idx_sys_cron_exec_job_plan` | reverse scan | `uq_sys_cron_execution` | drop in 301 |
-
-`idx_sys_cron_exec_job_plan` is intentionally outside the strict catalog
-matches: its final key is `plan_time DESC`, while `uq_sys_cron_execution` uses
-the default ascending order. The scheduler constrains the preceding three keys
-by equality, so PostgreSQL can satisfy `ORDER BY plan_time DESC LIMIT 1` with an
-`Index Scan Backward` over the unique index. The migration regression test
-asserts that plan explicitly.
-
-## Rollout and rollback evidence
-
-Each drop is a standalone `DROP INDEX CONCURRENTLY` migration. Its down file is
-a standalone `CREATE INDEX CONCURRENTLY` with the original definition. The
-migration runner now executes a down-direction INVALID-index cleanup hook before
-retrying those creates, so an interrupted rollback cannot be recorded while
-leaving an unusable index.
-
-The isolated regression fixture records the structural before/after comparison:
-
-| Measure | Before | After |
-| --- | ---: | ---: |
-| Public-schema index count | 346 | 342 |
-| Redundant B-tree maintenance per affected insert/indexed-key update | 1 | 0 |
-| Covering/constraint indexes retained | 4 | 4 |
-
-Disk reclaimed in an environment is the sum of `pg_relation_size` for the four
-dropped indexes; it depends on row count and value distribution. The migration
-test measures this sum on its seeded fixture before the drops and verifies that
-all four relations disappear afterward. Production should record those sizes
-before rollout rather than extrapolating a synthetic byte count; the reusable
-audit script intentionally does not hardcode a batch that disappears after the
-cleanup lands.
diff --git a/docs/telegram-channel-review-2026-08-08.md b/docs/telegram-channel-review-2026-08-08.md
deleted file mode 100644
index 47c8dbfe9e..0000000000
--- a/docs/telegram-channel-review-2026-08-08.md
+++ /dev/null
@@ -1,170 +0,0 @@
-# Telegram channel review and validation
-
-Final validation: 2026-08-18
-
-Baseline: `multica-ai/multica` `upstream/main` at `c670e0549`
-
-Contribution branch: `codex/telegram-integration`
-
-## Outcome
-
-Telegram is implemented as a first-class Multica channel for text-message
-workflows. The contribution includes backend transport and lifecycle, secure
-installation and account binding, private/group/forum-topic routing, streamed
-quoted replies, slash commands, issue provenance, settings and agent UI,
-localized setup documentation, landing copy, migrations, and regression tests.
-
-The review found and corrected integration, security, transport, UI, and data
-provenance gaps before this contribution was prepared. External review was
-used as advisory input; all acceptance decisions were made from the current
-source and local verification evidence.
-
-## Completed corrections
-
-- Reject long-polling installation when Telegram has an outgoing webhook;
- Multica does not silently delete another integration's webhook.
-- Sanitize Bot API transport errors so a bot token cannot enter logs or client
- responses.
-- Require authoritative task and channel provenance before sending Telegram
- output, with fail-closed behavior on lookup errors.
-- Keep bearer binding links out of groups and validate the binding token's
- channel type during redemption.
-- Distinguish invalid credentials from network/proxy failure and bound
- credential verification to 15 seconds.
-- Use Telegram's current `reply_parameters` request shape and retain the
- triggering message ID through streamed delivery.
-- Parse mention and command entities with Telegram UTF-16 offsets and exact bot
- username matching.
-- Key streamed output by immutable task ID so simultaneous tasks in one chat
- cannot share accumulated output.
-- Preserve explicitly quoted human-message text/caption and sender attribution
- in group context while keeping the sender's own instruction isolated in
- `CommandText`; `/new` is stripped before enrichment so the selected quote
- remains attached to the fresh instruction, and unaddressed group chatter
- remains uncollected.
-- Share stream throttling and Telegram `retry_after` state per chat in a
- hard-bounded schedule cache. Capacity compression merges active deadlines
- into a conservative per-installation fallback before deleting exact state.
-- Enqueue `EventChatDone` into a fixed-capacity in-process keyed scheduler that
- preserves per-session FIFO order. Fixed workers execute one request step,
- while edit throttles and arbitrary/continuous 429 waits return to a retry
- heap without occupying a worker. If cache pressure compresses exact backoff
- state, other chats under the same Bot installation may be conservatively
- delayed. Global count, per-session count, and total-byte limits reject and
- log overflow without blocking the event bus. Saved chunk progress avoids
- repeating successful sends; ambiguous non-429 transport failures remain
- non-retriable to avoid duplicates.
-- Shutdown cancels in-flight requests, abandons queued and retry-waiting jobs,
- and releases their local stream/schedule references; restart durability
- remains outside the in-process scheduler's contract.
-- Release task stream state on cancellation and retry-pending failures without
- emitting a false terminal failure notice; terminal failures still notify.
-- Enforce Telegram's UTF-16 message size limit, restrict plain-text fallback to
- entity-parsing errors, and prevent duplicate delivery after ambiguous
- transport failures.
-- Provide `/new` and `/issue`, including `@botname` command suffixes, usage
- replies, duplicate-issue handling, and explicit failure responses.
-- Preserve forum-topic IDs for typing indicators, unsupported-media notices,
- session routing, and outbound replies.
-- Fail closed on malformed management responses instead of rendering false
- install or account-binding success.
-- Add Telegram to agent integration visibility, settings, realtime cache
- invalidation, all four product locales, setup documentation, and landing
- release copy.
-- Extend issue-origin validation with `telegram_chat` through migrations 349
- and 350 and verify both migration directions and catalog state.
-
-## Capability comparison
-
-| Channel | Text | Thread/topic | Quote | Typing | Edit/stream | Attachment | Rich card |
-| --- | --- | --- | --- | --- | --- | --- | --- |
-| Lark | yes | yes | yes | yes | yes | yes | yes |
-| Slack | yes | yes | no | no | no | no | no |
-| DingTalk | yes | no | no | no | no | yes | no |
-| WeCom | yes | no | no | no | no | yes | no |
-| Telegram | yes | yes | yes | yes | yes | text-only | no |
-
-Telegram's media behavior is an explicit product boundary, not an accidental
-omission. Addressed non-text input receives a documented response and creates
-no task. Rich cards are Lark-specific and are not a cross-channel requirement.
-
-## Automated verification
-
-The following change-scoped checks passed on the contribution:
-
-- `pnpm typecheck`
-- `pnpm lint` with zero errors (repository warnings unchanged)
-- `pnpm build` for Web, Docs, and Desktop
-- `go test ./internal/migrations -count=1`
-- `go test -race ./internal/integrations/telegram -count=1`
-- `go test ./internal/handler -count=1`
-- focused Telegram settings, binding-page, API-schema, locale-parity, migration,
- install-management, routing, UTF-16, quote, reconnect, and streaming tests
-- `git diff --check`
-- credential-pattern and archive-path scans over the contribution source
-
-The repository-wide TypeScript suite was also exercised in serial mode. It
-completed 364 Views files / 4,325 tests with one unrelated Autopilot dialog
-test timing out; that file then passed 4/4 in an isolated rerun. Focused final
-parity runs covered agent/Telegram settings, locale parity, Telegram binding,
-and core API schemas.
-
-The repository-wide race suite was exercised through `make test`. Every
-Telegram and migration test passed. Five unrelated timing/host-process cases
-in repocache, GitHub snapshot refresh, and channel-media reconciliation failed
-in the concurrent run; all five passed with `-race` in isolated reruns. No
-repository Playwright spec targets Telegram, so the deterministic Bot API
-protocol suite is the relevant E2E boundary for these review corrections.
-
-## Real Telegram verification
-
-Using a local Multica server, migrated local database, local runtime, and an
-existing test bot, the following behaviors were observed against the live
-Telegram Bot API:
-
-- Bot installation and one-time private account binding.
-- Private inbound message -> Multica task -> runtime execution -> streamed
- outbound Telegram reply.
-- `/new` and `/issue`, including bare commands and
- `@multica_channel_bot` suffix forms. The incomplete `/fresh` alias was removed
- in favor of the shared, persisted `/new` contract.
-- Reply quoting through `reply_parameters` for command verdicts and normal
- agent output.
-- A 20-line response, reconnect after server restart, rapid sequential input,
- and a supplementary-plane Emoji response (`TG_UTF16_😀_OK`).
-- A real `/issue TG_ORIGIN_MIGRATION_REAL_20260814` created issue `SYCO-1`; its
- persisted row has `origin_type = 'telegram_chat'` and a non-null `origin_id`.
-- A real 26-byte text-file upload received the documented unsupported-media
- response and created no task.
-- The Desktop agent integration page displayed Telegram with open and
- disconnect actions; “Open in Telegram” launched the configured bot chat.
-
-Private-chat behavior is covered by both live E2E and automated tests.
-Group mention/reply, quoted human-message context, command isolation, and
-forum-topic behavior are covered by deterministic Bot API protocol tests. The
-live account's group chooser contained no isolated test group, so the regression
-deliberately avoided modifying unrelated groups or participants.
-
-## Security and release boundaries
-
-- No bot token, binding URL, Telegram sender/chat ID, API key, private key,
- cookie, browser state, environment file, or database content is stored in
- this contribution or its source archive.
-- The first release is intentionally text-only; unsupported media follows an
- explicit, tested response path.
-- Telegram availability requires deployment reachability to
- `api.telegram.org`; the adapter uses the standard proxy-aware Go transport.
-- A bot token has one active workspace owner, preventing competing long-poll
- consumers.
-- Migrations were applied only to the authorized local test database. No
- production deployment, production configuration, or real-user data action
- was performed.
-
-## Review provenance
-
-External advisory review:
-https://chatgpt.com/c/6a773603-2798-83ec-a368-e298da9da653
-
-The external response was not treated as acceptance evidence. Codex reviewed
-the implementation, applied corrections, and independently ran the checks and
-real Telegram regression recorded above.
diff --git a/packages/views/locales/glossary.md b/packages/views/locales/glossary.md
deleted file mode 100644
index 70eb3f875a..0000000000
--- a/packages/views/locales/glossary.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# Multica i18n 术语表 (Glossary)
-
-> **本文件已迁移**。所有翻译规范、命名规范、中文风格指南现在统一在 docs 站维护:
->
-> - 中文:[`apps/docs/content/docs/developers/conventions.zh.mdx`](../../../apps/docs/content/docs/developers/conventions.zh.mdx)
-> - English: [`apps/docs/content/docs/developers/conventions.mdx`](../../../apps/docs/content/docs/developers/conventions.mdx)
->
-> 翻译 PR 必读那一份文档,不要参考此处。
-
-如果你看到的是 git 历史里的旧版本,对应规则在 docs 站的「Conventions」页面里都能找到,按 `## 2. i18n 翻译术语表` / `## 3. 中文风格` 两段查询。
-
-修改规则只能在 docs 站改,本文件不再维护。
diff --git a/scripts/audit-redundant-indexes.sql b/scripts/audit-redundant-indexes.sql
deleted file mode 100644
index fe9d14ccac..0000000000
--- a/scripts/audit-redundant-indexes.sql
+++ /dev/null
@@ -1,68 +0,0 @@
--- Find valid, non-constraint-backed indexes whose complete key is identical to
--- or a strict left prefix of another index on the same public-schema table.
---
--- This deliberately compares access method, columns/expressions, opclasses,
--- collations, sort options and predicates. It does not decide that a prefix
--- candidate should be dropped: a narrower index can still be materially
--- smaller or have better production usage.
-WITH idx AS (
- SELECT
- i.indexrelid,
- i.indrelid,
- c.relname AS idxname,
- t.relname AS tblname,
- c.relam AS am,
- i.indisunique,
- i.indisprimary,
- (
- SELECT con.conname
- FROM pg_constraint con
- WHERE con.conindid = i.indexrelid
- LIMIT 1
- ) AS conname,
- i.indnkeyatts AS nkey,
- i.indkey::int2[] AS keys,
- i.indcollation::oid[] AS colls,
- i.indclass::oid[] AS opcls,
- i.indoption::int2[] AS opts,
- pg_get_expr(i.indpred, i.indrelid) AS pred,
- pg_get_expr(i.indexprs, i.indrelid) AS exprs,
- pg_get_indexdef(i.indexrelid) AS def
- FROM pg_index i
- JOIN pg_class c ON c.oid = i.indexrelid
- JOIN pg_class t ON t.oid = i.indrelid
- JOIN pg_namespace n ON n.oid = t.relnamespace
- WHERE n.nspname = 'public'
- AND c.relkind = 'i'
- AND i.indisvalid
-)
-SELECT
- a.tblname,
- a.idxname AS redundant_index,
- CASE WHEN a.nkey = b.nkey THEN 'exact' ELSE 'prefix' END AS relation,
- b.idxname AS covered_by,
- CASE
- WHEN b.indisprimary THEN 'pkey'
- WHEN b.conname IS NOT NULL THEN 'constraint'
- WHEN b.indisunique THEN 'unique_idx'
- ELSE 'plain_idx'
- END AS covering_kind,
- a.def AS candidate_definition,
- b.def AS covering_definition
-FROM idx a
-JOIN idx b
- ON a.indrelid = b.indrelid
- AND a.indexrelid <> b.indexrelid
- AND a.am = b.am
-WHERE NOT a.indisunique
- AND a.conname IS NULL
- AND a.nkey <= b.nkey
- AND a.keys[0:a.nkey - 1] = b.keys[0:a.nkey - 1]
- AND a.opcls[0:a.nkey - 1] = b.opcls[0:a.nkey - 1]
- AND a.colls[0:a.nkey - 1] = b.colls[0:a.nkey - 1]
- AND a.opts[0:a.nkey - 1] = b.opts[0:a.nkey - 1]
- AND COALESCE(a.pred, '') = COALESCE(b.pred, '')
- -- Expression columns have indkey=0, so compare the expressions too. Without
- -- this guard, unrelated expression indexes can be reported as duplicates.
- AND COALESCE(a.exprs, '') = COALESCE(b.exprs, '')
-ORDER BY a.tblname, a.idxname, b.idxname;