8000 fix(composer): keep attachment and microphone controls at fixed pixel sizes by simon-inkie · Pull Request #146 · simon-inkie/inkie-deck · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .specs/composer-px-oss-SPEC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Keep composer controls and text clearance fixed in pixels

Status: pixel geometry implemented; focused/browser checks, build and compiler pass. Full workspace and all-ref privacy gates remain failed; clean candidate verification is pending.
Base: current OSS main.

## Problem and result

Attach and microphone controls shrink when the root text size is reduced. Fixed-size controls also need fixed text clearance to prevent the draft running under them. Port the two related geometry fixes into OSS without changing voice, attachment, draft or upload behaviour. Their existing development-branch implementation is a donor, not a whole-history transplant.

## Scope

Only Compose.tsx, its focused composer sizing regression and this SPEC. Keep 36px button boxes, 20px glyphs, 6px bottom/right offsets and 2px gap. Reserve at least 84px right and 44px bottom in the textarea. Check Tailwind class merging and cascade. Preserve all newer current-main behaviour; exclude independent typography tuning and any install-specific/private material. Add no dependencies, configuration, service or runner changes.

## Acceptance

1. Compare current OSS source and selective committed donor geometry before applying it; retain exact private evidence without publishing donor identifiers.
2. Component tests check actual merged box/glyph overrides, control offsets and textarea reserve, including relevant voice/upload states. Removing pixel overrides or clearance must fail a meaningful assertion; restore exact source.
3. Check rendered geometry and text clearance at small/default/large root font sizes using an existing real browser where available. Otherwise report browser acceptance NOT RUN; jsdom classes do not prove geometry.
4. Run focused and required workspace tests, build, boundaries, leak self-test/full/history/message checks, licence, package version and ASCII gates. Run one final authoritative typecheck, serially with all other compilers. Preserve failures and limitations.
5. Freeze source/receipts, then main reviews, signs and opens a separate PR with fresh exact review and plain-English suitability/test note. No running-build, visibility or deployment change.

## Work log

### 2026-11-17: Implementation pickup
Current main has rem-sized controls and text reserve. Port only the two final pixel geometry behaviours and the sizing regression. Voice, draft, paste, upload and caller semantics remain untouched; typography belongs to a separate review unit. Fixed geometry is generic OSS UI behaviour and requires no installation-specific setting. No root font-size environment hook exists on current main.

### 2026-11-17: Implementation and verification
The first constituent behaviour fixes attach/mic button and glyph sizes plus group offsets/gap after Tailwind merging. The second adds fixed text clearance. Both are generic, reusable OSS UI behaviour. Intermediate merge comments and conflicting rem reserve utilities were removed only in the selected textarea seam. Current main typography, voice, upload, paste, draft and caller logic remain unchanged.

The sizing test checks idle, disabled voice, connecting spinner and upload pulse through actual component rendering. Three negative controls remove button size, glyph size or text reserve; each fails all four cases at the intended assertion. Exact source restoration passes all 43 focused tests. These jsdom checks prove DOM overrides, not rendered geometry.

An isolated Chromium harness rendered the actual component with candidate build CSS and local route/media doubles. All 12 state/root cases passed at 12px, 16px and 24px roots: 36px boxes, 20px glyphs, 6px offsets, 2px gap, 84px/44px reserve, and measured text-content clearance of 5px horizontally and 3px vertically. Native installation and full application E2E acceptance are not claimed.

Build and one serial authoritative workspace compiler passed. Boundaries, working-tree privacy, leak self-test, licence, library version and dash checks passed. Workspace tests passed 85 base tests and 2267 Deck tests, skipped 11 and failed 74 Deck tests. The failures are clean-tree assertions on the required unstaged delta and read-only home fixture creation. All-ref history and message scans failed with 345 and 69 findings; these are retained failures and need fresh clean candidate verification plus scoped history review. Touched source is ASCII; unrelated non-ASCII bytes are unchanged. Source remains unstaged with no commit, external review or publication acceptance.

## Current-main reconciliation, 17 November

Incorporate merged typography PR145 at main83eeaa107f97cc52be55b5d57cfa2c492419ec17 through a normal merge, preserving its complete seven-file delta. Resolve only the Compose textarea class seam: retain mc-composer-textarea and the typography removal of min-h-10, py-2 and text-sm; retain the pixel-style padding and omit pr-[5rem] and pb-10. Fixed 36px buttons, 20px glyphs, 6px offsets, 2px gap and all behavioural logic remain intact.

