Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3114-manual-unread-open.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**Mark as Unread** on the chat you are already reading now keeps its unread dot until you leave that chat and open it again, instead of clearing itself at once ([#3114](https://github.com/ThinkFlowLab/FlyBot/issues/3114)).
7 changes: 5 additions & 2 deletions core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10902,9 +10902,12 @@ var import_react21 = require("react");
var import_react_dom4 = require("react-dom");
var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
function useMarkedUnread(id, active, marked, actions) {
const wasActive = (0, import_react21.useRef)(false);
(0, import_react21.useEffect)(() => {
if (active && marked) actions.clearUnread(id);
}, [active, marked]);
const opened = marked && active && !wasActive.current;
wasActive.current = active;
if (opened) actions.clearUnread(id);
}, [active, marked, id]);
}
var PinMark = () => (0, import_react21.createElement)("span", { className: "bt-pin", "aria-hidden": true }, (0, import_react21.createElement)(PinMarkIcon));
var useApproval = (useWork, match) => useWork ? useWork((work) => (work.approvals ?? []).some(match)) : false;
Expand Down
10 changes: 7 additions & 3 deletions core/src/client/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ import { ProjectsNav } from './projects-nav.js'
// -------------------------------------------------------------------------
// Sidebar

// Manual "Mark as Unread" lasts until the conversation is opened again.
// Manual "Mark as Unread" is a local mark: opening the conversation clears it, and a
// mark made on the conversation already on screen lasts until it is left and opened again.
function useMarkedUnread(id, active, marked, actions) {
const wasActive = useRef(false)
useEffect(() => {
if (active && marked) actions.clearUnread(id)
}, [active, marked])
const opened = marked && active && !wasActive.current
wasActive.current = active
if (opened) actions.clearUnread(id)
}, [active, marked, id])
}

const PinMark = () => h('span', { className: 'bt-pin', 'aria-hidden': true }, h(PinMarkIcon))
Expand Down
129 changes: 129 additions & 0 deletions core/test/sidebar-manual-unread.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Manual "Mark as Unread" clears when the conversation is opened again, not in the pass
// that marks the conversation already on screen (#3114).
import assert from 'node:assert/strict'
import { test } from 'node:test'
import { fileURLToPath } from 'node:url'
import { runInNewContext } from 'node:vm'
import { build } from 'esbuild'

const { outputFiles } = await build({
stdin: { contents: "export { TeamSidebar } from './src/client/sidebar.js'", resolveDir: fileURLToPath(new URL('..', import.meta.url)) },
bundle: true, format: 'cjs', platform: 'browser', write: false, logLevel: 'silent',
external: ['react', 'react-dom', '@deepseek-ai/dsh-client-ui-primitives'],
})
const h = (type, props, ...children) => ({ type, props: { ...props, children: children.flat(Infinity) } })
const same = (a, b) => Boolean(a && b) && a.length === b.length && a.every((value, i) => Object.is(value, b[i]))
let slots = []
let effects = []
let pending = []
let index = 0
const react = {
createElement: h, Component: class {}, Fragment: Symbol('F'),
useMemo: (fn, deps) => { const at = index++; if (!(at in slots) || !same(slots[at].deps, deps)) slots[at] = { deps, value: fn() }; return slots[at].value },
useState: (initial) => { const at = index++; if (!(at in slots)) slots[at] = typeof initial === 'function' ? initial() : initial; return [slots[at], (value) => { slots[at] = typeof value === 'function' ? value(slots[at]) : value }] },
useCallback: (fn) => fn,
useRef: (value) => { const at = index++; if (!(at in slots)) slots[at] = { current: value }; return slots[at] },
// Effects whose deps changed are recorded here and run after the draw, the way React runs
// them after a commit; refs and memos keep their value from one draw to the next.
useEffect: (fn, deps) => { const at = index++; if (!(at in effects) || !same(effects[at].deps, deps)) { effects[at] = { deps, cleanup: effects[at]?.cleanup }; pending.push([at, fn]) } },
useLayoutEffect: () => {},
useSyncExternalStore: (_subscribe, get) => get(),
}
const win = { location: { hash: '' }, innerHeight: 800, addEventListener() {}, removeEventListener() {}, matchMedia: () => ({ matches: false, addEventListener() {}, removeEventListener() {} }) }
const module = { exports: {} }
runInNewContext(outputFiles[0].text, {
module, exports: module.exports, console, setTimeout, clearTimeout, setImmediate, queueMicrotask,
requestAnimationFrame: () => 0, cancelAnimationFrame() {},
Date, JSON, Promise, Symbol, Map, Set,
document: { hidden: false, addEventListener() {}, removeEventListener() {}, body: {}, querySelector: () => null },
navigator: { language: 'en' },
localStorage: { getItem: () => null, setItem() {} },
window: win,
__flybot__: { slots: { entries: () => [], subscribe: () => () => {}, version: () => 0 }, call: () => {} },
require: (name) => {
if (name === 'react') return react
if (name === 'react-dom') return { createPortal: node => node }
if (name === '@deepseek-ai/dsh-client-ui-primitives') return {}
throw new Error(`Unexpected platform module ${name}`)
},
})
const { TeamSidebar } = module.exports
const chief = { id: 'chief', name: 'Chief' }
const writer = { id: 'writer', name: 'Writer' }
const roster = { ready: true, bots: [chief, writer], rooms: [], agents: [], byId: { chief, writer }, roomsById: {}, exchangeTurns: {}, mainBotId: 'chief' }
const sessions = { ids: ['chief', 'writer'], byId: { chief: { updatedAt: 2 }, writer: { updatedAt: 1 } } }
// The rows this file measures, without the parts each row draws below itself.
const rows = (node, out = []) => {
if (Array.isArray(node)) { for (const item of node) rows(item, out); return out }
if (!node || typeof node !== 'object') return out
if (typeof node.type === 'function') { if (node.type.name === 'BotRow') out.push([node.type, node.props]); return out }
rows(node.props?.children, out)
return out
}

