Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(web): make the citation toggle a button (#40204)
yyh30ca836e0306
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.jsonindex 0995e0da8ff..0548cba730f 100644--- a/oxlint-suppressions.json+++ b/oxlint-suppressions.json@@ -817,12 +817,6 @@"web/app/components/base/chat/chat/citation/index.tsx": {"eslint-react/set-state-in-effect": {"count": 1- },- "jsx_a11y/click-events-have-key-events": {- "count": 1- },- "jsx_a11y/no-static-element-interactions": {- "count": 1}},"web/app/components/base/chat/chat/hooks.ts": {diff --git a/web/app/components/base/chat/chat/citation/__tests__/index.spec.tsx b/web/app/components/base/chat/chat/citation/__tests__/index.spec.tsxindex f734db90c13..1d5349124f6 100644--- a/web/app/components/base/chat/chat/citation/__tests__/index.spec.tsx+++ b/web/app/components/base/chat/chat/citation/__tests__/index.spec.tsx@@ -226,7 +226,7 @@ describe('Citation', () => {/>,)expect(screen.getAllByTestId('popup')).toHaveLength(3)- expect(screen.queryByTestId('citation-more-toggle')).not.toBeInTheDocument()+ expect(screen.queryByRole('button')).not.toBeInTheDocument()})})@@ -246,7 +246,11 @@ describe('Citation', () => {]}/>,)- expect(screen.getByTestId('citation-more-toggle')).toBeInTheDocument()+ expect(+ screen.getByRole('button', {+ name: 'share.chat.expand common.chat.citation.title',+ }),+ ).toHaveAttribute('aria-expanded', 'false')})})@@ -268,7 +272,11 @@ describe('Citation', () => {]}/>,)- expect(screen.getByTestId('citation-more-toggle')).toBeInTheDocument()+ expect(+ screen.getByRole('button', {+ name: 'share.chat.expand common.chat.citation.title',+ }),+ ).toHaveAttribute('aria-expanded', 'false')expect(screen.getAllByTestId('popup')).toHaveLength(2)})})@@ -290,43 +298,75 @@ describe('Citation', () => {]}/>,)- return screen.getByTestId('citation-more-toggle')+ return screen.getByRole('button', {+ name: 'share.chat.expand common.chat.citation.title',+ })}it('should show the overflow count label matching /+\\s*\\d+/ on the more-toggle in collapsed state', () => {- renderOverflowScenario()- expect(screen.getByTestId('citation-more-toggle').textContent).toMatch(/^\+\s*\d+$/)+ const toggle = renderOverflowScenario()+ expect(toggle).toHaveAttribute('aria-expanded', 'false')+ expect(toggle.textContent).toMatch(/^\+\s*\d+$/)})- it('should display the collapse icon div after clicking more-toggle to expand', async () => {+ it('should expose the expanded state and collapse action after clicking more-toggle', async () => {const user = userEvent.setup()- renderOverflowScenario()+ const toggle = renderOverflowScenario()- await user.click(screen.getByTestId('citation-more-toggle'))+ await user.click(toggle)- expect(document.querySelector('.i-ri-arrow-down-s-line')).toBeInTheDocument()+ expect(+ screen.getByRole('button', {+ name: 'share.chat.collapse common.chat.citation.title',+ }),+ ).toHaveAttribute('aria-expanded', 'true')})it('should return to the count label after clicking the toggle a second time to collapse', async () => {const user = userEvent.setup()- renderOverflowScenario()+ const toggle = renderOverflowScenario()- await user.click(screen.getByTestId('citation-more-toggle'))- await user.click(screen.getByTestId('citation-more-toggle'))+ await user.click(toggle)+ await user.click(+ screen.getByRole('button', {+ name: 'share.chat.collapse common.chat.citation.title',+ }),+ )- expect(screen.getByTestId('citation-more-toggle').textContent).toMatch(/^\+\s*\d+$/)+ expect(+ screen.getByRole('button', {+ name: 'share.chat.expand common.chat.citation.title',+ }).textContent,+ ).toMatch(/^\+\s*\d+$/)})it('should show all resource popups after expanding via the more-toggle', async () => {const user = userEvent.setup()- renderOverflowScenario()+ const toggle = renderOverflowScenario()- await user.click(screen.getByTestId('citation-more-toggle'))+ await user.click(toggle)await waitFor(() => {expect(screen.getAllByTestId('popup')).toHaveLength(3)})})++ it.each([+ ['Enter', '{Enter}'],+ ['Space', ' '],+ ])('should expand with the %s key', async (_, key) => {+ const user = userEvent.setup()+ const toggle = renderOverflowScenario()++ toggle.focus()+ await user.keyboard(key)++ expect(+ screen.getByRole('button', {+ name: 'share.chat.collapse common.chat.citation.title',+ }),+ ).toHaveAttribute('aria-expanded', 'true')+ })})describe('Edge Cases', () => {@@ -335,7 +375,7 @@ describe('Citation', () => {setupContainer()render(<Citation data={[makeCitationItem()]} />)expect(screen.getAllByTestId('citation-measurement-item')).toHaveLength(1)- expect(screen.queryByTestId('citation-more-toggle')).not.toBeInTheDocument()+ expect(screen.queryByRole('button')).not.toBeInTheDocument()})it('should handle all citations sharing one document_id as a single resource', () => {diff --git a/web/app/components/base/chat/chat/citation/index.tsx b/web/app/components/base/chat/chat/citation/index.tsxindex 9e57636bdf5..8053e79f9b1 100644--- a/web/app/components/base/chat/chat/citation/index.tsx+++ b/web/app/components/base/chat/chat/citation/index.tsx@@ -72,6 +72,12 @@ const Citation: FC<CitationProps> = ({}, [])const resourcesLength = resources.length+ const citationTitle = t(($) => $['chat.citation.title'], { ns: 'common' })+ const citationToggleLabel = `${+ showMore+ ? t(($) => $['chat.collapse'], { ns: 'share' })+ : t(($) => $['chat.expand'], { ns: 'share' })+ } ${citationTitle}`return (<div className="mt-3 -mb-1">@@ -79,7 +85,7 @@ const Citation: FC<CitationProps> = ({data-testid="citation-title"className="mb-2 flex items-center system-xs-medium text-text-tertiary">- {t(($) => $['chat.citation.title'], { ns: 'common' })}+ {citationTitle}<div className="ml-2 h-px grow bg-divider-regular" /></div><div className="relative flex flex-wrap">@@ -102,17 +108,22 @@ const Citation: FC<CitationProps> = ({</div>))}{limitNumberInOneLine < resourcesLength && (- <div- data-testid="citation-more-toggle"- className="flex h-7 cursor-pointer items-center rounded-lg bg-components-panel-bg px-2 system-xs-medium text-text-tertiary"+ <button+ type="button"+ aria-expanded={showMore}+ aria-label={citationToggleLabel}+ className="flex h-7 cursor-pointer appearance-none items-center rounded-lg bg-components-panel-bg px-2 system-xs-medium text-text-tertiary focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"onClick={() => setShowMore((v) => !v)}>{!showMore ? (`+ ${resourcesLength - limitNumberInOneLine}`) : (- <div className="i-ri-arrow-down-s-line size-4 rotate-180 text-text-tertiary" />+ <span+ aria-hidden+ className="i-ri-arrow-down-s-line size-4 rotate-180 text-text-tertiary"+ />)}- </div>+ </button>)}</div></div>