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-unread-mark-menu.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**Clear unread mark** is now offered on a chat that is already marked unread — in its row menu and in the conversation header — so the local mark can be cleared without opening the chat, and clearing it does not acknowledge system unread ([#3114](https://github.com/ThinkFlowLab/FlyBot/issues/3114)).
36 changes: 31 additions & 5 deletions core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ var ZH = {
Pin: "置顶",
Pinned: "已置顶",
"Mark as Unread": "标为未读",
"Clear unread mark": "清除手动未读标记",
"Group settings": "群设置",
"Rename group": "重命名群聊",
"Copy conversation ID": "复制对话 ID",
Expand Down Expand Up @@ -5286,6 +5287,10 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}
.bt-pill[aria-expanded=true] .bt-pill-go svg{transform:rotate(180deg)}
.bt-pill[data-memory=updated]:is(:hover,:focus-visible,[aria-expanded=true]) .bt-pill-go{width:0;margin-left:-8px;opacity:0;filter:blur(6px);transform:translateX(-6px)}
@media (prefers-reduced-motion:reduce){.bt-pill,.bt-pill-go,.bt-pill-go svg{transition:none!important}.bt-pill-go{filter:none}.bt-pill:active{transform:none}}
.bt-head-unread{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:50%;background:none;color:var(--bt-ink-3);cursor:pointer}
.bt-head-unread:hover{background:var(--bt-hover);color:var(--bt-ink)}
.bt-head-unread[aria-pressed=true]{color:var(--bt-accent)}
.bt-head-unread svg{width:15px;height:15px}

.bt-astack{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin:0}
.bt-bubble{max-width:min(80%,560px,calc(100% - 82px));background:var(--bt-bubble);color:var(--bt-ink);border-radius:18px;padding:7px 12px;font-size:var(--dsh-content-font-size,14px);line-height:calc(var(--dsh-content-font-size,14px) + 8px);box-sizing:border-box;overflow-wrap:anywhere}
Expand Down Expand Up @@ -13161,6 +13166,24 @@ function MemoryNotice({ shown }) {
(0, import_react24.createElement)("span", { className: "bt-pill-mem-in", ref: inner }, (0, import_react24.createElement)("span", { className: "bt-pill-mem-ico" }, (0, import_react24.createElement)(MemoryIcon)), label)
);
}
function unreadEntryId(roster, sessionId) {
const bot = roster?.byId?.[sessionId];
const room2 = roster?.roomsById?.[sessionId];
return bot?.id ?? room2?.id ?? roster?.agentOf?.[sessionId] ?? sessionId;
}
function SessionUnreadToggle({ sessionId, roster, unread, actions }) {
const target = unreadEntryId(roster, sessionId);
const marked = unread?.[target] === true;
const label = marked ? t("Clear unread mark") : t("Mark as Unread");
return (0, import_react24.createElement)("button", {
type: "button",
className: "bt-head-unread",
"aria-pressed": marked,
"aria-label": label,
title: label,
onClick: () => marked ? actions.clearUnread(target) : actions.markUnread(target)
}, (0, import_react24.createElement)(UnreadIcon));
}
function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus, useSession, useActivity, useBusyAcks, useMemoryNews, useTurnClock, useUi, useLive, actions }) {
const roster = useRoster((value) => value);
const title = useSessions((list) => list.byId[sessionId]?.displayTitle ?? list.byId[sessionId]?.title ?? "");
Expand All @@ -13170,6 +13193,7 @@ function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus, useSe
});
const hiddenTurns = roster.exchangeTurns?.[sessionId];
const visit = useUi((state) => state.visits?.[sessionId]);
const unread = useUi((state) => state.unread);
const opening = useTurnClock((state) => {
const first = openingTurn(state[sessionId], firstTurns, hiddenTurns);
return first && !unseenSince(visit, first.start) ? clockLabel(first.start) : "";
Expand Down Expand Up @@ -13220,7 +13244,8 @@ function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus, useSe
}),
(0, import_react24.createElement)(NewMessagePills, { key: sessionId, sessionId, hiddenTurns, useSessions, useUi, useTurnClock, actions }),
(0, import_react24.createElement)(ActivityIndicator, { key: `activity:${sessionId}`, sessionId, useRoster, useSessionStatus, useSession, useLive, actions }),
(0, import_react24.createElement)(BusyAckBubble, { key: `busy-ack:${sessionId}`, sessionId, useRoster, useBusyAcks, useSessionStatus, useSession, useLive })
(0, import_react24.createElement)(BusyAckBubble, { key: `busy-ack:${sessionId}`, sessionId, useRoster, useBusyAcks, useSessionStatus, useSession, useLive }),
(0, import_react24.createElement)(SessionUnreadToggle, { sessionId, roster, unread, actions })
);
}
function useTranscriptView() {
Expand Down Expand Up @@ -20903,7 +20928,7 @@ function ProjectsPage({ roster, actions, run, call: call4 }) {

// src/client/context-menu.js
var import_react46 = require("react");
function ContextMenu({ menu, roster, actions, leaving = false }) {
function ContextMenu({ menu, roster, actions, leaving = false, unread }) {
useEscape(() => actions.closeMenu());
(0, import_react46.useEffect)(() => {
const onDown = (event) => {
Expand All @@ -20925,13 +20950,14 @@ function ContextMenu({ menu, roster, actions, leaving = false }) {
const room2 = roster.roomsById[menu.id];
const entry = bot ?? room2;
if (entry === void 0) return null;
const unreadItem = unread?.[menu.id] === true ? [t("Clear unread mark"), UnreadIcon, () => actions.clearUnread(menu.id)] : [t("Mark as Unread"), UnreadIcon, () => actions.markUnread(menu.id)];
const isMainBot = isMainOf(roster, menu.id);
const isTile = roster.mainBotId === menu.id;
const mainCount = (roster.mainBotIds ?? []).length;
const locked = typeof roster?.readOnly === "string" && roster.readOnly.trim() !== "";
const groups = bot?.remote ? [
[
[t("Mark as Unread"), UnreadIcon, () => actions.markUnread(menu.id)]
unreadItem
],
[
[t("Bot settings"), GearIcon, () => actions.openSettings("bots", bot.id)]
Expand All @@ -20941,7 +20967,7 @@ function ContextMenu({ menu, roster, actions, leaving = false }) {
] : [
[
isTile || locked ? null : [entry.pinned ? t("Unpin") : t("Pin"), PinIcon, () => actions.setFlags(menu.id, { pinned: !entry.pinned })],
[t("Mark as Unread"), UnreadIcon, () => actions.markUnread(menu.id)]
unreadItem
],
[
// One way to edit a Bot (#385): its name is edited in Edit Bot too.
Expand Down Expand Up @@ -22374,7 +22400,7 @@ function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useActivity
ui2.palette ? (0, import_react_dom11.createPortal)((0, import_react50.createElement)(CommandPalette, { key: ui2.palette.token, start: ui2.palette.query, token: ui2.palette.token, roster, actions, useSessions }), document.body) : null,
ui2.exchange ? (0, import_react_dom11.createPortal)((0, import_react50.createElement)(ExchangeDialog, { pair: ui2.exchange, roster, actions }), document.body) : null,
ui2.voice ? (0, import_react_dom11.createPortal)((0, import_react50.createElement)(VoiceMode, { key: ui2.voice, sessionId: ui2.voice, roster, actions, useSessions, useSessionStatus }), document.body) : null,
menu ? (0, import_react_dom11.createPortal)((0, import_react50.createElement)(ContextMenu, { key: `${menu.kind ?? ""}:${menu.id}:${menu.x}:${menu.y}`, menu, roster, actions, leaving: menuLeaving }), document.body) : null,
menu ? (0, import_react_dom11.createPortal)((0, import_react50.createElement)(ContextMenu, { key: `${menu.kind ?? ""}:${menu.id}:${menu.x}:${menu.y}`, menu, roster, actions, unread: ui2.unread, leaving: menuLeaving }), document.body) : null,
settings ? (0, import_react_dom11.createPortal)((0, import_react50.createElement)(SettingsDialog, { page: settings.page, id: settings.id, roster, actions, useUpdate, leaving: settingsLeaving }), document.body) : null,
remoteBotSettings ? (0, import_react_dom11.createPortal)((0, import_react50.createElement)(RemoteBotSettingsSheet, { key: remoteBotSettings, bot: roster.byId[remoteBotSettings], roster, actions, leaving: remoteLeaving }), document.body) : null,
memory && roster.byId[memory] ? (0, import_react_dom11.createPortal)((0, import_react50.createElement)(MemoryDialog, { key: memory, bot: roster.byId[memory], roster, actions, leaving: memoryLeaving }), document.body) : null,
Expand Down
11 changes: 8 additions & 3 deletions core/src/client/context-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useSidebarStructure } from './flybot-slots.js'
import { pluginItems } from './flybot-registry.js'
import { LinkIcon } from './icons.js'

export function ContextMenu({ menu, roster, actions, leaving = false }) {
export function ContextMenu({ menu, roster, actions, leaving = false, unread }) {
useEscape(() => actions.closeMenu())
useEffect(() => {
const onDown = (event) => { if (!(event.target instanceof Element) || !event.target.closest('.bt-menu')) actions.closeMenu() }
Expand All @@ -28,6 +28,11 @@ export function ContextMenu({ menu, roster, actions, leaving = false }) {
const room = roster.roomsById[menu.id]
const entry = bot ?? room
if (entry === undefined) return null
// The manual unread mark is a local one (#3114): a chat already marked unread offers to
// clear it, and clearing drops only that key — a completion flag stays as it is.
const unreadItem = unread?.[menu.id] === true
? [t('Clear unread mark'), UnreadIcon, () => actions.clearUnread(menu.id)]
: [t('Mark as Unread'), UnreadIcon, () => actions.markUnread(menu.id)]
const isMainBot = isMainOf(roster, menu.id)
const isTile = roster.mainBotId === menu.id
const mainCount = (roster.mainBotIds ?? []).length
Expand All @@ -37,7 +42,7 @@ export function ContextMenu({ menu, roster, actions, leaving = false }) {
const groups = bot?.remote
? [
[
[t('Mark as Unread'), UnreadIcon, () => actions.markUnread(menu.id)],
unreadItem,
],
[
[t('Bot settings'), GearIcon, () => actions.openSettings('bots', bot.id)],
Expand All @@ -48,7 +53,7 @@ export function ContextMenu({ menu, roster, actions, leaving = false }) {
: [
[
isTile || locked ? null : [entry.pinned ? t('Unpin') : t('Pin'), PinIcon, () => actions.setFlags(menu.id, { pinned: !entry.pinned })],
[t('Mark as Unread'), UnreadIcon, () => actions.markUnread(menu.id)],
unreadItem,
],
[
// One way to edit a Bot (#385): its name is edited in Edit Bot too.
Expand Down
27 changes: 25 additions & 2 deletions core/src/client/header.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createElement as h, Fragment, useEffect, useLayoutEffect, useRef, useState } from 'react'
import { createPortal } from 'react-dom'
import { currentPart, faceRowTitle, latestMemoryChange } from './text.js'
import { ArrowUpIcon, CloseIcon, ArrowDownIcon, MemoryIcon } from './icons.js'
import { ArrowUpIcon, CloseIcon, ArrowDownIcon, MemoryIcon, UnreadIcon } from './icons.js'
import { botState, BotAvatar, RoomAvatar } from './mark.js'
import { clockLabel, movedOnSince, openingTurn, unseenSince } from './cells.js'
import { ActivityIndicator } from './activity-row.js'
Expand Down Expand Up @@ -46,6 +46,27 @@ function MemoryNotice({ shown }) {
h('span', { className: 'bt-pill-mem-in', ref: inner }, h('span', { className: 'bt-pill-mem-ico' }, h(MemoryIcon)), label))
}

// The manual unread mark is keyed by the sidebar's row id (a Bot id, a group id or an Agent
// id) while the header holds the Session id; an unknown id is left alone (#3114).
export function unreadEntryId(roster, sessionId) {
const bot = roster?.byId?.[sessionId]
const room = roster?.roomsById?.[sessionId]
return bot?.id ?? room?.id ?? roster?.agentOf?.[sessionId] ?? sessionId
}

// The header's local unread control: it marks this chat unread or clears that mark without
// opening it, and it never writes the host's completion or pending-interaction flags —
// those still clear only when the chat is opened.
export function SessionUnreadToggle({ sessionId, roster, unread, actions }) {
const target = unreadEntryId(roster, sessionId)
const marked = unread?.[target] === true
const label = marked ? t('Clear unread mark') : t('Mark as Unread')
return h('button', {
type: 'button', className: 'bt-head-unread', 'aria-pressed': marked, 'aria-label': label, title: label,
onClick: () => (marked ? actions.clearUnread(target) : actions.markUnread(target)),
}, h(UnreadIcon))
}

export function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus, useSession, useActivity, useBusyAcks, useMemoryNews, useTurnClock, useUi, useLive, actions }) {
const roster = useRoster(value => value)
const title = useSessions(list => list.byId[sessionId]?.displayTitle ?? list.byId[sessionId]?.title ?? '')
Expand All @@ -55,6 +76,7 @@ export function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus
})
const hiddenTurns = roster.exchangeTurns?.[sessionId]
const visit = useUi(state => state.visits?.[sessionId])
const unread = useUi(state => state.unread)
// The opening separator is the one page effect that stays with the pill: it needs a turn, so
// the shell always draws the header for it, and it reads `useTurnClock`, which the installer
// in header-effects.js deliberately does not carry.
Expand Down Expand Up @@ -106,7 +128,8 @@ export function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus
}),
h(NewMessagePills, { key: sessionId, sessionId, hiddenTurns, useSessions, useUi, useTurnClock, actions }),
h(ActivityIndicator, { key: `activity:${sessionId}`, sessionId, useRoster, useSessionStatus, useSession, useLive, actions }),
h(BusyAckBubble, { key: `busy-ack:${sessionId}`, sessionId, useRoster, useBusyAcks, useSessionStatus, useSession, useLive }))
h(BusyAckBubble, { key: `busy-ack:${sessionId}`, sessionId, useRoster, useBusyAcks, useSessionStatus, useSession, useLive }),
h(SessionUnreadToggle, { sessionId, roster, unread, actions }))
}

// New-message pills. "N new messages ↓" takes Back to bottom's place when
Expand Down
1 change: 1 addition & 0 deletions core/src/client/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ const ZH = {
Pin: '置顶',
Pinned: '已置顶',
'Mark as Unread': '标为未读',
'Clear unread mark': '清除手动未读标记',
'Group settings': '群设置',
'Rename group': '重命名群聊',
'Copy conversation ID': '复制对话 ID',
Expand Down
2 changes: 1 addition & 1 deletion core/src/client/overlays.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function Overlays({ useRoster, useUi, useSessions, useSessionStatus, useA
ui.palette ? createPortal(h(CommandPalette, { key: ui.palette.token, start: ui.palette.query, token: ui.palette.token, roster, actions, useSessions }), document.body) : null,
ui.exchange ? createPortal(h(ExchangeDialog, { pair: ui.exchange, roster, actions }), document.body) : null,
ui.voice ? createPortal(h(VoiceMode, { key: ui.voice, sessionId: ui.voice, roster, actions, useSessions, useSessionStatus }), document.body) : null,
menu ? createPortal(h(ContextMenu, { key: `${menu.kind ?? ''}:${menu.id}:${menu.x}:${menu.y}`, menu, roster, actions, leaving: menuLeaving }), document.body) : null,
menu ? createPortal(h(ContextMenu, { key: `${menu.kind ?? ''}:${menu.id}:${menu.x}:${menu.y}`, menu, roster, actions, unread: ui.unread, leaving: menuLeaving }), document.body) : null,
settings ? createPortal(h(SettingsDialog, { page: settings.page, id: settings.id, roster, actions, useUpdate, leaving: settingsLeaving }), document.body) : null,
remoteBotSettings ? createPortal(h(RemoteBotSettingsSheet, { key: remoteBotSettings, bot: roster.byId[remoteBotSettings], roster, actions, leaving: remoteLeaving }), document.body) : null,
memory && roster.byId[memory] ? createPortal(h(MemoryDialog, { key: memory, bot: roster.byId[memory], roster, actions, leaving: memoryLeaving }), document.body) : null,
Expand Down
4 changes: 4 additions & 0 deletions core/src/client/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ body[data-bt-motion=quiet] .bt-mark[data-poke]{cursor:default}
.bt-pill[aria-expanded=true] .bt-pill-go svg{transform:rotate(180deg)}
.bt-pill[data-memory=updated]:is(:hover,:focus-visible,[aria-expanded=true]) .bt-pill-go{width:0;margin-left:-8px;opacity:0;filter:blur(6px);transform:translateX(-6px)}
@media (prefers-reduced-motion:reduce){.bt-pill,.bt-pill-go,.bt-pill-go svg{transition:none!important}.bt-pill-go{filter:none}.bt-pill:active{transform:none}}
.bt-head-unread{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:50%;background:none;color:var(--bt-ink-3);cursor:pointer}
.bt-head-unread:hover{background:var(--bt-hover);color:var(--bt-ink)}
.bt-head-unread[aria-pressed=true]{color:var(--bt-accent)}
.bt-head-unread svg{width:15px;height:15px}

.bt-astack{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin:0}
.bt-bubble{max-width:min(80%,560px,calc(100% - 82px));background:var(--bt-bubble);color:var(--bt-ink);border-radius:18px;padding:7px 12px;font-size:var(--dsh-content-font-size,14px);line-height:calc(var(--dsh-content-font-size,14px) + 8px);box-sizing:border-box;overflow-wrap:anywhere}
Expand Down
Loading
Loading