Repository navigation
feat(agent-chat): the data box shows what it waits for #12221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0f8b1b9
feat(agent-chat): the data box shows what it waits for
MarkusNeusinger 9e97095
chore: reference PR #12221 in the changelog fragment
MarkusNeusinger 72e9a69
fix(agent-chat): box overlay dims the text, survives a drag, never st…
MarkusNeusinger caf62cb
fix(agent-chat): the box count runs from the step's start, long names…
MarkusNeusinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import { BoxWorking } from 'src/sections/agent-chat/BoxWorking'; | ||
| import { act, render, screen } from 'src/test-utils'; | ||
|
|
||
| describe('BoxWorking', () => { | ||
| beforeEach(() => vi.useFakeTimers()); | ||
| afterEach(() => vi.useRealTimers()); | ||
|
|
||
| it('names the step at once and counts the seconds from the first one on', () => { | ||
| render(<BoxWorking line='reading "meter.parquet" on the server' since={Date.now()} />); | ||
| const line = screen.getByTestId('box-working'); | ||
| expect(line).toHaveTextContent(/^# reading "meter\.parquet" on the server …$/); | ||
| expect(line).toHaveAttribute('aria-hidden', 'true'); | ||
|
|
||
| act(() => vi.advanceTimersByTime(3000)); | ||
| expect(line).toHaveTextContent('# reading "meter.parquet" on the server … · 3 s'); | ||
| }); | ||
|
|
||
| it('counts from when the step began, not from when it mounted', () => { | ||
| render(<BoxWorking line="parsing your data" since={Date.now() - 7000} />); | ||
| expect(screen.getByTestId('box-working')).toHaveTextContent('# parsing your data … · 7 s'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| /** | ||
| * What the data box waits for, drawn over it: a file read on the server or a parse. | ||
| * Both take seconds while the box itself does not change, so the line names the step, | ||
| * pulses its `…` and counts the seconds from the second one on, and a thin bar runs | ||
| * along the box's foot: a plain indicator, no spinner (docs/reference/style-guide.md | ||
| * §10.1). Hidden from screen readers, which hear the live line under the box; without | ||
| * motion under `prefers-reduced-motion`, where the counter still moves. | ||
| */ | ||
|
|
||
| import { useEffect, useState } from 'react'; | ||
|
|
||
| import Box from '@mui/material/Box'; | ||
|
|
||
| import { Ellipsis } from 'src/sections/agent-chat/Ellipsis'; | ||
| import { labelSx } from 'src/sections/agent-chat/styles'; | ||
| import { fontSize } from 'src/theme'; | ||
|
|
||
| /** | ||
| * `since`: when the step began (`Date.now()`), kept by the caller so a remount (a collapsed | ||
| * and reopened card) does not restart the count. `hidden`: a drag over the box shows its own | ||
| * hint; the count runs on underneath. | ||
| */ | ||
| export function BoxWorking({ | ||
| line, | ||
| since, | ||
| hidden = false, | ||
| }: { | ||
| line: string; | ||
| since: number; | ||
| hidden?: boolean; | ||
| }) { | ||
| const [mounted] = useState(() => Date.now()); | ||
| const [now, setNow] = useState(mounted); | ||
| useEffect(() => { | ||
| const timer = window.setInterval(() => setNow(Date.now()), 1000); | ||
| return () => window.clearInterval(timer); | ||
| }, []); | ||
| // A step the caller did not time (0) counts from the mount. | ||
| const seconds = Math.max(0, Math.floor((now - (since > 0 ? since : mounted)) / 1000)); | ||
|
|
||
| return ( | ||
| <Box | ||
| aria-hidden | ||
| data-testid="box-working" | ||
| sx={{ | ||
| position: 'absolute', | ||
| inset: 0, | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| p: 2, | ||
| textAlign: 'center', | ||
| pointerEvents: 'none', | ||
| overflow: 'hidden', | ||
| visibility: hidden ? 'hidden' : 'visible', | ||
| // Dims the text underneath, so the line stands out on the box's own surface in both themes. | ||
| bgcolor: 'color-mix(in srgb, var(--bg-elevated) 55%, transparent)', | ||
| borderRadius: '4px', | ||
| }} | ||
| > | ||
| <Box | ||
| component="span" | ||
| sx={{ | ||
| ...labelSx, | ||
| fontSize: fontSize.md, | ||
| color: 'var(--ink)', | ||
| bgcolor: 'var(--bg-elevated)', | ||
| border: '1px solid var(--rule)', | ||
| borderRadius: '4px', | ||
| px: 1.5, | ||
| py: 0.75, | ||
| // A long file or sheet name without spaces wraps instead of being clipped on a phone. | ||
| minWidth: 0, | ||
| maxWidth: '100%', | ||
| overflowWrap: 'anywhere', | ||
| }} | ||
| > | ||
| # {line} <Ellipsis /> | ||
| {seconds >= 1 ? ` · ${seconds} s` : ''} | ||
| </Box> | ||
| <Box | ||
| sx={{ | ||
| position: 'absolute', | ||
| left: 0, | ||
| right: 0, | ||
| bottom: 0, | ||
| height: '2px', | ||
| overflow: 'hidden', | ||
| '@media (prefers-reduced-motion: reduce)': { display: 'none' }, | ||
| }} | ||
| > | ||
| <Box | ||
| sx={{ | ||
| '@keyframes agentBoxWorking': { | ||
| '0%': { transform: 'translateX(-100%)' }, | ||
| '100%': { transform: 'translateX(340%)' }, | ||
| }, | ||
| width: '30%', | ||
| height: '100%', | ||
| bgcolor: 'var(--ink-soft)', | ||
| animation: 'agentBoxWorking 1.6s ease-in-out infinite', | ||
| }} | ||
| /> | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ### Changed | ||
|
|
||
| - **The data box says what it waits for.** While a dropped Parquet, Excel, | ||
| OpenDocument, Feather or NumPy file is read on the server, and while | ||
| `.parse()` runs, the box shows `# reading "x.parquet" on the server … · 4 s` | ||
| or `# parsing your data … · 3 s` over itself: a pulsing `…`, a seconds counter | ||
| and a thin bar along its foot. Before, only the buttons greyed out and a quiet | ||
| line under them changed, so the page looked stuck for the several seconds a | ||
| sandbox read takes. (#12221) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.