From cadda28b014c48dfecb5e605b5955330941cb52c Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 13:42:29 +0000 Subject: [PATCH] docs(#2500): Host Feed, Remote Host and device-owned notification preferences Records the grill-with-docs outcome: every client reads every Host, This Host included, through one Host Feed; the Host decides attention and the Paired Device owns its Device Notification Preference; a phone is only a Paired Device. Renames Computer to Remote Host in ADR-0242. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01Asbot1EHttjnKA6hQuCC6r --- CONTEXT.md | 20 +++++++++++++++ CONTEXT.zh.md | 20 +++++++++++++++ ...tent-free-projection-of-the-human-inbox.md | 2 +- ...-computers-through-their-device-gateway.md | 15 +++++------ ...-reads-every-host-through-one-host-feed.md | 25 +++++++++++++++++++ 5 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 docs/adr/0243-every-client-reads-every-host-through-one-host-feed.md diff --git a/CONTEXT.md b/CONTEXT.md index 638328e116..5cd75cdf47 100644 --- a/CONTEXT.md +++ b/CONTEXT.md @@ -929,6 +929,26 @@ _Avoid_: widget, tile, gadget, Panel The RPC surface through which the Web Client reads PersonaBots and invokes separate mutation commands without sharing Host services. _Avoid_: remote, IPC, gateway +**This Host**: +The Host that serves the client page the Human is using (本机). A phone app has no This Host. +_Avoid_: local computer, this computer, local machine + +**Remote Host**: +A Host that a client reaches through device pairing rather than one that serves it (远程). Every Host a phone uses is a Remote Host; for a browser on Host A, Host B is a Remote Host. +_Avoid_: Computer, other computer, machine, server, peer + +**Paired Device**: +A client, a phone app or one browser profile on one origin, holding its own revocable credential from one Host. It reads and acts on that Host but never hosts PersonaBots or relays another Host. +_Avoid_: phone (for all devices), session, Host + +**Host Feed**: +The whole live state one Host serves to one admitted client: roster, avatars, activity, unread state, Human Inbox and conversations. Every client reads every Host, This Host included, through the same Host Feed; new state to sync is a new part of the Host Feed. +_Avoid_: sync, mirror, replica, bridge state + +**Device Notification Preference**: +Which kinds of Human Inbox item one Paired Device wants to be alerted about from one Host. The device owns and stores it; the Host keeps a copy only to decide what to send that device. +_Avoid_: Host notification setting, push settings, mute (for a Channel) + **Bot Settings**: The BotHarness-owned modal (Bot 设置) for profile-wide BotHarness configuration, organised into Bot Settings sections in its own sidebar. Configuration of one PersonaBot or one Channel never lives here; that belongs in Channel settings or the relevant operational Panel. DSH's own settings modal is called DSH settings; its Bot 设置 item only points into Bot Settings, while App credentials remain in DSH settings. _Avoid_: Settings UI, settings page, preferences, admin panel, dashboard, web console diff --git a/CONTEXT.zh.md b/CONTEXT.zh.md index 551d4eed63..e5f3b32b5f 100644 --- a/CONTEXT.zh.md +++ b/CONTEXT.zh.md @@ -926,6 +926,26 @@ _避免使用_:widget、tile、gadget、Panel Web Client 用于读取 PersonaBot 并调用各自独立 mutation command 的 RPC surface,不与 Client 共享 Host service。 _避免使用_:remote、IPC、gateway +**This Host**: +界面中文为“本机”。为 Human 正在使用的客户端页面提供服务的那台 Host。手机 App 没有 This Host。 +_避免使用_:local computer、this computer、本地电脑 + +**Remote Host**: +界面中文为“远程”。客户端通过设备配对连上、而不是为它提供页面的 Host。手机连的每台 Host 都是 Remote Host;对 Host A 上的浏览器来说,Host B 是 Remote Host。 +_避免使用_:Computer、其它电脑、machine、server、peer + +**Paired Device**: +持有某台 Host 发放的独立、可撤销凭据的客户端:一个手机 App,或一个 origin 上的一个浏览器 profile。它读取并操作那台 Host,但从不承载 PersonaBot,也不中转其它 Host。 +_避免使用_:phone(指所有设备时)、session、Host + +**Host Feed**: +一台 Host 向一个已认证客户端提供的全部实时状态:名单、头像、activity、未读、Human Inbox 和会话。每个客户端都通过同一个 Host Feed 读取每一台 Host,包括 This Host;新增要同步的状态,就是给 Host Feed 加一项。 +_避免使用_:sync、mirror、replica、bridge state + +**Device Notification Preference**: +某个 Paired Device 希望某台 Host 就哪些 Human Inbox 项提醒它。偏好由设备拥有并保存;Host 只保留一份副本,用来决定给这台设备发什么。 +_避免使用_:Host 通知设置、push settings、mute(指 Channel 时) + **Bot Settings**: BotHarness 自有的 modal(Bot 设置),承载 profile 级的 BotHarness 配置,按自己 sidebar 中的 Bot Settings section 组织。单个 PersonaBot 或单个 Channel 的配置不在这里,而属于频道设置或对应的运行操作面板。DSH 自带的设置 modal 称为 DSH settings;其中的 Bot 设置 项只负责指向 Bot Settings,App 凭据仍留在 DSH settings。 _避免使用_:Settings UI、settings page、preferences、admin panel、dashboard、web console diff --git a/docs/adr/0202-phone-push-is-a-content-free-projection-of-the-human-inbox.md b/docs/adr/0202-phone-push-is-a-content-free-projection-of-the-human-inbox.md index 1a0db1cfdf..d3264b7d80 100644 --- a/docs/adr/0202-phone-push-is-a-content-free-projection-of-the-human-inbox.md +++ b/docs/adr/0202-phone-push-is-a-content-free-projection-of-the-human-inbox.md @@ -1,5 +1,5 @@ --- -Status: Superseded in part by ADR-0213 +Status: Superseded in part by ADR-0213 and ADR-0243 Date: 2026-10-14 Issues: [#1655](https://github.com/BotHarness/DeepSeekBot/issues/1655), [#1646](https://github.com/BotHarness/DeepSeekBot/issues/1646), [#1643](https://github.com/BotHarness/DeepSeekBot/issues/1643) --- diff --git a/docs/adr/0242-a-browser-pairs-other-computers-through-their-device-gateway.md b/docs/adr/0242-a-browser-pairs-other-computers-through-their-device-gateway.md index 2ad0157215..77d315f5b7 100644 --- a/docs/adr/0242-a-browser-pairs-other-computers-through-their-device-gateway.md +++ b/docs/adr/0242-a-browser-pairs-other-computers-through-their-device-gateway.md @@ -4,22 +4,23 @@ Date: 2026-10-21 Issues: [#2500](https://github.com/BotHarness/DeepSeekBot/issues/2500), [#2180](https://github.com/BotHarness/DeepSeekBot/issues/2180), [#2178](https://github.com/BotHarness/DeepSeekBot/issues/2178) --- -# A browser pairs other Computers through their device gateway +# A browser pairs Remote Hosts through their device gateway -The Web Client serves exactly one Host. The Human wants its channel list to work like the phone's (#2194): **All** by default, then one tab per Computer, with chats from another Computer on the tailnet listed, opened and answered in the same browser. Spec #2178 already fixes the authority split: each Computer owns its conversations, and a client's connections belong to that client (browser profile plus origin), never to a Host setting. +The Web Client serves exactly one Host. The Human wants its channel list to work like the phone's (#2194): **All** by default, then one tab per Host, with chats from a Remote Host on the tailnet listed, opened and answered in the same browser. Spec #2178 already fixes the authority split: each Host owns its conversations, and a client's connections belong to that client (browser profile plus origin), never to a Host setting. -We decided that **the browser pairs another Computer exactly like a phone does, and talks to it directly with that per-device credential.** The other Host admits the cross-origin calls on its device gateway (ADR-0199); the serving Host never relays or stores the credential. +We decided that **the browser pairs a Remote Host exactly like a phone does, and talks to it directly with that per-device credential.** The Remote Host admits the cross-origin calls on its device gateway (ADR-0199); the serving Host never relays or stores the credential. ## Decision -- **Same pairing, same credential.** The Human copies the pairing link from the other Computer's Settings → Devices → Pair a phone and pastes it into **Add computer** in the channel list. The browser redeems the offer at `/botharness-device/pair` and keeps the returned device record in `localStorage` of the serving origin. The other Computer lists it as one more paired device ("Browser on …") and can revoke it there. +- **Same pairing, same credential.** The Human copies the pairing link from the Remote Host's Settings → Devices → Pair a phone and pastes it into **Add remote** in the channel list. The browser redeems the offer at `/botharness-device/pair` and keeps the returned device record in `localStorage` of the serving origin. The Remote Host lists it as one more paired device ("Browser on …") and can revoke it there. - **CORS only for header-authenticated paths.** The gateway answers cross-origin `pair`, `unpair`, `stream-ticket` and unary `/botharness-device/api/*` requests, including the preflight, only when the `Origin` is itself a Host-shaped address (loopback, Tailscale HTTPS or the Connect domain, the same check as phone routes) and the request carries no cookie. The cookie-authenticated full Web Client (`/botharness-device/web/`) stays same-origin. Responses echo that origin with `Vary: Origin` and never allow credentials, so a page needs the device secret itself; ambient cookies never authorize a cross-origin call. - **Stream tickets.** Browsers cannot put an `Authorization` header on a WebSocket. The browser first `POST`s `/botharness-device/stream-ticket` with its credential and opens `/botharness-device/api/remote.mux?ticket=…`. A ticket is random, stored only as a hash, bound to the device, valid for 30 seconds and spent on first use; the device is checked again when it is used, so revocation still closes streams and refuses new ones. Phones keep the header form. - **One client implementation.** The Web Client reuses the phone's Host client, pairing and conversation modules (`apps/mobile/src/host/`) behind a browser carrier, so wire handling, reconnects, drafts and sends stay one code path. -- **Source-scoped state.** Conversations are keyed by Computer and conversation, so the same Bot slug or Channel ID on two Computers never shares a draft, history or send. Removing a Computer revokes this browser there and drops its cached conversations. +- **Source-scoped state.** Conversations are keyed by Host and conversation, so the same Bot slug or Channel ID on two Hosts never shares a draft, history or send. Removing a Remote Host revokes this browser there and drops its cached conversations. ## Consequences -- The first slice shows each other Computer as its own section under All and as its own tab; it does not merge them into one recency-sorted list, show images or cards, or sync read state. Those follow in later #2180 slices. -- The Computer look (icon and colour) is still stored per phone, so the Web Client uses a generic computer icon. +- The first slice shows each Remote Host as its own section under All and as its own tab; it does not merge them into one recency-sorted list, show images or cards, or sync read state. Those follow in later #2180 slices. +- The Host look (icon and colour) is still stored per phone, so the Web Client uses a generic icon. +- Terminology follows ADR-0243: This Host and Remote Host, 本机 and 远程 in Chinese; "Computer" stays reserved for the PersonaBots' shared desktop. - DSH Desktop is not qualified by this slice; its storage and origin rules are verified separately (#2180). diff --git a/docs/adr/0243-every-client-reads-every-host-through-one-host-feed.md b/docs/adr/0243-every-client-reads-every-host-through-one-host-feed.md new file mode 100644 index 0000000000..fd8e2e4bd7 --- /dev/null +++ b/docs/adr/0243-every-client-reads-every-host-through-one-host-feed.md @@ -0,0 +1,25 @@ +--- +Status: Accepted +Date: 2026-10-21 +Issues: [#2500](https://github.com/BotHarness/DeepSeekBot/issues/2500), [#2180](https://github.com/BotHarness/DeepSeekBot/issues/2180) +Supersedes: ADR-0202's Host-owned per-kind switches +--- + +# Every client reads every Host through one Host Feed, and notification preferences belong to the device + +A phone and a browser can now both reach Remote Hosts (ADR-0242), but the Web Client still reads This Host through its own bridge and store while phones and Remote Hosts go through the Host client and Remote stream. Every new piece of synced state (avatars, activity, unread, Activity Center) had to be built twice, and it was unclear who decides a notification when one device is paired with several Hosts. We decided that **every client reads every Host, This Host included, through one Host Feed; the Host decides what deserves attention; the Paired Device decides whether it is alerted.** + +## Decision + +- **One Host Feed.** The live state a Host serves to an admitted client (roster, avatars, activity, unread state, Human Inbox, conversations) is one contract over the device gateway and Remote stream. New state to sync is added to the Host Feed once; phone, browser and Desktop pick it up through the shared Host client (`apps/mobile/src/host/`). +- **This Host migrates in slices.** The Web Client moves its reads of This Host onto the Host Feed one area at a time: avatars, activity and unread first, then Activity Center. No single rewrite; until a slice moves, the bridge keeps serving it. +- **The Host decides attention.** What deserves a notification comes from that Host's Human Inbox, as ADR-0202 already does for phones. A client never re-derives attention from raw messages. +- **The device owns its Device Notification Preference.** Device A stores which kinds of item it wants from each Host and is the place the Human changes them. Because a Host sends phone pushes while the app is closed, A pushes a copy to each Host it is paired with; the Host uses that copy only to decide sends. After a re-pairing, A pushes its preference again. +- **A phone is only ever a Paired Device.** It never hosts PersonaBots. A browser on Host A is a Paired Device of Host B; A never relays B or stores B's credential. +- **Browser alerts while open.** The Web Client shows Remote Host alerts with browser notifications only while the page is open, honouring the Device Notification Preference. Web Push for a closed page is a later decision. +- **Language.** The glossary uses This Host and Remote Host; the Chinese UI says 本机 and 远程, never 电脑, so the Computer (the PersonaBots' shared desktop) keeps its meaning. + +## Consequences + +- The Remote Host slices (avatars, activity rings, unread counts, Activity Center items) are built once on the Host Feed and also serve This Host as it migrates. +- The device push settings endpoint becomes a write of the device's own preference; existing Host-stored switches are the initial copy until the device first pushes its own.