Skip to content

Commit fe2a44f

Browse files
committed
Merge remote-tracking branch 'upstream/main' into fix/336-share-requested-card
# Conflicts: # plugins/social/test/social.test.js
2 parents 11b58e8 + 0852b3f commit fe2a44f

33 files changed

Lines changed: 1088 additions & 275 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A friend chat that Bot Social paused (turn budget reached, loop suspected) now shows a **Chat paused** notice with **Extend…**. It raises the usual approval card, and only **Approve** adds 4 turns on Bot Social, so the chat continues without removing and re-adding the friend ([#404](https://github.com/ThinkFlowLab/FlyBot/issues/404)).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A friend's Bot chat is quieter ([#419](https://github.com/ThinkFlowLab/FlyBot/issues/419)): no `Tool removed: create_child_bot · …` line from plugin tool masks (in any chat), no local turns/steps/tok/s footer (the friend's Bot runs on its owner's home), and the composer keeps `Message <Bot>` after a send instead of switching to the coding label.

‎core/client.js‎

Lines changed: 192 additions & 162 deletions
Large diffs are not rendered by default.

‎core/src/client/cells.js‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createElement as h, Fragment, useEffect, useLayoutEffect, useMemo, useR
22
import { createPortal } from 'react-dom'
33
import { MarkdownText } from '@deepseek-ai/dsh-client-ui-primitives'
44
import { inkText } from './inks.js'
5-
import { currentPart, linkMentions, mentionTarget, dayLabel, contentText, stripHeader, stripTrace, isHiddenTurn, typedBy, isRelayContext, relaysBefore, relayPart, commRunOf, toolName, toolArgs, reminderPrompts } from './text.js'
5+
import { currentPart, linkMentions, mentionTarget, dayLabel, contentText, stripHeader, stripTrace, isHiddenTurn, typedBy, isRelayContext, relaysBefore, relayPart, commRunOf, toolName, toolArgs, reminderPrompts, isPluginTool } from './text.js'
66
import { SmileIcon, ReplyIcon, DotsIcon, CheckIcon, DownloadIcon, CopyIcon, MemoryIcon } from './icons.js'
77
import { colorOf, lookBotForRemote, toolState, BotMark, PersonMark, RoomAvatar } from './mark.js'
88
import { AnsweredCell, SettledQuestion, PendingQuestion } from './questions.js'
@@ -561,16 +561,20 @@ export function Nothing() { return null }
561561
export const HIDDEN_REMOVED_TOOLS = new Set(['ask_user_question'])
562562
// Connector tools come and go with a Bot's connector switch (#335), not with anything the Bot did.
563563
const isConnectorTool = name => typeof name === 'string' && /^mcp__(github|composio)__/.test(name)
564-
const isHiddenNotice = block => (block?.type === 'tool-removal' && (HIDDEN_REMOVED_TOOLS.has(block.toolName) || isConnectorTool(block.toolName)))
565-
|| (block?.type === 'tool-addition' && isConnectorTool(block.toolName))
564+
// Plugin tools a per-Bot mask hides (tree's create_child_bot, list_children, …) come and go with the
565+
// Bot's place, never with anything a person did, so their rows stay out of every chat (#419).
566+
const isHiddenNotice = block => (block?.type === 'tool-removal' && (HIDDEN_REMOVED_TOOLS.has(block.toolName) || isConnectorTool(block.toolName) || isPluginTool(block.toolName)))
567+
|| (block?.type === 'tool-addition' && (isConnectorTool(block.toolName) || isPluginTool(block.toolName)))
566568

567569
export function isHiddenToolRemoval(node) {
568570
const content = node?.data?.content
569571
if (!Array.isArray(content) || content.length === 0) return false
570572
return content.every(isHiddenNotice)
571573
}
572574

573-
export function ContextCell({ node }) {
575+
export function ContextCell({ node, useRoster }) {
576+
// Plugin tool names can arrive after this row has drawn (a plugin reload): follow them (#419).
577+
useRoster?.(roster => (roster.pluginTools ?? []).join('\n'))
574578
if (isHiddenToolRemoval(node)) return null
575579
const content = Array.isArray(node?.data?.content) ? node.data.content : []
576580
const parts = []

‎core/src/client/header.js‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,34 @@ export function HeaderPill({ sessionId, useRoster, useSessions, useSessionStatus
9494
document.body.style.removeProperty('--bt-remote-empty')
9595
}
9696
}, [bot?.remote, blank, remoteEmptyHint])
97+
// A friend's Bot runs on its owner's home: the local run stats (turns, steps, tok/s, cache)
98+
// are relay turns and always 0 here, so CSS hides the shell's stats footer in that chat (#419).
99+
useEffect(() => {
100+
if (!bot?.remote) return undefined
101+
document.body.dataset.btFriendChat = ''
102+
return () => { delete document.body.dataset.btFriendChat }
103+
}, [bot?.remote])
97104
useEffect(() => {
98105
document.body.style.setProperty('--bt-placeholder', JSON.stringify(composerLabel))
99106
const input = document.querySelector('[data-composer-input]')
100107
const priorLabel = input?.getAttribute('aria-label') ?? null
101108
const apply = () => {
102109
const el = document.querySelector('[data-composer-input]')
103-
if (el) el.setAttribute('aria-label', composerLabel)
110+
if (el && el.getAttribute('aria-label') !== composerLabel) el.setAttribute('aria-label', composerLabel)
104111
}
105112
apply()
106113
const timer = setTimeout(apply, 0)
114+
// The shell re-renders its composer after a send and puts its own coding label back
115+
// ("Message or run a task, / commands, …"); keep "Message <name>" on it (#419).
116+
let frame = 0
117+
const watcher = typeof MutationObserver === 'function'
118+
? new MutationObserver(() => { if (!frame) frame = requestAnimationFrame(() => { frame = 0; apply() }) })
119+
: null
120+
watcher?.observe(document.body, { subtree: true, childList: true, attributes: true, attributeFilter: ['aria-label'] })
107121
return () => {
108122
clearTimeout(timer)
123+
watcher?.disconnect()
124+
if (frame) cancelAnimationFrame(frame)
109125
const el = document.querySelector('[data-composer-input]')
110126
if (!el) return
111127
if (priorLabel == null) el.removeAttribute('aria-label')

‎core/src/client/index.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { isHex, inkText, paintCss } from './inks.js'
44
import { DEFAULT_MASK, SHAPES, markupCache, maskOf } from './characters.js'
55
import { countCards, createSource, EMPTY_ROSTER, indexRoster, isAgentSession } from './sources.js'
66
import { themeCss, shellTokens, registry, registerShape, registerTheme, allThemes } from './themes.js'
7-
import { MENTION_ORIGIN, currentPart, landingPart } from './text.js'
7+
import { MENTION_ORIGIN, currentPart, landingPart, setPluginTools } from './text.js'
88
import { SHELL_CSS, CONVERSATION_CSS, installStyles, installCompiledStyles } from './styles.js'
99
import { installBrandChrome, installTabTitle } from './brand.js'
1010
import { lookOf } from './mark.js'
@@ -158,6 +158,8 @@ export function apply(ctx) {
158158
const live = {}
159159
if (value.connectors !== undefined && JSON.stringify(value.connectors) !== JSON.stringify(current.connectors ?? [])) live.connectors = value.connectors
160160
if (value.capabilityStatuses !== undefined && JSON.stringify(value.capabilityStatuses) !== JSON.stringify(current.capabilityStatuses ?? {})) live.capabilityStatuses = value.capabilityStatuses
161+
// Plugin tool names come with a plugin reload, not a revision; context rows re-read them (#419).
162+
if (value.pluginTools !== undefined && JSON.stringify(value.pluginTools) !== JSON.stringify(current.pluginTools ?? [])) { setPluginTools(value.pluginTools); live.pluginTools = value.pluginTools }
161163
if (Object.keys(live).length > 0 && current.ready) roster.set({ ...current, ...live })
162164
if (value.unchanged || (value.revision === current.revision && value.modelsKey === current.modelsKey)) return
163165
// On a browser with no visit record yet, everything already there counts as seen.
@@ -822,7 +824,7 @@ export function apply(ctx) {
822824
shadow('conversation.chat.node', { key: 'turn-error', priority: -10, locale: 'chat', inject: face }, TurnErrorCell),
823825
// DSH's context row is "Tool removed: ask_user_question" after Bot sessions
824826
// restrict that tool; hide it, keep other tool-change notices (#140).
825-
shadow('conversation.chat.node', { key: 'context', priority: -10, locale: 'chat' }, ContextCell),
827+
shadow('conversation.chat.node', { key: 'context', priority: -10, locale: 'chat', inject: face }, ContextCell),
826828
...(canDrawUserMessages() ? ['user', 'steering'].map(key => shadow('conversation.chat.node', { key, priority: -10, locale: 'chat', inject: face }, UserMessageCell)) : []),
827829
shadow('conversation.input.permission', { priority: -10 }, Nothing),
828830
shadow('conversation.input.plan', { priority: -10 }, Nothing),

‎core/src/client/sources.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { setLocalBots } from './characters.js'
2+
import { setPluginTools } from './text.js'
23

34
// -------------------------------------------------------------------------
45
// Small observable sources for the inject `hooks` compartment.
@@ -27,6 +28,7 @@ export const isMainOf = (roster, id) => id !== undefined && (roster.mainBotIds ?
2728
// (running, unread, turns) is read from the current part, team state from the Bot id.
2829
export function indexRoster(value) {
2930
setLocalBots(value.bots)
31+
setPluginTools(value.pluginTools)
3032
const byId = {}
3133
for (const bot of value.bots) {
3234
for (const id of [...(bot.parts ?? []), bot.sessionId ?? bot.id, bot.id]) byId[id] = bot

‎core/src/client/styles.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,8 @@ body[data-bt-remote-chat=empty][data-content-phase=hero] [class*="_scrollBody"]:
915915
[data-composer-card] [data-composer-input]{min-height:24px;padding:2px 0!important}
916916
[data-composer-card] [data-composer-placeholder]{left:0!important;top:2px!important}
917917
[data-composer-placeholder]{font-size:0!important;line-height:0!important}
918+
/* A friend's Bot chat: no local run stats (they are relay turns, always 0; #419). */
919+
body[data-bt-friend-chat] [data-composer-stats]{display:none!important}
918920
[data-composer-placeholder]::after{content:var(--bt-placeholder,"Message");display:block;font-size:14px;line-height:24px;color:color-mix(in srgb,var(--bt-ink) 36%,transparent)}
919921
/* The team's "+" (ComposerPlus) takes the seat of the shell's command-menu button. */
920922
[data-composer-card] button[class*="_add"]{display:none!important}

‎core/src/client/text.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ export function isHiddenTurn(roster, sessionId, turn) {
148148

149149
export const toolName = root => root.name || root.call?.name
150150

151+
// Plugin tools a per-Bot mask adds or removes (the roster's `pluginTools`, #419).
152+
let pluginTools = new Set()
153+
export function setPluginTools(names) {
154+
pluginTools = new Set((Array.isArray(names) ? names : []).filter(name => typeof name === 'string'))
155+
}
156+
export const isPluginTool = name => typeof name === 'string' && pluginTools.has(name)
157+
151158
// While a Session's history loads, a card asked in it may yet be drawn at its call,
152159
// so the docks hold it back until then.
153160
export const historyLoading = snapshot => snapshot?.openState === 'cold' || snapshot?.openState === 'loading'

‎core/src/host/channel.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ export function install(rt) {
116116
connectors: rt.connectorsView(),
117117
capabilityStatuses: rt.capabilityStatusesView(),
118118
}
119-
return rt.ownedLive(full, actor)
119+
// Plugin tool names change with a plugin reload, not with the team revision, so they ride every
120+
// answer, unchanged or not, and the client re-reads its hidden-row set (#419).
121+
return { ...rt.ownedLive(full, actor), pluginTools: rt.pluginToolNames?.() ?? [] }
120122
}
121123
// What a host that only reads the team may still answer.
122124
// Updates change the dsh profile, not the team, so a reading host may run them too.

0 commit comments

Comments
 (0)