// What the two readers say this draw: the manual marks, and which conversation the main
// view holds (`retainedBy.mainView` is what each row reads as "active").
const live = { unread: {}, retain: {} }
let calls = []
const mount = () => {
slots = []; effects = []; pending = []; calls = []; live.unread = {}; live.retain = {}
return () => {
index = 0
pending = []
for (const [row, props] of rows(TeamSidebar({
wide: true,
useRoster: select => select(roster),
useUi: select => select({ unread: live.unread }),
useSessions: select => select(sessions),
useRegistry: () => {},
useUpdate: select => select({}),
useWork: select => select({}),
useSessionStatus: select => select(new Map()),
useSessionRetainInfo: (key, select) => select(live.retain[key]),
useActivity: select => select({}),
actions: {
openInbox() {}, openBoard() {}, openPalette() {}, openNewChat() {}, landOn() {},
clearUnread: id => calls.push(id), isAgentSession: () => false,
},
}))) row(props)
for (const [at, fn] of pending) {
if (effects[at].cleanup) effects[at].cleanup()
const cleanup = fn(); effects[at].cleanup = typeof cleanup === 'function' ? cleanup : undefined
}
pending = []
}
}
const OPEN = { writer: { retainedBy: { mainView: 1 } } }

test('#3114: a mark made on the chat already on screen stays while it stays open', () => {
const draw = mount()
live.retain = OPEN
draw() // the chat is open, not yet marked
live.unread = { writer: true }
draw() // Mark as Unread pressed on that chat
draw() // it stays open
assert.deepEqual(calls, [], 'the open chat mark was cleared while it stayed open')
})

test('#3114: opening a chat that was already marked unread clears the mark once', () => {
const draw = mount()
live.unread = { writer: true }
draw() // marked while another chat is on screen
live.retain = OPEN
draw() // opened
draw() // and stays open
assert.deepEqual(calls, ['writer'])
})

