Repository navigation
🪶 feat: Quiet Prompt Editor Boxes, Table Columns and Destructive Buttons #16751
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
9 commits
Select commit
Hold shift + click to select a range
19c5ade
feat: Quiet Prompt Editor Boxes, Table Columns and Destructive Button…
berry-13 485203e
fix: Outrank the Cell Border Color With the Column Rule Share
berry-13 250fa6a
fix: Keep the First Table Cell's Outer Edge Under the Inset Share
berry-13 3da58de
fix: Keep the Batched Edit Divider on the Light Border
berry-13 8ff15f9
fix: Keep Web Search Source Row Separators on the Light Border
berry-13 877eb18
fix: Quiet the Result Switcher Divider and Keep the RTL Table Edge
berry-13 bdc894e
fix: Resolve Table Edges by Cell Direction and Keep the Variables Car…
berry-13 e1a5a64
fix: Draw Table Frame Edges in Logical Terms So Direction Needs No Se…
berry-13 303b632
fix: Keep Soft Destructive Hover and Pressed Tints Above 4.5:1
berry-13 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
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
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
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
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,189 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import type { Page } from '@playwright/test'; | ||
| import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse'; | ||
| import { NEW_CHAT_PATH } from '../helpers'; | ||
|
|
||
| /** | ||
| * The prompt-editor and table surfaces of the ClickHouse border switch. A `destructive` Button is | ||
| * solid by default and a 10% tint under the destructive ink when the theme's `destructiveStyle` is | ||
| * `soft`; `border-inset-medium` is `border-medium` at the inset share, so the prompt editor's form | ||
| * boxes keep their edge in the bundled themes and drop it in ClickHouse; and a markdown table keeps | ||
| * its column rules only while the inset share is above zero, and always its outer left edge, whichever way the table is laid out, including a right-to-left | ||
| * table under a left-to-right page. The probes carry the classes the | ||
| * components compose, so only the roles style them. | ||
| */ | ||
|
|
||
| type Mode = 'light' | 'dark'; | ||
| type Paint = { | ||
| destructive: string; | ||
| inset: string; | ||
| column: string; | ||
| frame: string; | ||
| rtlColumn: string; | ||
| rtlFrame: string; | ||
| rtlInner: string; | ||
| }; | ||
|
|
||
| const SOFT_THEME = { | ||
| version: 1, | ||
| name: 'e2e-prompt-surfaces', | ||
| modes: { | ||
| light: { | ||
| colors: { 'rgb-border-medium': '10 20 30', 'rgb-surface-destructive': '200 0 0' }, | ||
| appearance: { destructiveStyle: 'soft', insetBorderAlpha: '0.5' }, | ||
| }, | ||
| dark: { | ||
| colors: { 'rgb-border-medium': '10 20 30', 'rgb-surface-destructive': '200 0 0' }, | ||
| appearance: { destructiveStyle: 'soft', insetBorderAlpha: '0.5' }, | ||
| }, | ||
| }, | ||
| } as const; | ||
|
|
||
| async function openChat(page: Page, mode: Mode, definition?: { name: string }) { | ||
| await page.addInitScript( | ||
| ([appearance, stored]) => { | ||
| localStorage.setItem('color-theme', appearance as string); | ||
| localStorage.removeItem('theme-colors'); | ||
| localStorage.removeItem('theme-name'); | ||
| if (stored) { | ||
| localStorage.setItem('theme-definition', JSON.stringify(stored)); | ||
| localStorage.setItem('theme-source', 'definition'); | ||
| } else { | ||
| localStorage.removeItem('theme-definition'); | ||
| localStorage.removeItem('theme-source'); | ||
| } | ||
| }, | ||
| [mode, definition ?? null] as [string, unknown], | ||
| ); | ||
| await page.goto(NEW_CHAT_PATH, { timeout: 15000 }); | ||
| await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible({ | ||
| timeout: 30000, | ||
| }); | ||
| const root = page.locator('html'); | ||
| if (definition) { | ||
| await expect(root).toHaveAttribute('data-theme', definition.name); | ||
| } else { | ||
| await expect(root).not.toHaveAttribute('data-theme'); | ||
| } | ||
| await expect(root).toHaveClass(mode === 'dark' ? /\bdark\b/ : /\blight\b/); | ||
| } | ||
|
|
||
| function paint(page: Page): Promise<Paint> { | ||
| return page.evaluate(() => { | ||
| const read = (html: string, pick: (node: Element) => string, className = '') => { | ||
| const host = document.createElement('div'); | ||
| host.className = className; | ||
| host.innerHTML = html; | ||
| document.body.append(host); | ||
| const value = pick(host.firstElementChild as Element); | ||
| host.remove(); | ||
| return value; | ||
| }; | ||
| const rtl = (html: string, pick: (node: Element) => string) => { | ||
| const host = document.createElement('div'); | ||
| host.className = 'markdown'; | ||
| host.dir = 'rtl'; | ||
| host.innerHTML = html; | ||
| document.body.append(host); | ||
| const value = pick(host.firstElementChild as Element); | ||
| host.remove(); | ||
| return value; | ||
| }; | ||
| return { | ||
| destructive: read( | ||
| '<div class="bg-surface-destructive theme-destructive-soft:bg-surface-destructive/10"></div>', | ||
| (node) => getComputedStyle(node).backgroundColor, | ||
| ), | ||
| inset: read( | ||
| '<div class="border border-solid border-border-inset-medium"></div>', | ||
| (node) => getComputedStyle(node).borderTopColor, | ||
| ), | ||
| column: read( | ||
| '<table><tbody><tr><td>one</td><td>two</td></tr></tbody></table>', | ||
| (node) => getComputedStyle(node.querySelectorAll('td')[1]).borderLeftColor, | ||
| 'markdown', | ||
| ), | ||
| frame: read( | ||
| '<table><tbody><tr><td>one</td><td>two</td></tr></tbody></table>', | ||
| (node) => getComputedStyle(node.querySelector('td') as Element).borderLeftColor, | ||
| 'markdown', | ||
| ), | ||
| rtlColumn: rtl( | ||
| '<table><tbody><tr><td>one</td><td>two</td></tr></tbody></table>', | ||
| (node) => getComputedStyle(node.querySelector('td') as Element).borderLeftColor, | ||
| ), | ||
| rtlFrame: rtl( | ||
| '<table><tbody><tr><td>one</td><td>two</td></tr></tbody></table>', | ||
| (node) => getComputedStyle(node.querySelectorAll('td')[1]).borderLeftColor, | ||
| ), | ||
| rtlInner: rtl( | ||
| '<table><tbody><tr><td>one</td><td>two</td></tr></tbody></table>', | ||
| (node) => getComputedStyle(node.querySelectorAll('td')[1]).borderRightColor, | ||
| ), | ||
| }; | ||
| }); | ||
| } | ||
|
|
||
| /** An opaque color computes to `rgb(...)`; a tint or a drawn-away color carries an alpha slot. */ | ||
| const opaque = /^rgb\(\d+, \d+, \d+\)$/; | ||
| const clear = /(\/ 0\)|, 0\)|\/ 0\.0*\))$/; | ||
| const tinted = /(\/ 0\.1\d*\)|, 0\.1\d*\))$/; | ||
|
|
||
| /** Each tag is written out whole: the runner finds a scenario by its literal tag. */ | ||
| const CASES: Array<{ | ||
| title: string; | ||
| mode: Mode; | ||
| definition?: { name: string }; | ||
| expects: { [K in Exclude<keyof Paint, 'frame' | 'rtlColumn' | 'rtlFrame' | 'rtlInner'>]: RegExp }; | ||
| }> = [ | ||
| { | ||
| title: | ||
| 'the default light theme keeps a solid destructive button, form box edge and column rule @scenario:prompt-surfaces-default-light-unchanged', | ||
| mode: 'light', | ||
| expects: { destructive: opaque, inset: opaque, column: opaque }, | ||
| }, | ||
| { | ||
| title: | ||
| 'the default dark theme keeps a solid destructive button, form box edge and column rule @scenario:prompt-surfaces-default-dark-unchanged', | ||
| mode: 'dark', | ||
| expects: { destructive: opaque, inset: opaque, column: opaque }, | ||
| }, | ||
| { | ||
| title: | ||
| 'the ClickHouse light theme tints the destructive button and draws no form box edge or column rule @scenario:prompt-surfaces-clickhouse-light', | ||
| mode: 'light', | ||
| definition: clickHouseTheme, | ||
| expects: { destructive: tinted, inset: clear, column: clear }, | ||
| }, | ||
| { | ||
| title: | ||
| 'the ClickHouse dark theme tints the destructive button and draws no form box edge or column rule @scenario:prompt-surfaces-clickhouse-dark', | ||
| mode: 'dark', | ||
| definition: clickHouseTheme, | ||
| expects: { destructive: tinted, inset: clear, column: clear }, | ||
| }, | ||
| { | ||
| title: | ||
| 'a theme that names the destructive style and inset share follows both @scenario:prompt-surfaces-follow-reference-theme', | ||
| mode: 'light', | ||
| definition: SOFT_THEME, | ||
| expects: { destructive: tinted, inset: /0\.5\)$/, column: /0\.5\)$/ }, | ||
| }, | ||
| ]; | ||
|
|
||
| test.describe('prompt editor and table surfaces', () => { | ||
| for (const { title, mode, definition, expects } of CASES) { | ||
| test(title, async ({ page }) => { | ||
| await openChat(page, mode, definition); | ||
|
|
||
| const painted = await paint(page); | ||
| expect(painted.destructive).toMatch(expects.destructive); | ||
| expect(painted.inset).toMatch(expects.inset); | ||
| expect(painted.column).toMatch(expects.column); | ||
| expect(painted.frame).toMatch(opaque); | ||
| expect(painted.rtlColumn).toMatch(expects.column); | ||
| expect(painted.rtlFrame).toMatch(opaque); | ||
| expect(painted.rtlInner).toMatch(expects.column); | ||
| }); | ||
| } | ||
| }); |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When code execution has more than one result, this newly inset output section is immediately followed by
ResultSwitcher, whose root still usesborder-border-lightfor its top border. Consequently, a theme such as ClickHouse withinsetBorderAlpha: '0'still draws an internal rule at the bottom of the output, so the code block is only quiet for single-result executions. Change that divider to the inset border role as well and cover the multi-result state.AGENTS.md reference: AGENTS.md:L142-L151
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 877eb18: the result switcher divider draws border-border-inset, so a multi-result code block is quiet end to end.