Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(hetero-agent): head the composer's floating stack with guard notices (#19791)

Arvin Xu0542683a4592
diff --git a/.agents/acceptance/probe-mock-patterns.md b/.agents/acceptance/probe-mock-patterns.md
index 05330efbb9c..88f76b80f9b 100644
--- a/.agents/acceptance/probe-mock-patterns.md
+++ b/.agents/acceptance/probe-mock-patterns.md
@@ -103,6 +103,8 @@ drive / probe / capture / publish. Skip a row only when its surface AND runtime
| P79 | web, cli | client, gateway | env | Local SearXNG with `SEARCH_PROVIDERS=searxng`; the on-disk search1api keys are dead |
| P84 | cli | any | auth | Drive `lh` against the local lobehub-cloud runtime by seeding an API key row into its main database |
| P85 | cli | any | fixture | Simulate a publish whose response was lost by restoring `pendingCreateKey` in `.lobehub/artifacts.json` |
+| P88 | web | hetero | fixture | Force the device-offline guard by rewriting `listDevices` at the CDP Fetch layer; the tray needs a real `startOperation` |
+| P89 | web | any | probe | A layout before/after on one live page: swap only the changed files and let HMR settle; `getComputedStyle().bottom` is a used value, read `el.style.bottom` |
| P82 | web | any | drive | Acceptance flow canvas through the production debug proxy: anonymous shared link, one uninterrupted script, canvas controls for clipped groups |
| P86 | electron, cli | any | env, auth | A session spawned by the desktop hetero runtime inherits `LOBEHUB_JWT` (production) and `ELECTRON_RUN_AS_NODE=1` — strip both before local Electron/CLI work |
@@ -2581,3 +2583,67 @@ printf '{"artifacts":{"dist/index.html":{"pendingCreateKey":"%s"}},"version":1}'
Capture both publishes' `--json` output in one artifact with the restored
manifest shown between them, so a reviewer can see the key was genuinely reused.
+
+#### P88 · Forcing the hetero composer's device-offline guard, and the status tray that sits above it
+
+**applies-to:** surface=web · runtime=hetero · phase=fixture
+
+**Situation:** verifying the guard banner above a heterogeneous agent's composer
+(设备未连接 / 云端未配置 …), and its relationship to the floating run-status tray.
+
+**Doesn't work:** actually disconnecting the bound device. `lh connect` runs the
+infrastructure executing the agent, and the round then depends on a gateway you
+had to take down.
+
+**Works:** the guard reads `deviceService.listDevices()`, so rewrite that one
+response at the CDP Fetch layer and leave the product's own guard logic intact:
+
+```js
+await send('Fetch.enable', { patterns: [{ urlPattern: '*listDevices*', requestStage: 'Response' }] });
+// in Fetch.requestPaused: getResponseBody → text.replace(/"online":true/g, '"online":false') → fulfillRequest
+```
+
+Drop `content-length` and `content-encoding` from the replayed headers or the
+fulfilled body is truncated. The interception dies with the CDP connection, so a
+later HMR re-fetch brings the device back online and the banner disappears —
+keep one script alive for the whole capture rather than attaching per step.
+
+The run-status tray needs a *real* operation, not a DOM stub:
+
+```js
+const { useChatStore } = await import('http://localhost:<vitePort>/src/store/chat/index.ts');
+useChatStore.getState().startOperation({
+ type: 'execHeterogeneousAgent',
+ context: { agentId, topicId },
+ metadata: { startTime: Date.now() - 5000 },
+});
+```
+
+`getVisibleAgentRuntimeStartTimeByContext` only counts `AI_RUNTIME_OPERATION_TYPES`
+whose `metadata.visibleLoadingDone` is unset, and it keys off the conversation's
+full context — pass the route's own `agentId` / `topicId` or the tray never mounts.
+
+#### P89 · A layout A/B on one live page: swap the changed files, and read inline styles not computed ones
+
+**applies-to:** surface=web · runtime=any · phase=probe
+
+**Situation:** proving a CSS/structure fix changed what the user sees, with only
+the code as the variable.
+
+**Works:** keep one page open and swap just the changed files under the running
+Vite server, letting HMR settle between measurements — same route, same data,
+same viewport, same injected state. In a shared working tree take the "after"
+copy with `cp` first and restore from it (never `git stash`, see
+[[feedback_no_git_stash_shared_worktrees]] in the user memory); recover the
+"before" with `git show HEAD:<path>`. When the tree sits on an unrelated branch,
+write the PR branch's exact file content in for the capture and record the
+sha256 of both sides in the evidence.
+
+**Trap:** `getComputedStyle(el).bottom` on a positioned element returns the
+**used** value in pixels, so a selector looking for `bottom === '100%'` silently
+matches nothing and the overlay reads as absent. Match on the inline style
+(`el.style.bottom === '100%'`) instead. Same for any percentage offset.
+
+For "does A cover B", assert the rectangles rather than eyeballing the capture:
+`!(a.bottom <= b.top || b.bottom <= a.top)`. A banner whose top sliver is still
+visible looks fine in a thumbnail and is still broken.
diff --git a/src/features/Conversation/ChatInput/index.tsx b/src/features/Conversation/ChatInput/index.tsx
index ff7f031353b..874ecffcc37 100644
--- a/src/features/Conversation/ChatInput/index.tsx
+++ b/src/features/Conversation/ChatInput/index.tsx
@@ -123,6 +123,15 @@ export interface ChatInputProps {
* Mention items for @ mentions (for group chat)
*/
mentionItems?: SlashOptions['items'];
+ /**
+ * Blocking notices (device offline, cloud not configured, …). They ride at the
+ * top of the composer's floating stack — above the run-status / queue / todo
+ * trays, which stay next to the input they annotate, and on the same inline
+ * edges as those trays so the stack reads as one column. Rendered as a sibling
+ * above `ChatInput` instead, a notice would be covered by those trays, since
+ * the stack floats upward from the top of this column.
+ */
+ notices?: ReactNode;
/**
* Callback when editor instance is ready
*/
@@ -175,6 +184,7 @@ const ChatInput = memo<ChatInputProps>(
extraActionItems,
isConfigLoading = false,
mentionItems,
+ notices,
controlBarSlot,
sendMenu,
sendAreaPrefix,
@@ -469,6 +479,10 @@ const ChatInput = memo<ChatInputProps>(
zIndex: 10,
}}
>
+ {/* A blocking notice outranks the run it is blocking, so it heads the
+ stack. It takes the overlay's own inset like every tray below it,
+ so the whole floating column shares one pair of edges. */}
+ {notices}
<InputCompletionErrorAlert />
{!disableQueue && hasQueuedMessages && <QueueTray />}
<TodoProgress topAttached={!disableQueue && hasQueuedMessages} />
diff --git a/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/index.tsx b/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/index.tsx
index 7e6a90b05cb..ac8a4838564 100644
--- a/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/index.tsx
+++ b/src/routes/(main)/agent/features/Conversation/HeterogeneousChatInput/index.tsx
@@ -16,7 +16,6 @@ import HeteroModel from '@/features/ChatInput/ControlBar/HeteroModel';
import { ChatInput } from '@/features/Conversation';
import { contextSelectors, useConversationStore } from '@/features/Conversation/store';
import { useProviderBindingValidation } from '@/features/HeterogeneousAgent/hooks/useProviderBinding';
-import WideScreenContainer from '@/features/WideScreenContainer';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import {
isHeterogeneousSandboxExecutionAvailable,
@@ -47,24 +46,25 @@ const leftActions: ActionKeys[] = [];
* fold the headline and the hint onto one line (no separate `description`
* block, no oversized 24px icon) so the guard stays a compact strip instead of
* eating a chunk of the conversation area.
+ *
+ * Rendered through `ChatInput`'s `notices` slot, which places it at the top of
+ * the composer's floating stack: above the run-status tray, and with no inline
+ * padding or width cap of its own so its edges land on the input's edges.
*/
const GuardBanner = memo<{ action?: ReactNode; hint?: string; title: string }>(
({ title, hint, action }) => (
- <WideScreenContainer>
- <Flexbox align={'center'} paddingBlock={'0 8px'} paddingInline={12}>
- <Alert
- action={action}
- style={{ maxWidth: 880, width: '100%' }}
- type={'warning'}
- title={
- <Flexbox horizontal align={'baseline'} gap={6} style={{ flexWrap: 'wrap' }}>
- <span>{title}</span>
- {hint && <span style={{ fontWeight: 400, opacity: 0.75 }}>{hint}</span>}
- </Flexbox>
- }
- />
- </Flexbox>
- </WideScreenContainer>
+ <Flexbox paddingBlock={'0 8px'}>
+ <Alert
+ action={action}
+ type={'warning'}
+ title={
+ <Flexbox horizontal align={'baseline'} gap={6} style={{ flexWrap: 'wrap' }}>
+ <span>{title}</span>
+ {hint && <span style={{ fontWeight: 400, opacity: 0.75 }}>{hint}</span>}
+ </Flexbox>
+ }
+ />
+ </Flexbox>
),
);
@@ -311,21 +311,30 @@ const HeterogeneousChatInput = memo(() => {
deviceBlocked ||
(!isConfigured && !isDeviceExecution);
- return (
- <Flexbox>
+ // The guards go through `notices` rather than as siblings above `ChatInput`:
+ // the running-status / queue trays float above this column, so a sibling
+ // guard would sit underneath them. The slot puts it on top of that stack.
+ const notices = hasGuard ? (
+ <>
{renderApiModeTargetGuard()}
{renderApiModeBindingGuard()}
{renderDeviceSelectionGuard()}
{renderCloudConfigGuard()}
{renderDeviceGuard()}
+ </>
+ ) : undefined;
+
+ return (
+ <Flexbox>
<ChatInput
+ skipScrollMarginWithList
allowExpand={false}
controlBarSlot={<HeteroControlBar />}
extraActionItems={extraActionItems}
leftActions={leftActions}
+ notices={notices}
sendAreaPrefix={sendAreaPrefix}
sendButtonProps={{ disabled: inputDisabled, shape: 'round' }}
- skipScrollMarginWithList={!hasGuard}
onEditorReady={(instance) => {
// Sync to global ChatStore for compatibility with other features
useChatStore.setState({ mainInputEditor: instance });