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.

💄 style: refine chat input notice stacking (#20402)

Nekobb413404fc79
diff --git a/.agents/skills/ux-audit/references/example/chat-input-notice.md b/.agents/skills/ux-audit/references/example/chat-input-notice.md
new file mode 100644
index 00000000000..e0988ebfbf0
--- /dev/null
+++ b/.agents/skills/ux-audit/references/example/chat-input-notice.md
@@ -0,0 +1,49 @@
+# UX Audit — Chat Input Notice stacking
+
+**Layers:** L1 static/code ✅ · L2 desktop + mobile visual ✅ · L3 disclosure interaction ✅.
+
+**Surface class:** contextual capability and restriction feedback inside a persistent chat composer. The closest norms are inline validation/capability warnings, progressive disclosure, and non-blocking status display. The composer must remain the dominant action surface; routine warnings should explain state without taking over the conversation.
+
+## Patterns in use
+
+| Pattern | Rating | Evidence |
+| ------------------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Contextual capability feedback | ✅ | Notices stay beside the controls they affect; unresolved runtime state remains silent (`useChatInputNotice.ts:87-109,254-263`). |
+| Progressive disclosure | ✅ | Any non-empty notice set collapses to one consistent count entry, then expands on demand (`Content.tsx`). |
+| Status summary + detail | ✅ | Compact warning count opens an ordered list of full Alert rows (`Content.tsx:146-175`). |
+| Responsive disclosure | ✅ | Desktop accepts hover/click; mobile uses click, and the list width/height are viewport-bounded (`Content.tsx:44-48,154`). |
+| Recovery action | ✅ | Existing per-notice action, permission-disabled reason, loading state, and error toast remain intact (`Content.tsx:87-124`; `useChatInputNotice.ts:265-324`). |
+
+## Strengths / good cases
+
+- **✅ One disclosure model for every count.** Single and multiple notices use the same compact count entry and the same upward Popover, so the composer no longer changes layout strategy when a second condition appears.
+- **✅ Routine states no longer compete with the composer.** The summary occupies one compact toolbar slot, while the complete content floats above the input on demand. This applies Grow §5.1 progressive disclosure without hiding the existence or count of warnings.
+- **✅ Long warnings stay readable.** Expanded notice titles use normal wrapping plus `overflow-wrap: anywhere`; the viewport-bounded list scrolls as a whole instead of truncating actionable copy.
+- **✅ Priority remains semantic, not arrival-based.** Resource-level view-only state is inserted before narrower model configuration state, so the expanded list leads with the broad blocker (`useChatInputNotice.ts:75-109`). The legacy singular resolver still returns that first item (`:120-133`).
+- **✅ Cold-load false warnings stay suppressed.** Model warnings wait for both model configuration and effective selection resolution (`useChatInputNotice.ts:87-101,254-263`), validating Feedback §4.3 capability gating.
+- **✅ The component uses existing primitives and tokens.** `Alert`, text `Button`, `Popover`, responsive hook, semantic warning color, and current i18n/action paths are reused rather than introducing a parallel notice system (`Content.tsx`). Warning color identifies the state without adding a second elevation system.
+
+## Experience gaps found and resolved
+
+1. 🟡 **The collapsed summary was styled as a raised warning card.** L2 showed a strong warning border plus a two-layer yellow `box-shadow`, making a secondary toolbar affordance compete with the composer. The decoration had no system precedent: `DESIGN.md` reserves semantic color for meaning and standard elevation for surfaces that genuinely float. Fixed by using the canonical text-button hierarchy, keeping only the warning icon/text color, and deleting the colored border and decorative shadow (`Content.tsx`).
+2. 🟡 **Wrapped warning icons were centered against the whole paragraph.** `align-items: center` made the second row's icon float between lines instead of identifying the first line. Fixed with first-line alignment (`align-items: flex-start` plus a 1px optical inset), confirmed on the real `/tasks` Task Agent panel at 1600×1000.
+3. 🟠 **The first implementation used two disclosure models.** One notice rendered inline while two notices switched to a count Popover, making the composer change shape as state accumulated. Follow-up feedback selected consistency over immediate single-item detail, so every non-empty set now uses the same count-and-expand interaction.
+4. 🟠 **Prototype-only notice injection leaked into application logic.** A development environment flag fabricated a second warning. Removed; production resolution is now entirely state-derived, while acceptance uses a temporary harness at the presentation boundary.
+5. 🟡 **The default locale source lacked the new count key.** Adding only generated JSON would be overwritten by locale generation. Fixed in `packages/locales/src/default/chat.ts` and preview JSON for English and Simplified Chinese.
+6. 🟡 **Mobile disclosure initially inherited hover semantics.** Fixed by selecting click-only on mobile while keeping hover plus click on desktop (`Content.tsx`). L2 at an iPhone 14 viewport confirmed the 360px-bounded list fits without horizontal clipping.
+
+## L2 / L3 evidence
+
+- Desktop single notice: the composer shows a compact count of 1; activation opens the full warning above it.
+- Desktop long notice: the complete controlled warning wraps to two lines inside the production Popover without ellipsis.
+- Desktop multiple collapsed: one compact warning icon/count is visible; the composer, model selector, and send button remain present.
+- Desktop multiple expanded: the Popover opens upward and shows the view-only notice before the unavailable-model notice.
+- Real Task Agent refinement at 1600×1000: collapsed summary has no border or colored shadow; expanded rows use the standard neutral Popover elevation, and the two-line model warning icon aligns with its first line.
+- Mobile multiple expanded: the list remains within the 390px viewport and the summary stays anchored inside the composer.
+- Interaction: the controlled production-component harness changed the trigger from `aria-expanded=false` to `true` after activation; source selects click-only when `useIsMobile()` is true.
+
+## Skill feedback
+
+- The findings validate existing `ux` rules: Feedback §4.3 for capability-gated state, Grow §5.1 for progressive disclosure, and the persistent-composer guidance in Read §1.11.
+- **New generalizable gap landed in Feedback §4.3.** Collapsed guardrail summaries must remain subordinate to their action surface: semantic color may identify state, but strong warning outlines or decorative colored elevation must not turn the trigger into a competing card.
+- **New generalizable alignment rule landed in Feedback §4.3.** Icons in wrapped guardrail rows align to the first line of copy rather than the vertical center of the full paragraph.
diff --git a/.agents/skills/ux/references/feedback.md b/.agents/skills/ux/references/feedback.md
index bae07b33765..94e95854792 100644
--- a/.agents/skills/ux/references/feedback.md
+++ b/.agents/skills/ux/references/feedback.md
@@ -371,6 +371,13 @@ Stay reactive — the reminder clears the moment the user switches to a capable
unsupported state. Scope to the mode that needs it — one reminder per root cause — and
state both the problem and the remedy.
+When several guardrails collapse behind one summary control, keep that control subordinate
+to the action surface. Semantic warning color may identify the icon or label, but it must not
+turn a toolbar affordance into a raised warning card through a strong outline, tinted depth,
+or decorative stacking shadow. The expanded rows still carry the complete warning treatment.
+For wrapped messages, align the status icon to the first line of copy rather than centering it
+against the whole text block; the icon identifies the message, not its bounding box.
+
**Soft-inline is right only when the user can fix it _in context_.** The "never a hard block"
rule above assumes a **model / config** capability — the user switches the model dropdown and
the feature works, so blocking them would be gratuitous. A different class of gap is
@@ -397,6 +404,8 @@ with a path out. Both still owe the remedy.
- [ ] No warning while config is still loading; only on resolved-unsupported. _(Certainty)_
- [ ] Scoped to the dependent mode; one reminder per root cause. _(Natural・Certainty)_
- [ ] Copy states the problem and the remedy. _(Meaningful)_
+- [ ] A collapsed guardrail summary stays visually subordinate to its action surface — semantic color can identify it, but no strong warning outline or decorative colored elevation turns it into a competing card. _(Natural・Certainty)_
+- [ ] In a wrapped guardrail row, the status icon aligns with the first line of copy, not the vertical center of the complete text block. _(Natural)_
## 4.4 Autosave needs a persistent save-state, and one convention per surface・Certainty・Meaningful
@@ -475,7 +484,7 @@ message) and never passes an i18n file. Three smells mark a message that escaped
- **Internal ids in the headline** — a raw `tpc_…` / `msg_…` / uuid, a `#N` sequence, an
operation id. The id is for a **log or an inspect link**, never the sentence the user reads;
it belongs on a **structured field** (`topicId`, `taskId`) that powers a "View run" affordance,
- not baked into the title. A human reading "topic #1 (tpc\_5UBuAjUU4z6B)" learns nothing and
+ not baked into the title. A human reading "topic #1 (tpc_5UBuAjUU4z6B)" learns nothing and
distrusts the whole card.
- **Log / stack framing** — `Execution failed: …`, `Error: …`, `[TaskLifecycle]`, a
prefixed severity. Framing that reads like a console line signals "this wasn't meant for
@@ -495,7 +504,7 @@ of the smells above, and localize the _cause_ too where it maps to a known error
> `topicId` field that lights up "View run" (`InboxBriefCard.tsx`,
> `taskLifecycle/index.ts` error brief). ❌ Its prior form baked the lot into the stored
> string — title `` `${taskIdentifier} topic #${seq} (${topicId}) error` `` → **"T-1 topic #1
-> (tpc\_5UBuAjUU4z6B) error"**, summary `` `Execution failed: ${raw}` `` — internal id in the
+> (tpc_5UBuAjUU4z6B) error"**, summary `` `Execution failed: ${raw}` `` — internal id in the
> headline, log framing, task ref duplicated from the meta row, and English-only for every
> locale.
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index 8697d704440..8db4eb00f5d 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -1300,6 +1300,8 @@
"input.modelFixedTip": "The model is fixed in the Agent Profile and cannot be switched while chatting.",
"input.modelUnavailable": "The current model is no longer available. Choose another model to continue.",
"input.more": "More",
+ "input.notice.summary_one": "{{count}} input notice",
+ "input.notice.summary_other": "{{count}} input notices",
"input.schedule.cancel": "Cancel",
"input.schedule.clear": "Cancel scheduled send",
"input.schedule.failed": "Could not schedule this message. Try again.",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index 2f98612e1ae..f6f2d4a289b 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -1300,6 +1300,8 @@
"input.modelFixedTip": "模型已在助理档案中固定,聊天时不可切换。",
"input.modelUnavailable": "当前模型已下线。请选择其他模型后继续使用。",
"input.more": "更多",
+ "input.notice.summary_one": "{{count}} 个输入提醒",
+ "input.notice.summary_other": "{{count}} 个输入提醒",
"input.schedule.cancel": "取消排期",
"input.schedule.clear": "取消定时",
"input.schedule.failed": "定时发送失败,请重试",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index 7b4b339461d..f40ccc27904 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -775,6 +775,8 @@ export default {
'input.viewOnlyGroup': 'You can only view this group',
'input.heteroPlus.tooltip': 'Formatting and scheduling',
'input.more': 'More',
+ 'input.notice.summary_one': '{{count}} input notice',
+ 'input.notice.summary_other': '{{count}} input notices',
'input.schedule.cancel': 'Cancel',
'input.schedule.clear': 'Cancel scheduled send',
'input.schedule.failed': 'Could not schedule this message. Try again.',
diff --git a/src/features/ChatInput/ChatInputNotice/Content.tsx b/src/features/ChatInput/ChatInputNotice/Content.tsx
new file mode 100644
index 00000000000..3a90bae558b
--- /dev/null
+++ b/src/features/ChatInput/ChatInputNotice/Content.tsx
@@ -0,0 +1,179 @@
+'use client';
+
+import { Flexbox, Icon, Tooltip } from '@lobehub/ui';
+import { Alert, Button, Popover, Text } from '@lobehub/ui/base-ui';
+import { createStaticStyles, cssVar, cx } from 'antd-style';
+import { AlertTriangle } from 'lucide-react';
+import { memo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import { useIsMobile } from '@/hooks/useIsMobile';
+
+import type { ChatInputNotice } from './useChatInputNotice';
+
+const styles = createStaticStyles(({ css }) => ({
+ action: css`
+ flex: none;
+ height: 24px;
+ padding-inline: 10px;
+ `,
+ actionWrapper: css`
+ display: inline-flex;
+ `,
+ alert: css`
+ gap: 6px !important;
+ align-items: flex-start !important;
+
+ min-width: 0;
+ padding-inline: 8px 10px !important;
+ border-radius: ${cssVar.borderRadius};
+
+ font-size: ${cssVar.fontSizeSM};
+
+ .ant-alert-content {
+ min-width: 0;
+ }
+
+ .ant-alert-icon {
+ flex: none;
+ height: 18px !important;
+ margin-block-start: 1px;
+ margin-inline-end: 0 !important;
+ }
+ `,
+ list: css`
+ overflow-y: auto;
+ overscroll-behavior: contain;
+ width: min(360px, calc(100vw - 32px));
+ max-height: min(320px, calc(100vh - 96px));
+ `,
+ notice: css`
+ width: 100%;
+ padding-block: 6px !important;
+ `,
+ summary: css`
+ min-width: 36px;
+ height: 26px;
+ padding-inline: 6px;
+
+ && {
+ color: ${cssVar.colorWarning};
+ background: color-mix(in srgb, ${cssVar.colorWarning} 12%, ${cssVar.colorBgContainer});
+ }
+
+ &&:hover,
+ &&:active,
+ &&[data-popup-open] {
+ color: ${cssVar.colorWarning};
+ background: color-mix(in srgb, ${cssVar.colorWarning} 18%, ${cssVar.colorBgContainer});
+ }
+ `,
+ title: css`
+ min-width: 0;
+
+ font-size: 12px;
+ line-height: 18px !important;
+ overflow-wrap: anywhere;
+ white-space: normal;
+ `,
+}));
+
+const popoverStyles = { content: { padding: 8 } } as const;
+
+interface NoticeAlertProps {
+ notice: ChatInputNotice;
+}
+
+const NoticeAlert = ({ notice }: NoticeAlertProps) => {
+ const { t } = useTranslation('chat');
+
+ const enableButton = notice.action === 'enableModel' && (
+ <Button
+ className={styles.action}
+ disabled={notice.actionDisabled}
+ loading={notice.actionLoading}
+ size={'small'}
+ type={'primary'}
+ onClick={() => void notice.onAction?.()}
+ >
+ {t('input.modelDisabled.action')}
+ </Button>
+ );
+
+ const action =
+ enableButton && notice.actionDisabled ? (
+ <Tooltip title={notice.actionDisabledReason}>
+ <span className={styles.actionWrapper}>{enableButton}</span>
+ </Tooltip>
+ ) : (
+ enableButton
+ );
+
+ return (
+ <Alert
+ action={action}
+ title={t(notice.key)}
+ type={notice.type}
+ variant={'borderless'}
+ classNames={{
+ alert: cx(styles.alert, styles.notice),
+ title: styles.title,
+ }}
+ />
+ );
+};
+
+/**
+ * Renders the chat-input notice presentation for a resolved notice collection.
+ *
+ * Use when:
+ * - The caller already owns notice resolution
+ * - A controlled preview needs to exercise the production presentation
+ *
+ * Expects:
+ * - Notices ordered from the broadest blocker to narrower configuration issues
+ *
+ * Returns:
+ * - Nothing for zero notices, or a compact summary that expands every resolved notice
+ */
+export const ChatInputNoticeContent = memo(({ notices }: { notices: ChatInputNotice[] }) => {
+ const { t } = useTranslation('chat');
+ const isMobile = useIsMobile();
+ if (notices.length === 0) return null;
+
+ const summary = t('input.notice.summary', { count: notices.length });
+
+ return (
+ <Popover
+ arrow
+ standalone
+ closeDelay={160}
+ openDelay={100}
+ placement={'top'}
+ styles={popoverStyles}
+ trigger={isMobile ? 'click' : ['hover', 'click']}
+ content={
+ <Flexbox className={styles.list} gap={8}>
+ <Text fontSize={12} type={'secondary'} weight={500}>
+ {summary}
+ </Text>
+ {notices.map((notice) => (
+ <NoticeAlert key={notice.key} notice={notice} />
+ ))}
+ </Flexbox>
+ }
+ >
+ <Button
+ aria-label={summary}
+ className={styles.summary}
+ icon={<Icon icon={AlertTriangle} size={14} />}
+ size={'small'}
+ type={'text'}
+ >
+ {notices.length}
+ </Button>
+ </Popover>
+ );
+});
+
+ChatInputNoticeContent.displayName = 'ChatInputNoticeContent';
diff --git a/src/features/ChatInput/ChatInputNotice/index.tsx b/src/features/ChatInput/ChatInputNotice/index.tsx
index aff81dfe75e..b26a4c267c4 100644
--- a/src/features/ChatInput/ChatInputNotice/index.tsx
+++ b/src/features/ChatInput/ChatInputNotice/index.tsx
@@ -1,108 +1,14 @@
'use client';
-import { Tooltip } from '@lobehub/ui';
-import { Alert, Button } from '@lobehub/ui/base-ui';
-import { createStaticStyles, cx } from 'antd-style';
import { memo } from 'react';
-import { useTranslation } from 'react-i18next';
-import { useChatInputNotice } from './useChatInputNotice';
-
-const styles = createStaticStyles(({ css, cssVar }) => ({
- action: css`
- flex: none;
- height: 24px;
- padding-inline: 10px;
- `,
- actionWrapper: css`
- display: inline-flex;
- `,
- alert: css`
- flex: 0 1 auto;
-
- /* The Alert root already flex-gaps icon and content; without zeroing the
- icon margin below the two would stack into a ~14px gap. */
- gap: 6px !important;
-
- /* Keep the icon centered against the single-line title. */
- align-items: center !important;
-
- min-width: 0;
- max-width: min(560px, 52vw);
- padding-block: 4px !important;
- padding-inline: 8px 10px !important;
- border-radius: ${cssVar.borderRadius};
-
- .ant-alert-content {
- min-width: 0;
- }
-
- .ant-alert-icon {
- flex: none;
- height: 18px !important;
- margin-inline-end: 0 !important;
- }
-
- @media (width <= 768px) {
- max-width: 100%;
- }
- `,
- title: css`
- overflow: hidden;
-
- min-width: 0;
-
- font-size: 12px;
- line-height: 18px !important;
- text-overflow: ellipsis;
- white-space: nowrap;
- `,
-}));
-
-/**
- * Base Alert fills the available width, which pushes its action away from the notice text.
- * Keep this notice content-sized while its max-width rule handles long translations.
- */
-const alertStyle = { fontSize: 12, width: 'fit-content' } as const;
+import { ChatInputNoticeContent } from './Content';
+import { useChatInputNotices } from './useChatInputNotice';
const ChatInputNotice = memo(() => {
- const { t } = useTranslation('chat');
- const notice = useChatInputNotice();
-
- if (!notice) return null;
-
- const enableButton = notice.action === 'enableModel' && (
- <Button
- className={styles.action}
- disabled={notice.actionDisabled}
- loading={notice.actionLoading}
- size={'small'}
- type={'primary'}
- onClick={() => void notice.onAction?.()}
- >
- {t('input.modelDisabled.action')}
- </Button>
- );
-
- const action =
- enableButton && notice.actionDisabled ? (
- <Tooltip title={notice.actionDisabledReason}>
- <span className={styles.actionWrapper}>{enableButton}</span>
- </Tooltip>
- ) : (
- enableButton
- );
+ const notices = useChatInputNotices();
- return (
- <Alert
- action={action}
- classNames={{ alert: cx(styles.alert), title: styles.title }}
- style={alertStyle}
- title={t(notice.key)}
- type={notice.type}
- variant={'borderless'}
- />
- );
+ return <ChatInputNoticeContent notices={notices} />;
});
ChatInputNotice.displayName = 'ChatInputNotice';
diff --git a/src/features/ChatInput/ChatInputNotice/useChatInputNotice.test.tsx b/src/features/ChatInput/ChatInputNotice/useChatInputNotice.test.tsx
index 2ac118c829a..e40f6244bb5 100644
--- a/src/features/ChatInput/ChatInputNotice/useChatInputNotice.test.tsx
+++ b/src/features/ChatInput/ChatInputNotice/useChatInputNotice.test.tsx
@@ -1,7 +1,7 @@
import { act, renderHook } from '@testing-library/react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
-import { useChatInputNotice } from './useChatInputNotice';
+import { useChatInputNotice, useChatInputNotices } from './useChatInputNotice';
const { toastError } = vi.hoisted(() => ({ toastError: vi.fn() }));
@@ -238,6 +238,27 @@ describe('useChatInputNotice', () => {
expect(result.current).toEqual({ key: 'input.viewOnlyGroup', type: 'warning' });
});
+ it('collects simultaneous input notices without changing the legacy priority result', () => {
+ testState.resourceAccess = {
+ canConfigureResource: false,
+ isAccessLoading: false,
+ isAccessResolved: true,
+ canUseResource: false,
+ isGroupContext: true,
+ isResourceGated: true,
+ };
+ testState.aiInfra.isInitAiProviderRuntimeState = true;
+
+ const notices = renderHook(() => useChatInputNotices());
+ const notice = renderHook(() => useChatInputNotice());
+
+ expect(notices.result.current).toEqual([
+ { key: 'input.viewOnlyGroup', type: 'warning' },
+ { key: 'input.modelUnavailable', type: 'warning' },
+ ]);
+ expect(notice.result.current).toEqual({ key: 'input.viewOnlyGroup', type: 'warning' });
+ });
+
it('stays silent for a gated member who can use but not edit the agent', () => {
// The use-only permission is explained on the controls it actually locks
// (model trigger / device chip), not as a standing banner.
diff --git a/src/features/ChatInput/ChatInputNotice/useChatInputNotice.ts b/src/features/ChatInput/ChatInputNotice/useChatInputNotice.ts
index ae345f4aa5e..3ead607e635 100644
--- a/src/features/ChatInput/ChatInputNotice/useChatInputNotice.ts
+++ b/src/features/ChatInput/ChatInputNotice/useChatInputNotice.ts
@@ -29,6 +29,17 @@ interface ResolveChatInputNoticeParams {
isResourceViewOnly?: boolean;
}
+interface ResolvedChatInputNotice {
+ action?: 'enableModel';
+ key:
+ | 'input.agentModeUnsupportedModel'
+ | 'input.modelDisabled'
+ | 'input.modelUnavailable'
+ | 'input.viewOnlyAgent'
+ | 'input.viewOnlyGroup';
+ type: 'warning';
+}
+
const findEnabledChatModel = (
enabledChatModelList: EnabledProviderWithModels[],
model: string,
@@ -39,7 +50,20 @@ const findEnabledChatModel = (
?.children.find((item) => item.id === model);
};
-export const resolveChatInputNotice = ({
+/**
+ * Resolves every persistent notice that applies to the active chat input.
+ *
+ * Use when:
+ * - Rendering the compact notice summary and its expanded stack
+ * - Inspecting simultaneous permission and model configuration problems
+ *
+ * Expects:
+ * - Fully resolved resource access and effective model state
+ *
+ * Returns:
+ * - Notices ordered from the broadest input blocker to narrower configuration issues
+ */
+export const resolveChatInputNotices = ({
currentChatModel,
isEffectiveModelPending,
isGroupContext,
@@ -48,14 +72,17 @@ export const resolveChatInputNotice = ({
isModelConfigReady,
isResourceViewOnly,
}: ResolveChatInputNoticeParams) => {
+ const notices: ResolvedChatInputNotice[] = [];
+
// View-level General access on the bound agent/group makes the whole input
- // read-only — that outranks any model-config notice (nothing can be sent).
+ // read-only. Keep it first so legacy single-notice consumers retain their
+ // blocker-first behavior while the stack can still explain narrower issues.
if (isResourceViewOnly)
- return {
+ notices.push({
action: undefined,
key: isGroupContext ? 'input.viewOnlyGroup' : 'input.viewOnlyAgent',
type: 'warning',
- } as const;
+ });
// Model-config notices don't apply to heterogeneous agents (own toolchain),
// before the model runtime config is ready, or before the effective model is
@@ -74,13 +101,12 @@ export const resolveChatInputNotice = ({
!currentChatModel
) {
if (isModelDisabled)
- return {
+ notices.push({
action: 'enableModel' as const,
key: 'input.modelDisabled',
type: 'warning',
- } as const;
-
- return { action: undefined, key: 'input.modelUnavailable', type: 'warning' } as const;
+ });
+ else notices.push({ key: 'input.modelUnavailable', type: 'warning' });
}
// Use-level General access (can chat, can't edit the shared config) is
@@ -88,8 +114,24 @@ export const resolveChatInputNotice = ({
// states a permission without naming what it blocks. The locked
// controls explain themselves instead — see `useModelLockTooltip` for the
// model triggers and the fixed-target tooltip on the device chip.
+ return notices;
};
+/**
+ * Resolves the highest-priority notice for legacy single-notice consumers.
+ *
+ * Use when:
+ * - A surface can render only one notice
+ *
+ * Expects:
+ * - The same resolved state accepted by {@link resolveChatInputNotices}
+ *
+ * Returns:
+ * - The first applicable notice, or undefined when the input has no notice
+ */
+export const resolveChatInputNotice = (params: ResolveChatInputNoticeParams) =>
+ resolveChatInputNotices(params)[0];
+
/** Union of every notice shape `resolveChatInputNotice` can return. */
export type ChatInputNotice = NonNullable<ReturnType<typeof resolveChatInputNotice>> & {
actionDisabled?: boolean;
@@ -98,7 +140,19 @@ export type ChatInputNotice = NonNullable<ReturnType<typeof resolveChatInputNoti
onAction?: () => Promise<void>;
};
-export const useChatInputNotice = (): ChatInputNotice | undefined => {
+/**
+ * Collects all persistent notices for the active chat input.
+ *
+ * Use when:
+ * - Rendering the notice summary and expandable stack beside the composer actions
+ *
+ * Expects:
+ * - Chat, agent, permission, and model stores to be available through their providers
+ *
+ * Returns:
+ * - Ordered notices with any available recovery action attached
+ */
+export const useChatInputNotices = (): ChatInputNotice[] => {
const { t } = useTranslation('chat');
const { allowed: canManageAiInfra, reason: aiInfraPermissionReason } =
usePermission('manage_provider_key');
@@ -197,7 +251,7 @@ export const useChatInputNotice = (): ChatInputNotice | undefined => {
);
const { canUseResource, isGroupContext } = useChatInputResourceAccess();
- const notice = resolveChatInputNotice({
+ const notices = resolveChatInputNotices({
currentChatModel,
isEffectiveModelPending:
isAgentConfigLoading || isMemberOverridePending || isActiveTopicPending,
@@ -257,13 +311,29 @@ export const useChatInputNotice = (): ChatInputNotice | undefined => {
updateTopicModel,
]);
- if (notice?.action !== 'enableModel') return notice;
-
- return {
- ...notice,
- actionDisabled: !canManageAiInfra,
- actionDisabledReason: canManageAiInfra ? undefined : aiInfraPermissionReason,
- actionLoading,
- onAction: canManageAiInfra ? handleEnableModel : undefined,
- };
+ return notices.map((notice) =>
+ notice.action === 'enableModel'
+ ? {
+ ...notice,
+ actionDisabled: !canManageAiInfra,
+ actionDisabledReason: canManageAiInfra ? undefined : aiInfraPermissionReason,
+ actionLoading,
+ onAction: canManageAiInfra ? handleEnableModel : undefined,
+ }
+ : notice,
+ );
};
+
+/**
+ * Returns the highest-priority persistent notice for compatibility.
+ *
+ * Use when:
+ * - A caller has not adopted the multi-notice stack yet
+ *
+ * Expects:
+ * - The same providers required by {@link useChatInputNotices}
+ *
+ * Returns:
+ * - The first notice, or undefined when no notice applies
+ */
+export const useChatInputNotice = (): ChatInputNotice | undefined => useChatInputNotices()[0];
diff --git a/src/features/ChatInput/Desktop/index.tsx b/src/features/ChatInput/Desktop/index.tsx
index 94ca3caa073..b72796392e4 100644
--- a/src/features/ChatInput/Desktop/index.tsx
+++ b/src/features/ChatInput/Desktop/index.tsx
@@ -197,6 +197,9 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
// shrink-to-fit box is pushed past the bar's right edge and leaves a
// one-slot hole between the last action and the expand toggle. Keep the
// toggle in a row outside that box.
+ // NOTICE: The hover-only expand button stays in layout at zero opacity to
+ // prevent shifting. Keep the notice before it so the hidden 32px control
+ // does not create a false gap after the microphone action.
const leftSlotContent = (
<Flexbox horizontal align={'center'} flex={'none'} gap={2}>
<Flexbox horizontal align={'center'} className={styles.leftActions}>
@@ -209,13 +212,13 @@ const DesktopChatInput = memo<DesktopChatInputProps>(
/>
)}
</Flexbox>
+ {noticeNode}
<ComposerExpandButton />
</Flexbox>
);
const leftSlot = noticeNode ? (
- <Flexbox horizontal align={'center'} className={styles.leftSlot} gap={4}>
+ <Flexbox horizontal align={'center'} className={styles.leftSlot}>
{leftSlotContent}
- {noticeNode}
</Flexbox>
) : (
leftSlotContent