Repository navigation
fix(uiux): round-1 bug-hunt fixes with swipe-dismiss preserved (rework of #298) #562
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import "../tests/setup-dom.mjs"; | ||
| import assert from "node:assert/strict"; | ||
| import test from "node:test"; | ||
| import { act, createElement } from "react"; | ||
| const { cleanup, fireEvent, render, within } = await import("@testing-library/react/pure.js"); | ||
| const { SettingsConfig } = await import("./SettingsConfig"); | ||
|
|
||
| const noop = () => {}; | ||
| const settle = () => act(() => new Promise((resolve) => setTimeout(resolve, 20))); | ||
|
|
||
| const settingsProps = { | ||
| activeTab: "system", | ||
| toolCallsDefaultCollapsed: false, onToolCallsDefaultCollapsedChange: noop, | ||
| hideToolActivity: false, onHideToolActivityChange: noop, | ||
| expandThinkingByDefault: false, onExpandThinkingByDefaultChange: noop, onHideThinkingBlockChange: noop, | ||
| providerUsageVisible: false, onProviderUsageVisibleChange: noop, | ||
| scopeNativeSelectAll: false, onScopeNativeSelectAllChange: noop, | ||
| openUrlAutomatically: false, onOpenUrlAutomaticallyChange: noop, | ||
| cwd: null, remoteHost: false, sessionId: null, | ||
| onModelsSaved: noop, onPluginsReloaded: noop, | ||
| appUpdate: null, onRefreshAppUpdate: async () => null, | ||
| onRequestAppUpdate: noop, onSelectTab: noop, onClose: noop, | ||
| }; | ||
|
|
||
| /** `get` answers the settings load; each PUT waits until the test releases it. */ | ||
| function fakeSettings(t, get) { | ||
| const puts = []; | ||
| const originalFetch = globalThis.fetch; | ||
| globalThis.fetch = async (url, init) => { | ||
| if (String(url) !== "/api/web-settings") return Response.json({}); | ||
| if (init?.method === "PUT") { | ||
| const { promise, resolve } = Promise.withResolvers(); | ||
| puts.push({ body: init.body, release: () => resolve(Response.json({})) }); | ||
| return promise; | ||
| } | ||
| return get(); | ||
| }; | ||
| t.after(() => { | ||
| cleanup(); | ||
| globalThis.fetch = originalFetch; | ||
| }); | ||
| return puts; | ||
| } | ||
|
|
||
| // Two overlapping PUTs can resolve out of order and leave the UI showing the | ||
| // opposite of the server value — for the agent-tools toggle, a security | ||
| // boundary. Each switch must take no second change until its save lands. | ||
| for (const [label, body] of [ | ||
| ["Resume running sessions after a restart", '{"autoResumeSessions":true}'], | ||
| ["Agent tools (cross-session)", '{"agentToolsEnabled":true}'], | ||
| ]) { | ||
| test(`${label}: the switch takes no second change until its save lands`, async (t) => { | ||
| const puts = fakeSettings(t, () => Response.json({ autoResumeSessions: false, agentToolsEnabled: false })); | ||
| const { container } = render(createElement(SettingsConfig, settingsProps)); | ||
| await settle(); | ||
| const toggle = within(container).getByRole("switch", { name: label }); | ||
| assert.equal(toggle.disabled, false); | ||
|
|
||
| fireEvent.click(toggle); | ||
| await settle(); | ||
| assert.deepEqual(puts.map((p) => p.body), [body]); | ||
| assert.equal(toggle.disabled, true, "an off click now could reach the server before the on"); | ||
| fireEvent.click(toggle); | ||
| await settle(); | ||
| assert.equal(puts.length, 1); | ||
|
|
||
| puts[0].release(); | ||
| await settle(); | ||
| assert.equal(toggle.disabled, false); | ||
| assert.equal(toggle.getAttribute("aria-checked"), "true"); | ||
| }); | ||
| } |
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.
Expose disclosure-control semantics without breaking swipes.
The new tab stop is a plain
span. Enter and Space work, but the control has no button role for assistive technology. The disclosure pattern requires button semantics witharia-expanded. (w3.org)Provide a semantic disclosure control and preserve description-origin swipes through a separate control or adjusted gesture handling. Adding
role="button"alone would conflict with the gesture constraint documented here.Based on learnings, span buttons require “role="button", tabIndex={0}, Enter/Space activation.”
Source: Learnings