Freeze exact combined files, commit through Root, then fresh committed-tree workspace tests and required tree gates. Combined production changes require final compiler/build authority and rendered root/state geometry checks. No threshold, test expectation or unrelated source changes. Keep 8000 inherited audit failures and old receipts; no private branch/deployment changes or history rewrite. Send exact merged object and receipts for bounded independent recheck before PR146 merge.
23 changes: 13 additions & 10 deletions packages/deck/app/components/Compose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ import {
SILENCE_AUTO_STOP_MS,
} from "~/lib/voice-insert";
import { buildOutgoingBody, extractPasteFiles } from "~/lib/compose-attach";
import { cn } from "~/lib/utils";

interface ComposeProps {
/**
Expand Down Expand Up @@ -1202,6 +1201,9 @@ export function Compose({
disabled={busy || uploading}
placeholder={isCustomMode ? "Write your answer..." : "Write a reply..."}
data-testid="compose-textarea"
// Fixed-pixel clearance for the two 36px controls, their 2px gap
// and 6px offsets, with room between the text and the controls.
style={{ paddingRight: 84, paddingBottom: 44 }}
value={currentDraft}
>
isCustomMode && onChange
Expand All @@ -1217,11 +1219,12 @@ export function Compose({
}
>
>
className="mc-composer-textarea max-h-[40vh] w-full resize-none overflow-y-auto rounded-md border border-input bg-background px-3 pr-[5rem] pb-10 text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 focus:ring-offset-background disabled:opacity-50"
className="mc-composer-textarea max-h-[40vh] w-full resize-none overflow-y-auto rounded-md border border-input bg-background px-3 text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-1 focus:ring-offset-background disabled:opacity-50"
/>

{/* Attach + Mic live inside the textarea border, bottom-right corner */}
<div className="absolute bottom-1.5 right-1.5 flex items-center gap-0.5">
{/* Attach + Mic live inside the textarea border, bottom-right corner.
Fixed px (36px box, 20px glyph) so they do not shrink with the root font size. */}
<div className="absolute bottom-[6px] right-[6px] flex items-center gap-[2px]" data-testid="compose-controls">
{/* Paperclip - wired to file picker */}
<Button
type="button"
Expand All @@ -1230,11 +1233,11 @@ export function Compose({
disabled={uploading}
aria-label={uploading ? "Uploading..." : "Attach a file"}
title={uploading ? "Uploading..." : "Attach a file"}
className="h-9 w-9 p-0 min-h-0 min-w-0 text-muted-foreground"
className="size-[36px] p-0 min-h-0 min-w-0 text-muted-foreground [&_svg]:size-[20px]"
>
data-testid="attach-button"
>
<Paperclip className={cn("h-5 w-5", uploading ? "animate-pulse" : "")} />
<Paperclip className={uploading ? "animate-pulse" : undefined} />
</Button>

{/* Mic button - live when voiceProxyUrl present and mic available;
Expand All @@ -1246,7 +1249,7 @@ export function Compose({
disabled={!voiceEnabled || !micAvailable}
aria-label={micLabel}
title={micLabel}
className="relative h-9 w-9 p-0 min-h-0 min-w-0 text-muted-foreground"
className="relative size-[36px] p-0 min-h-0 min-w-0 text-muted-foreground [&_svg]:size-[20px]"
>
aria-busy={isConnecting || undefined}
data-testid="mic-button"
Expand All @@ -1256,11 +1259,11 @@ export function Compose({
<span className="absolute top-0.5 right-0.5 size-1.5 rounded-full bg-primary animate-pulse" />
) : null}
8000 {voiceEnabled && isConnecting ? (
<Loader2 className="h-5 w-5 animate-spin" />
<Loader2 className="animate-spin" />
) : voiceEnabled ? (
<Mic className={cn("h-5 w-5", isActive ? "text-primary" : "")} />
<Mic className={isActive ? "text-primary" : undefined} />
) : (
<MicOff className="h-5 w-5" />
<MicOff />
)}
</Button>
</div>
Expand Down
114 changes: 114 additions & 0 deletions packages/deck/test/compose-icon-size.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// @vitest-environment jsdom
/**
* Compose control geometry after Button's Tailwind class merging.
* These DOM assertions pin the fixed-pixel overrides and clearance; jsdom
* does not prove rendered geometry at different root font sizes.
*/
import { describe, it, expect, beforeEach, afterEach } from "vitest";
import React, { act } from "react";
import { createRoot, type Root } from "react-dom/client";
import { createRoutesStub } from "react-router";
import { Compose } from "~/components/Compose";

(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;

let container: HTMLDivElement;
let root: Root;
let mediaDevices: PropertyDescriptor | undefined;
let finishUpload: (() => void) | undefined;

beforeEach(() => {
mediaDevices = Object.getOwnPropertyDescriptor(navigator, "mediaDevices");
Object.defineProperty(navigator, "mediaDevices", {
configurable: true,
value: { getUserMedia: () => new Promise(() => {}) },
});
finishUpload = undefined;
container = document.createElement("div");
document.body.appendChild(container);
root = createRoot(container);
});

afterEach(async () => {
await act(async () => finishUpload?.());
act(() => root.unmount());
container.remove();
if (mediaDevices) Object.defineProperty(navigator, "mediaDevices", mediaDevices);
else Reflect.deleteProperty(navigator, "mediaDevices");
});

function render(disabled = false): void {
const Stub = createRoutesStub([
{
path: "/",
action: () => new Promise((resolve) => {
finishUpload = () => resolve({ ok: true, attachments: [] });
}),
Component: () => (
<Compose
draftKey="quill"
voiceProxyUrl="ws://localhost:5176/voice"
voiceDisabledReason={disabled ? "Voice unavailable" : null}
/>
),
},
]);
act(() => root.render(<Stub initialEntries={["/"]} />));
}

const button = (id: string) => container.querySelector(`[data-testid="${id}"]`) as HTMLButtonElement;

function expectPixelOverrides(): void {
for (const id of ["attach-button", "mic-button"]) {
const btn = button(id);
const cls = btn.className.split(/\s+/);
expect(cls).toContain("size-[36px]");
expect(cls).toContain("[&_svg]:size-[20px]");
expect(cls).not.toContain("h-9");
expect(cls).not.toContain("w-9");
expect(cls).not.toContain("[&_svg]:size-4");
const glyph = btn.querySelector("svg")!;
expect(glyph).not.toBeNull();
expect(glyph.classList.contains("h-5")).toBe(false);
expect(glyph.classList.contains("w-5")).toBe(false);
}
const group = container.querySelector('[data-testid="compose-controls"]') as HTMLElement;
expect(group.className.split(/\s+/)).toEqual(
expect.arrayContaining(["bottom-[6px]", "right-[6px]", "gap-[2px]"])
);
const ta = container.querySelector('[data-testid="compose-textarea"]') as HTMLTextAreaElement;
expect(parseFloat(ta.style.paddingRight)).toBeGreaterThanOrEqual(84);
expect(parseFloat(ta.style.paddingBottom)).toBeGreaterThanOrEqual(44);
expect(ta.classList.contains("pr-[5rem]")).toBe(false);
expect(ta.classList.contains("pb-10")).toBe(false);
}

describe("Compose attach and mic pixel overrides", () => {
it.each([false, true])("retains overrides with voice disabled=%s", (disabled) => {
render(disabled);
expect(button("mic-button").disabled).toBe(disabled);
expectPixelOverrides();
});

it("keeps the connecting spinner under the same glyph override", async () => {
render();
await act(async () => button("mic-button").click());
expect(button("mic-button").getAttribute("aria-busy")).toBe("true");
expect(button("mic-button").querySelector("svg")!.classList.contains("animate-spin")).toBe(true);
expectPixelOverrides();
await act(async () => button("mic-button").click());
expect(button("mic-button").getAttribute("aria-busy")).toBeNull();
});

it("keeps upload pulse geometry and disables the draft while uploading", async () => {
render();
const input = container.querySelector('input[type="file"]') as HTMLInputElement;
Object.defineProperty(input, "files", { value: [new File(["sample"], "sample.txt", { type: "text/plain" })] });
await act(async () => input.dispatchEvent(new Event("change", { bubbles: true })));
expect(button("attach-button").disabled).toBe(true);
expect(button("attach-button").getAttribute("aria-label")).toBe("Uploading...");
expect(button("attach-button").querySelector("svg")!.classList.contains("animate-pulse")).toBe(true);
expect((container.querySelector("textarea") as HTMLTextAreaElement).disabled).toBe(true);
expectPixelOverrides();
});
});
Loading
0