Skip to content

Commit 0707768

Browse files
authored
fix(sessions): stop footer status line overlapping diff stats when narrow (#3258)
1 parent 12bf0c1 commit 0707768

2 files changed

Lines changed: 85 additions & 12 deletions

File tree

packages/ui/src/features/sessions/components/GeneratingIndicator.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,22 @@ export function GeneratingIndicator({
171171
<Flex
172172
align="center"
173173
gap="2"
174-
className="select-none select-none"
174+
className="min-w-0 select-none"
175175
style={{ WebkitUserSelect: "none" }}
176176
>
177-
<Brain size={12} className="ph-pulse" />
178-
<Text className="text-[13px] text-accent-11">{activity}...</Text>
179-
<Text color="gray" className="text-[13px]">
177+
<Brain size={12} className="ph-pulse shrink-0" />
178+
<Text className="truncate text-[13px] text-accent-11">{activity}...</Text>
179+
{/* The hint shrinks (and truncates) well before the activity word does. */}
180+
<Text color="gray" className="shrink-[8] truncate text-[13px]">
180181
(Esc to stop
181-
</Text>
182-
<Circle size={4} weight="fill" className="mx-[2px] my-0 text-gray-9" />
183-
<Text
184-
color="gray"
185-
style={{ fontVariantNumeric: "tabular-nums" }}
186-
className="text-[13px]"
187-
>
188-
{formatDuration(elapsed, 1)})
182+
<Circle
183+
size={4}
184+
weight="fill"
185+
className="mx-1 inline-block align-middle text-gray-9"
186+
/>
187+
<span style={{ fontVariantNumeric: "tabular-nums" }}>
188+
{formatDuration(elapsed, 1)})
189+
</span>
189190
</Text>
190191
</Flex>
191192
);
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { SessionFooter } from "@posthog/ui/features/sessions/components/SessionFooter";
2+
import type { ContextUsage } from "@posthog/ui/features/sessions/hooks/useContextUsage";
3+
import type { Meta, StoryObj } from "@storybook/react-vite";
4+
5+
const meta: Meta<typeof SessionFooter> = {
6+
title: "Sessions/SessionFooter",
7+
component: SessionFooter,
8+
parameters: {
9+
layout: "padded",
10+
},
11+
};
12+
13+
export default meta;
14+
type Story = StoryObj<typeof SessionFooter>;
15+
16+
const usage: ContextUsage = {
17+
used: 788_000,
18+
size: 1_000_000,
19+
percentage: 79,
20+
cost: null,
21+
breakdown: null,
22+
};
23+
24+
const generatingArgs = {
25+
isPromptPending: true,
26+
promptStartedAt: Date.now() - 5_400,
27+
lastGenerationDuration: null,
28+
usage,
29+
};
30+
31+
/** Wraps the footer in fixed-width boxes so narrow panes are easy to eyeball. */
32+
function AtWidths({ args }: { args: Parameters<typeof SessionFooter>[0] }) {
33+
return (
34+
<div className="flex flex-col gap-4">
35+
{[720, 480, 400, 340, 280, 220].map((width) => (
36+
<div key={width}>
37+
<div className="mb-1 text-[11px] text-gray-9">{width}px</div>
38+
<div
39+
className="rounded border border-gray-6 border-dashed px-2"
40+
style={{ width }}
41+
>
42+
<SessionFooter {...args} />
43+
</div>
44+
</div>
45+
))}
46+
</div>
47+
);
48+
}
49+
50+
export const GeneratingAtNarrowWidths: Story = {
51+
args: generatingArgs,
52+
render: (args) => <AtWidths args={args} />,
53+
};
54+
55+
export const GeneratingWithQueueAtNarrowWidths: Story = {
56+
args: { ...generatingArgs, queuedCount: 2 },
57+
render: (args) => <AtWidths args={args} />,
58+
};
59+
60+
export const AwaitingPermissionAtNarrowWidths: Story = {
61+
args: { ...generatingArgs, hasPendingPermission: true },
62+
render: (args) => <AtWidths args={args} />,
63+
};
64+
65+
export const IdleAtNarrowWidths: Story = {
66+
args: {
67+
isPromptPending: false,
68+
lastGenerationDuration: 331_000,
69+
usage,
70+
},
71+
render: (args) => <AtWidths args={args} />,
72+
};

0 commit comments

Comments
 (0)