test('#3114: leaving and coming back clears the mark that was made while the chat was open', () => {
const draw = mount()
live.retain = OPEN
draw() // the chat is open, not yet marked
live.unread = { writer: true }
draw() // marked while it stays open
live.retain = {}
draw() // leave: nothing is cleared on the way out
live.retain = OPEN
draw() // back in: cleared once
assert.deepEqual(calls, ['writer'], 'the mark is cleared on the way back in, not while open')
})
2 changes: 1 addition & 1 deletion docs/subsystems/core-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ The overlay (`flybot-slots.js` `FlyBotApprovals`) is the fallback, not a second
- An own Bot's settings (`BotSettingsForm`) draw the `flybot.bot.details` entries once, as a titled **Sharing** card right after **Instructions** (`FlyBotDetails` with `wrap` → `Card`), so sharing is not at the end of the page; with no entry there is no card. Bot settings and group settings both end with a **More** card (Duplicate / Delete). A write the host refuses is reported on the dialog's own line under its heading, outside the page's scrolling box: `SettingsDialog` owns the sentence `run` stores, and `.bt-settings-scroll` no longer holds it, so scrolling down to the control that was pressed cannot leave the refusal above the viewport with the switch apparently unmoved ([#2194](https://github.com/ThinkFlowLab/FlyBot/issues/2194)). A window that holds the team read-only says so in that same header: `SettingsDialog` prints the host's own sentence from `roster.readOnly` as a `role="status"` line under the heading and above the refused-write line, so the standing state comes first and the answer to one pressed control sits closest to it, and a blank or missing `readOnly` draws nothing at all (#2199). The details drawer's own Settings view is not that dialog and had no header sentence: it now reads the same window lock (`lockedWindow`, `schedules.js`) and, in a read-only window, draws the host's sentence in the form's place instead of mounting `BotSettingsForm` or `GroupSettingsForm`, so no write control the host would refuse is drawn for a Bot or a group, and a writable window keeps the form unchanged (#2387). A refused write in that view follows the same rule as the dialog (#2385): the `bt-error` line is a sibling above `bt-drawer-body bt-set-body`, not its first child, so a press at the bottom of the group page — Pin, Hide, Make admin, Remove — writes the host's refusal where the press happened instead of at the top of the box it was scrolled past. The drawer's overview view holds the same two rules: its refusal line is a sibling above `bt-drawer-body`, and in a read-only window the Bot's name is plain text with no model, permission or working-folder control beside it, above a `role="status"` line carrying the host's own sentence, so the overview offers only what the host will not refuse. Since P-547 those three cards keep their titles and their saved values as plain text as well (`ReadOnlyOverview`: the model's name and provider, the permission preset's label, the working folder's last segment with the full path as its `title`), because the window refuses the writes, not the reading — a value that vanishes with its control leaves the page saying less than the host knows; a writable window keeps every control and draws none of those values twice. Tests: `core/test/details-overview-readonly.test.js`. A group's overview follows it (#2391 left it to P-544): the name is plain text with no rename control, `Remove my Bot` is gone, and the host's one sentence sits above the reads — a shared room's approval card keeps its headline and rows and drops its decisions — while a writable window keeps every control. Tests: `core/test/details-bot-settings-readonly.test.js`, `core/test/details-drawer-refusal-line.test.js`, `core/test/details-overview-readonly.test.js`, `core/test/details-group-overview-readonly.test.js`. The composer card's `:focus-within` border is 55% ink, hover stays 30% (#406). Keyboard Tab order, checked in headless Chrome on a mock bench (#406): sidebar (Search, New…, the Bots, Connect apps, Account) → chat header pill → message box → Add, Dictate, voice → the turn stats; the `shell.overlay` layer (approval cards) comes after the main column in the DOM, and no stop focuses an invisible element. The message box comes before **+** because DSH's DOM puts the input first and FlyBot's CSS only reorders it visually.
- Settings → **Projects** (`ProjectsPage` and `ProjectsList` in `settings.js`) draws the write half of the Project record: a name field, **New Project**, a **Bind to {name}** choice on every Project row and **Unbind** on every binding. In a window that holds the team read-only (`lockedWindow`, `schedules.js`) none of them is drawn, because the host refuses `project-create` and `project-bind`; **Open board**, the Project rows with their names and working folders, and the members already bound stay readable, and a writable window is unchanged. With no Project at all the read-only page says only that there is none (`No Project yet.`) instead of inviting a creation the page no longer offers, while a writable window keeps the shared `No Project yet — create one.` the Project board also uses (#2489). Tests: `core/test/project-settings-page.test.js`.
- The rest of Settings follows that lock (#2474): `GeneralPage`, `MainBotsSection` and `MotionSection` in `settings.js`, `BotSettingsForm` (`bot-settings.js`), `GroupSettingsForm` (`group-settings.js`), `ConnectorsPage` (`connectors.js`), `CapabilitiesPage` (`capability-settings.js`) and `SecretsPage` (`secret-card.js`) each read the same `lockedWindow(roster)` and, in a read-only window, draw no `select`, `input`, switch or component that would render one — every one of them asked for `set-prefs`, `set-main`, `update-bot`, `update-room`, a `connector-*` write, `save-capability`/`delete-capability` or a `secret-*` write, which the host refuses with `bot/read-only`. The facts stay as text: the theme and the accent in use, the notification state, the Main Bots and the animation setting, a Bot's role, model, working folder and instructions, a group's members, admin and notice (in a face-to-face room each person's Bots are named under that person; the page states who answers and the working folder for every group, face-to-face or plain, since #2492 and #2528), each connector's own state sentence, each capability's description and each stored key's name with who may use it. Entries that only navigate stay — **New Bot**, whose form explains the lock itself since #2465, and a row that opens a Bot's or a group's page — and the standing sentence is still the dialog header's, drawn once above the page and never again inside it. A writable window is unchanged. Tests: `core/test/settings-readonly-pages.test.js`.
- Every listed Bot row in wide sidebar mode is a `bt-row-wrap`: the session `bt-row` and a sibling gear (`bt-row-settings`, hover/focus) that opens Edit Bot for an own Bot or Bot settings for a friend's (#166, #276).
- Every listed Bot row in wide sidebar mode is a `bt-row-wrap`: the session `bt-row` and a sibling gear (`bt-row-settings`, hover/focus) that opens Edit Bot for an own Bot or Bot settings for a friend's (#166, #276). A manual **Mark as Unread** is a local mark cleared when that conversation is opened; one made on the chat already on screen lasts until it is left and opened again ([#3114](https://github.com/ThinkFlowLab/FlyBot/issues/3114)).
- The Session header is the shell's own: FlyBot registers the Bot pill in `conversation.session.header.utilities` rather than claiming the single `conversation.session.header` slot, so the seats that header renders — the lineage title and `conversation.session.header.actions`, where `@deepseek-ai/ui-subagent` puts the subagent catalog — keep rendering (#803). The floating header style FlyBot used to draw over the Session header is gone.
- What the pill does to the page is not in the pill and not in a seat of its own (#803). The shell draws `.utilities` — and the pill with it — only while its chrome shows, which a Session without a first message hides, so a side effect parked in the pill stops there: the friend's empty-chat hint, `body[data-bt-friend-chat]`, the `Message {name}` composer label, the visit ledger, `body[data-bt-room]` and the face-room `@` filter. `installHeaderEffects` (`src/client/header-effects.js`) is installed once from `apply` and keeps them on the Session in the main view. It carries no React, and each effect has its own dependency key: the sessions list answers before the roster, so a single "did the Session change" guard would drop a friend's flags on the first pass, while `beginVisit`/`endVisit` keyed on more than the Session would open a second visit for a chat that was only just opened. `test/header-effects.test.js` drives those transitions on jsdom; `test/header-slot.test.js` pins that no such effect runs in `HeaderPill` and that FlyBot claims no other header seat.
- `conversation.session.header.corner` is **not** available as that seat: it is `single` and `ui-sidebar-right` already registers its right-sidebar button there with no `priority` (0), and `SlotCore.register` throws on a second registration in the same cell (`single slot "…" already has a registration at priority 0`), which would fail FlyBot's whole client plugin from `apply`. Only `--bt-first-sep` still rides the pill, because it needs a turn and so always has a header to be drawn in.
Expand Down
18 changes: 17 additions & 1 deletion patches/ds-bot/0003-flybot-api-client.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3110,7 +3110,7 @@ diff --git a/src/client/questions.js b/src/client/questions.js
diff --git a/src/client/sidebar.js b/src/client/sidebar.js
--- a/src/client/sidebar.js
+++ b/src/client/sidebar.js
@@ -1,16 +1,23 @@
@@ -1,25 +1,36 @@
-import { createElement as h, Fragment, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from 'react'
+import { FlyBotSections, FlyBotAccountHeader, useSidebarStructure, botTree } from './flybot-slots.js'
+import { Component, createElement as h, Fragment, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
Expand All @@ -3137,6 +3137,22 @@ diff --git a/src/client/sidebar.js b/src/client/sidebar.js

// -------------------------------------------------------------------------
// Sidebar

-// Manual "Mark as Unread" lasts until the conversation is opened again.
+// Manual "Mark as Unread" is a local mark: opening the conversation clears it, and a
+// mark made on the conversation already on screen lasts until it is left and opened again.
function useMarkedUnread(id, active, marked, actions) {
+ const wasActive = useRef(false)
useEffect(() => {
- if (active && marked) actions.clearUnread(id)
- }, [active, marked])
+ const opened = marked && active && !wasActive.current
+ wasActive.current = active
+ if (opened) actions.clearUnread(id)
+ }, [active, marked, id])
}

const PinMark = () => h('span', { className: 'bt-pin', 'aria-hidden': true }, h(PinMarkIcon))
@@ -37,77 +37,151 @@ const workKeys = text => (text === '' ? [] : text.split(',').map((key) => {
}))
const workLine = (lead, tool, more) => h(Shimmer, null, `${lead} · ${workPhrase(tool)}…${more > 0 ? ` +${more}` : ''}`)
Expand Down
Loading
Loading