Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(web): align composer accessory rail spacing (#580)

Gener588e8369becd
diff --git a/src/web/src/components/community/messages/composer-accessory-rail.test.ts b/src/web/src/components/community/messages/composer-accessory-rail.test.ts
index 5a3aa71f5..0cfad582c 100644
--- a/src/web/src/components/community/messages/composer-accessory-rail.test.ts
+++ b/src/web/src/components/community/messages/composer-accessory-rail.test.ts
@@ -124,6 +124,10 @@ describe("ComposerAccessoryRail", () => {
const renderer = render()
const rail = renderer.root.findByProps({ "data-testid": tid.composerAccessoryRail })
expect(rail.props.className).toContain("absolute")
+ const railClasses = rail.props.className.split(" ")
+ expect(railClasses).toContain("bottom-2")
+ expect(railClasses).toContain("sm:bottom-4")
+ expect(railClasses).not.toContain("bottom-3")
expect(rail.props["data-layout"]).toBe("centered")
expect(renderer.root.findByProps({ "data-testid": tid.scrollToPresent }).props["aria-label"])
.toBe("Jump to present, 4 unread below")
diff --git a/src/web/src/components/community/messages/composer-accessory-rail.tsx b/src/web/src/components/community/messages/composer-accessory-rail.tsx
index 8811d3d5b..94512101a 100644
--- a/src/web/src/components/community/messages/composer-accessory-rail.tsx
+++ b/src/web/src/components/community/messages/composer-accessory-rail.tsx
@@ -41,7 +41,7 @@ export function ComposerAccessoryRail({
data-testid={tid.composerAccessoryRail}
data-selection={selectMode ? "active" : "inactive"}
data-layout={layout}
- className="pointer-events-none absolute inset-x-0 bottom-3 z-20 px-2 sm:px-4"
+ className="pointer-events-none absolute inset-x-0 bottom-2 z-20 px-2 sm:bottom-4 sm:px-4"
>
<div
className={cn(
diff --git a/src/web/src/test/e2e-ui/25-composer-accessory-rail-occupancy.spec.ts b/src/web/src/test/e2e-ui/25-composer-accessory-rail-occupancy.spec.ts
index c5f545164..3d825c0e2 100644
--- a/src/web/src/test/e2e-ui/25-composer-accessory-rail-occupancy.spec.ts
+++ b/src/web/src/test/e2e-ui/25-composer-accessory-rail-occupancy.spec.ts
@@ -9,9 +9,11 @@ const LONG_TYPING_NAME = `Typing ${"occupancy ".repeat(8)}edge`
type Rect = {
left: number
+ top: number
right: number
bottom: number
width: number
+ height: number
center: number
}
@@ -44,9 +46,11 @@ async function railMetrics(page: Page): Promise<RailMetrics> {
const style = typingText ? getComputedStyle(typingText) : null
const toRect = (value: DOMRect) => ({
left: value.left,
+ top: value.top,
right: value.right,
bottom: value.bottom,
width: value.width,
+ height: value.height,
center: value.left + value.width / 2,
})
return {
@@ -88,6 +92,40 @@ function expectContained(metrics: RailMetrics, state: string, width: number): vo
}
}
+function expectCheckpoint(
+ metrics: RailMetrics,
+ state: string,
+ width: number,
+ selection: boolean,
+): void {
+ const evidence = `${state}@${width}: ${JSON.stringify(metrics)}`
+ const expectedGap = width < 640 ? 8 : 16
+ for (const [name, control] of [
+ ["typing", metrics.typing],
+ [selection ? "selection" : "scroll", metrics.center],
+ ] as const) {
+ if (!control || control.width === 0) continue
+ expect(Math.abs(metrics.composer.top - control.bottom - expectedGap), `${name} ${evidence}`)
+ .toBeLessThanOrEqual(1)
+ }
+ if (metrics.typing?.width) {
+ expect(metrics.typing.height, `typing ${evidence}`).toBe(32)
+ }
+ if (metrics.center?.width) {
+ if (!selection) {
+ expect(metrics.center.height, `scroll ${evidence}`).toBe(32)
+ } else if (width === 390) {
+ expect(metrics.center.height, `selection ${evidence}`).toBe(40)
+ } else if (width === 1280) {
+ expect(metrics.center.height, `selection ${evidence}`).toBe(38)
+ }
+ }
+ if (metrics.typing?.width && metrics.center?.width) {
+ expect(Math.abs(metrics.typing.bottom - metrics.center.bottom), `shared baseline ${evidence}`)
+ .toBeLessThanOrEqual(1)
+ }
+}
+
async function captureState(args: {
page: Page
testInfo: TestInfo
@@ -128,8 +166,14 @@ async function captureState(args: {
await expect(rail).toHaveAttribute("data-layout", layout!)
await expect(page.getByTestId(tid.typingIndicator)).toHaveCount(typing ? 1 : 0)
await expect(page.getByTestId(tid.messageSelectionToolbar)).toHaveCount(selection ? 1 : 0)
+ if (selection && (width === 390 || width === 1280)) {
+ await expect.poll(() => page.getByTestId(tid.messageSelectionToolbar).evaluate(
+ (element) => element.getBoundingClientRect().height,
+ )).toBe(width === 390 ? 40 : 38)
+ }
const metrics = await railMetrics(page)
expectContained(metrics, state, width)
+ expectCheckpoint(metrics, state, width, selection)
if (center) {
expect(metrics.center, `${state}@${width}`).not.toBeNull()
expect(Math.abs(metrics.center!.center - metrics.composer.center), `${state}@${width}`)