Skip to content

Commit c0e42aa

Browse files
fix(chat): footer actions and the sources strip keep the loading standard (one switch, marked items, no hidden ones). CU-17tkuw5yk9q
The strip and the footer actions from #2870 left lib main with 5 loading-standard findings, which failed Test Node for every branch. FooterAction is now the one switch the footer actions go through; the strip draws its full skeleton count and marks its items. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a60fa80 commit c0e42aa

3 files changed

Lines changed: 58 additions & 36 deletions

File tree

‎openframe-frontend-core/src/components/chat/embeddable-chat.tsx‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,8 @@ function dispatchSlashCommandAction(
821821
/** A no-break space: one line of the chip's text, so a bar that holds it is exactly one text line tall. */
822822
const ONE_TEXT_LINE = '\u00a0';
823823

824-
/** How many chips the strip's loading form draws: the count real answers' strips showed (measured). On a phone,
825-
* where a strip holds one chip a row, it draws one. */
824+
/** How many chips the strip's loading form draws: the count real answers' strips showed (measured). Drawn at every
825+
* width: a chip past the row's end is cut. */
826826
const SOURCE_CHIP_SKELETON_COUNT = 2;
827827

828828
/**
@@ -831,7 +831,11 @@ const SOURCE_CHIP_SKELETON_COUNT = 2;
831831
*/
832832
function SourceChipSkeleton({ className }: { className?: string }) {
833833
return (
834-
<span aria-hidden className={cn('pointer-events-none inline-flex shrink-0 items-center', className)}>
834+
<span
835+
aria-hidden
836+
data-loading-item
837+
className={cn('pointer-events-none inline-flex shrink-0 items-center', className)}
838+
>
835839
<span className={chatChipClass({ tone: 'secondary' })}>
836840
<span className={cn(SKELETON_SURFACE_CLASS, 'inline-block h-3.5 w-3.5 rounded-sm')} />
837841
<span className={cn(SKELETON_SURFACE_CLASS, 'w-28 rounded-sm')}>{ONE_TEXT_LINE}</span>
@@ -1059,11 +1063,11 @@ function SourceChips({
10591063
<span className="uppercase text-ods-text-muted text-h6">
10601064
<TextHold>Sources</TextHold>
10611065
</span>
1062-
{/* One row at every width: a chip that does not fit is cut, never wrapped (a strip's chips fit one row in
1063-
the answers measured, and a wrapped skeleton shrinks when the answer ends). */}
1066+
{/* One row at every width: a chip that does not fit is cut, never wrapped or hidden (a strip's chips fit one
1067+
row in the answers measured, and a wrapped skeleton shrinks when the answer ends). */}
10641068
<div className="flex flex-nowrap gap-1.5 overflow-hidden">
10651069
{Array.from({ length: SOURCE_CHIP_SKELETON_COUNT }, (_, i) => (
1066-
<SourceChipSkeleton key={i} className={i > 0 ? 'max-md:hidden' : undefined} />
1070+
<SourceChipSkeleton key={i} />
10671071
))}
10681072
</div>
10691073
</div>
@@ -1100,14 +1104,16 @@ function SourceChips({
11001104
<span className="uppercase text-ods-text-muted text-h6">Sources</span>
11011105
<div className={`flex flex-wrap gap-1.5 ${expanded ? 'max-h-[200px] overflow-y-auto overscroll-contain' : ''}`}>
11021106
{cited.map(src => (
1103-
<SourceChip
1104-
key={src.index}
1105-
src={src}
1106-
baseRoute={baseRoute}
1107-
chipBasePlatform={chipBasePlatform}
1108-
onClose={onClose}
1109-
onDiscuss={onDiscuss}
1110-
/>
1107+
// The loaded list beside the loading form's: each chip an item of it (`contents`: no box of its own).
1108+
<span key={src.index} data-loading-item className="contents">
1109+
<SourceChip
1110+
src={src}
1111+
baseRoute={baseRoute}
1112+
chipBasePlatform={chipBasePlatform}
1113+
onClose={onClose}
1114+
onDiscuss={onDiscuss}
1115+
/>
1116+
</span>
11111117
))}
11121118
{expanded &&
11131119
uncited.map(src => (

‎openframe-frontend-core/src/components/chat/entity-cards/chat-card-disclosure.tsx‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@
2828
import type React from 'react';
2929
import { type ReactNode, useState } from 'react';
3030
import { PlayIcon } from '../../icons-v2-generated/media-playback/play-icon';
31-
import { Button } from '../../ui/button';
3231
import type { ChatRef } from '../chat-ref.types';
3332
import { ExpandChevron } from '../expand-chevron';
3433
import { useCollapsible } from '../hooks/use-collapsible';
35-
import { CARD_FOOTER_ACTION_CLASS, FooterActionSkeleton } from '../source-action-button';
34+
import { CARD_FOOTER_ACTION_CLASS, FooterAction } from '../source-action-button';
3635
import { ChatVideoEntityCard } from './chat-video-entity-card';
3736

3837
/** The kinds of content a chat card can open below itself. */
@@ -142,13 +141,13 @@ export function ChatCardDisclosureButton({
142141
loading?: boolean;
143142
}): React.ReactElement {
144143
const spec = CHAT_CARD_DISCLOSURES[kind];
145-
if (loading) return <FooterActionSkeleton label={spec.label} className={CARD_FOOTER_ACTION_CLASS} />;
146144
const label = open ? spec.openLabel : spec.label;
147145
const Icon = spec.icon;
148146
return (
149-
<Button
150-
variant="transparent"
151-
size="small"
147+
<FooterAction
148+
// The closed label: what a card that can carry this content shows while it loads.
149+
label={loading ? spec.label : label}
150+
loading={loading}
152151
leftIcon={<Icon className="!h-3 !w-3" />}
153152
rightIcon={<ExpandChevron expanded={open} className="!h-3 !w-3" />}
154153
onClick={(e: React.MouseEvent) => {
@@ -162,7 +161,7 @@ export function ChatCardDisclosureButton({
162161
className={CARD_FOOTER_ACTION_CLASS}
163162
>
164163
{label}
165-
</Button>
164+
</FooterAction>
166165
);
167166
}
168167

‎openframe-frontend-core/src/components/chat/source-action-button.tsx‎

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
import { MessageSquare, FileText } from 'lucide-react';
2222
import type React from 'react';
2323
import { cn } from '../../utils/cn';
24-
import { Button } from '../ui/button';
24+
import { Button, type ButtonProps } from '../ui/button';
2525
import { TextHold } from '../ui/layout-hold';
26+
import { useLoadingScope } from '../ui/loading-scope';
2627
import { SKELETON_SURFACE_CLASS } from '../ui/skeleton-surface';
2728
import type { ChatRef } from './chat-ref.types';
2829

@@ -117,6 +118,31 @@ export function FooterActionSkeleton({
117118
);
118119
}
119120

121+
/**
122+
* A card footer's action (Ask, Display, Watch video): the transparent button, or its loading form
123+
* (`FooterActionSkeleton`) in a loading scope or while `loading`. The one switch every footer action goes through.
124+
*/
125+
export function FooterAction({
126+
label,
127+
loading = false,
128+
showLabel = true,
129+
size = 'small',
130+
className = '',
131+
...props
132+
}: Omit<ButtonProps, 'variant' | 'size' | 'className'> & {
133+
/** The action's name: what its loading form holds the width of. */
134+
label: string;
135+
loading?: boolean;
136+
showLabel?: boolean;
137+
size?: 'small' | 'icon';
138+
className?: string;
139+
}): React.ReactElement {
140+
if (useLoadingScope() || loading) {
141+
return <FooterActionSkeleton label={label} size={size} showLabel={showLabel} className={className} />;
142+
}
143+
return <Button variant="transparent" size={size} className={className} {...props} />;
144+
}
145+
120146
export function SourceActionButton({
121147
chatRef,
122148
onDiscuss,
@@ -126,17 +152,6 @@ export function SourceActionButton({
126152
loading,
127153
}: SourceActionButtonProps): React.ReactElement | null {
128154
if (!chatRef || !onDiscuss) return null;
129-
if (loading) {
130-
const s = DENSITY_STYLES[density];
131-
return (
132-
<FooterActionSkeleton
133-
label={label}
134-
size={s.size}
135-
showLabel={s.showLabel}
136-
className={`${s.className}${className ? ` ${className}` : ''}`}
137-
/>
138-
);
139-
}
140155

141156
// Label-driven icon. "Display" reads as a verbatim-content action so a
142157
// FileText icon reinforces "show me the body" semantics; the default
@@ -154,16 +169,18 @@ export function SourceActionButton({
154169
const icon = <IconComponent className={styles.iconSize} />;
155170

156171
return (
157-
<Button
158-
variant="transparent"
172+
<FooterAction
173+
label={label}
174+
loading={loading}
159175
size={styles.size}
176+
showLabel={styles.showLabel}
160177
leftIcon={styles.showLabel ? icon : undefined}
161178
onClick={handle}
162179
aria-label={verbLabel}
163180
title={verbLabel}
164181
className={`${styles.className}${className ? ` ${className}` : ''}`}
165182
>
166183
{styles.showLabel ? label : icon}
167-
</Button>
184+
</FooterAction>
168185
);
169186
}

0 commit comments

Comments
 (0)