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
2 changes: 1 addition & 1 deletion docs/i18n-inventory.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# i18n inventory (egdev6/quorb#66)

Generated by `node scripts/i18n-inventory.mjs` from the source trees `src/` = `950e87aed191c15e2ea061efd6ff0e41e12a54a2` and `src-tauri/src/` = `4e040c3e38251119abf3e7d0de46376d82d9c885`.
Generated by `node scripts/i18n-inventory.mjs` from the source trees `src/` = `eb4547b4f645376c9d2e56581547abd336534584` and `src-tauri/src/` = `4e040c3e38251119abf3e7d0de46376d82d9c885`.
Any commit whose `git rev-parse <commit>:src` and `<commit>:src-tauri/src` match has these exact texts.
Do not edit by hand: regenerate, or verify with `node scripts/i18n-inventory.mjs --check`.

Expand Down
40 changes: 40 additions & 0 deletions odd/tasks/229-detail-panel-width.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# #229 — Fit detail panel width to the work area
Branch: `fix/229-detail-panel-width`; base: `0852eba386c340dece3a03cfadbf6e1deb3a021c`; delivery: ask-on-risk, local work only.
Checks: focused Vitest, `npm test`, `npm run typecheck`; forecast: 250–400 authored diff lines, one coherent work-unit commit.

## Specs
S1 — Issue requirement: «Que el panel nunca se salga del área de trabajo en ancho, igual que ya ocurre en altura.» Source: https://github.com/egdev6/quorb/issues/229
S2 — Owner-approved geometry: «**Factor:** el mínimo entre el de altura y el de ancho, con escalado uniforme. El límite horizontal es `area.w` en los bordes superior e inferior, y el espacio libre junto a la tira, descontando la separación, en los laterales. `DetailPlacement` ya incluye `strip` y `edge`, así que no hace falta cambiar el payload.»
S3 — Owner-approved height: «**Altura devuelta:** `maxHeight` solo cuando la altura es el límite activo; si no, `ceil(natural × factor)`.»
S4 — Owner-approved degenerate case: «**Sin espacio útil:** igual que `panelHeightLimit`, el límite de ancho se acota a un mínimo de 1, sin usar `placement-failed`, que queda para fallos de colocación nativa.»
S5 — Owner-approved physical containment: «**Píxeles físicos:** verificar que los bordes derecho e inferior no superen el área tras el redondeo de `physicalPanelBounds`, resolviéndolo en el detalle sin tocar el conversor compartido con la tira.»
S6 — Scope exclusions: «**Fuera de alcance:** escala mínima legible, scroll y redistribución del contenido.» «#265 y #314 quedan fuera.» Keep payload, shared converter, strip geometry and #250 placement/retry contracts unchanged.
S7 — Owner-requested tests: «En los tests, además de lo que indicas, conviene ampliar la prueba de contención de los cuatro bordes con escala de texto 2,25 y áreas estrechas (la actual usa ancho 300 sin escala) y actualizar la aserción de `DetailPanel.test.tsx` si cambia la llamada a `fitPanel`.» Check no fit, width-only, height-only, both with each dominant axis and ties, negative monitor origins, fractional DPI, actual DOM/native size coherence, and existing placement behavior. Manual Windows visual validation must be reported unavailable if no Windows runtime exists.
Approval source for S2–S7: https://github.com/egdev6/quorb/issues/229#issuecomment-7157846474
S8 — Publication request: «pues subimos la rama a github.com/egdev6/quorb y genramos pr en la pr en español comentar que me gustaría que alguien con windows nativo nos confirmara que es correcto lo que se ha implementado. tiene sentido pedirlo?» Publish branch and Spanish PR to the explicitly authorized upstream; retain pending Windows proof without claiming it passed.

## Tasks
T1 — S1–S7; route: bounded worker (context backstop), parent owns physical strategy; done (automated implementation checks); fitting and detail-local physical containment implemented with comments; commit: 3b7332d; RED exit1 20 failed/87 passed, final GREEN exit0 107 passed, typecheck exit0.
T2 — S1–S7; route: parent spot-check and assessment; done (automated local work); full suite exit0 (1287 Vitest + 329 Node), parent spot-check exit0 107/107, typecheck exit0; source commit 3b7332d; committed ASSESS medium, reviewDue=false/under_budget, no independent verifier required, no native review started. Peer base-study received, not a verification of the implementation; Windows proof remains T3.
T3 — S7; route: human Windows runtime; blocked (no Windows runtime available); visual check of text scale, clipping, corners and interaction; commit: N/A.
T4 — S8; route: parent; done; scoped format ddad8b8, inventory/preflight a0c25c7; branch published to egdev6/quorb and Spanish PR https://github.com/egdev6/quorb/pull/315 opened against main, assigned to ludevdot; native Windows validation requested explicitly; CI pending.

## Log
L1 — User implementation request verbatim: «sabiendo esto empezamos con el desarrollo apoyandonos de la sesion 01a21247-9d8d-7760-bdf0-ce334663beda para lo que necesites, tanto en investigacion , como en desarrollo, tu decides»
L2 — Preimplementation: branch verified clean; GitHub assignee ludevdot verified against `gh api user`; owner approval and latest acknowledgement read. RDD on. Peer 01a21247-9d8d-7760-bdf0-ce334663beda asked for read-only physical containment strategy. No source edits yet.
L3 — Research: fitPanel only caps height; width is already rendered basal monitor width (CSS layout divides by base). Shared physicalPanelBounds rounds origin and ceils size; changing it would affect strip behavior. #250 does not validate work-area containment. Explorer supplied focused runner `npx vitest run --dir src lib/detail-panel.test.ts lib/dock.test.ts DetailPanel.placement.test.tsx`; `npm test` includes Vitest and Node scripts, `npm run typecheck` is available. No tests run yet. Existing comments are the proportionate fitting documentation; no CLI/API/help behavior changes planned.
L4 — Risk forecast: detail-only behavior, no data/security/concurrency/delivery changes intended. Reassess item 3 if shared unrequested behavior changes; do not alter shared converter or strip. Physical strategy implemented in fitDetailPanel: recover integer physical work-area origin/size separately, derive inward strip bounds with ceil/floor, uniformly refit DOM if native rounded dimensions exceed budget, then clamp physical origin. No truncation beneath larger content; shared converter unchanged.

L5 — Writer T1 evidence: RED exit1 (20 failed/87 passed), first GREEN exit1 (4 failed/103 passed, DOM operation-order ulp mismatch), corrected and final GREEN exit0 (107/107), typecheck exit0. Logs: /var/folders/9f/dwn9fytx6zx61dklp7tcs_nr0000gn/T/gpWrafwp/gaQgcva7/quorb-229-writer.g9WfmN/. Parent spot check exit0 107/107; git diff --check exit0. Full npm test job-1 exit0.
L6 — Initial uncommitted ASSESS unavailable because untracked task document lacked declaration; no review lineage created. Will assess the committed work-unit selector after local commit. Windows visual validation unavailable; T3 remains blocked. Risk: none (detail-only fitting logic and callsite; shared converter, payload, strip geometry, and native placement contracts unchanged).

L7 — Work-unit commit 3b7332d, 310 authored changed lines. ASSESS over base 0852eba386c340dece3a03cfadbf6e1deb3a021c with committedOnly=true: medium, reviewDue=false, reviewDueReason=under_budget, independentVerifier=false. No receipt/approval claimed. Full npm test exit0: 1287 Vitest + 329 Node tests, zero failures. Peer contrast was pending at this point (resolved in L8); T3 awaits Windows runtime. No push/PR.

L8 — Peer base-study received: agrees width/height factor, real strip bounds, min1/no failure gate and local physical fix. Its context predates 3b7332d, so this is research support, NOT an independent review of current code. No new proven defect. Proposed ceil logical width and size-only shrink were not adopted: implementation preserves proportional fit and uniformly refits DOM before any surface resize. Suggested risks (shared panelRect/concurrent queue) do not apply to the diff: neither implementation nor contracts changed there. Automated T2 complete; T3 remains blocked. Rollback boundary: five source/test files changed by 3b7332d, no unrelated edits.

L9 — User publication request verbatim: «pues subimos la rama a github.com/egdev6/quorb y genramos pr en la pr en español comentar que me gustaría que alguien con windows nativo nos confirmara que es correcto lo que se ha implementado. tiene sentido pedirlo?» Origin is ludevdot/quorb (fork), authorized target is egdev6/quorb, viewerPermission WRITE verified. Will push explicit upstream URL without changing remotes.
L10 — Publication preflight found one Biome formatting error in src/lib/detail-panel.test.ts; corrected with scoped formatter (only array wrapping). Biome now exit0, 225 warnings/31 infos retained, focused tests exit0 107/107. Inventory was refreshed in 2cc9320; formatting source-tree change requires another generated hash refresh. Source review baseline remains 0852eba.

L11 — Final publication preflight: npm test and npm run build exit0 (1287 Vitest + 329 Node); build emits nonblocking >500kB chunk warning. cargo fmt --check, inventory --check and diff --check exit0. Scoped formatting commit ddad8b8; generated inventory refreshed again against its source tree. Windows manual proof remains pending and will be requested in Spanish PR.

L12 — Publication verified: https://github.com/egdev6/quorb/pull/315 OPEN, base main, head fix/229-detail-panel-width, assignee ludevdot. Spanish body includes exact approved scope, actual check results, explicit native Windows/WebView2 validation request and no claim of manual proof. Five CI checks initially IN_PROGRESS (Windows, Linux, macOS ARM64, static code safety, secrets scan). Push passed normal Biome/cargo-fmt hooks. Foreground delivery used after pre-delivery guard refused background execution without running it; no bypass. Final slice ASSESS: medium, reviewDue=false/under_budget. No merge/release authorized or performed.
67 changes: 62 additions & 5 deletions src/DetailPanel.placement.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { DetailPanel } from './DetailPanel';
import type { DetailPlacementReport } from './detail-placement';
import { DETAIL_EVENTS, type DetailState, type PhysicalBounds } from './lib/detail-panel';
import { DETAIL_EVENTS, panelScaleFromTransform, type DetailState, type PhysicalBounds } from './lib/detail-panel';
import { panelHeightLimit, stripRect, type Edge } from './lib/dock';

const harness = vi.hoisted(() => ({
states: [] as unknown[],
stateIndex: 0,
stateWrite: vi.fn(),
textScale: 1,
refs: [] as { current: unknown }[],
refIndex: 0,
effects: [] as { run: () => void | (() => void) }[],
Expand Down Expand Up @@ -73,7 +75,7 @@ vi.mock('@tauri-apps/api/window', () => ({ getCurrentWindow: () => ({ hide: nati
vi.mock('@tauri-apps/api/event', () => ({ listen: vi.fn(async () => () => {}), emitTo: native.emitTo }));
vi.mock('@tauri-apps/plugin-opener', () => ({ openUrl: vi.fn(async () => {}) }));
vi.mock('./i18n/use-locale', () => ({ useLocale: () => 'es' }));
vi.mock('./lib/useTextScale', () => ({ useTextScale: () => 1 }));
vi.mock('./lib/useTextScale', () => ({ useTextScale: () => harness.textScale }));

const granted: PhysicalBounds = { x: 815, y: 88, w: 330, h: 400 };

Expand Down Expand Up @@ -162,22 +164,22 @@ const failureNotices = () =>
* Monta el panel con estado y ejecuta su efecto de placement real con la
* secuencia de informes nativa indicada.
*/
const runPlacement = async (reports: DetailPlacementReport[], place?: () => Promise<DetailPlacementReport>) => {
const runPlacement = async (reports: DetailPlacementReport[], place?: () => Promise<DetailPlacementReport>, state = detailState) => {
harness.states = [];
harness.stateIndex = 0;
harness.refs = [];
harness.refIndex = 0;
harness.effects = [];
harness.layoutEffects = [];
harness.states[0] = detailState; // `data`: hay algo que colocar.
harness.states[0] = state; // `data`: hay algo que colocar.
let index = 0;
native.setDetailBounds.mockImplementation(place ?? (async () => reports[Math.min(index++, reports.length - 1)]));
native.setSurfaceClip.mockResolvedValue(undefined);
native.showDetail.mockResolvedValue(true);
// El componente registra sus efectos al llamarse.
DetailPanel();
harness.refs[0].current = panelElement; // `panelRef`
harness.refs[1].current = detailState; // `dataRef`: la sesión de detalle vigente
harness.refs[1].current = state; // `dataRef`: la sesión de detalle vigente
expect(harness.layoutEffects).toHaveLength(1);
const cleanup = harness.layoutEffects[0].run();
await flush();
Expand All @@ -198,6 +200,8 @@ describe('the detail placement effect (#250/S17)', () => {
devicePixelRatio: 1,
});
panelHeight = 400;
panelElement.style.transform = 'scale(1)';
harness.textScale = 1;
resize = null;
vi.stubGlobal(
'ResizeObserver',
Expand Down Expand Up @@ -225,6 +229,58 @@ describe('the detail placement effect (#250/S17)', () => {
vi.resetAllMocks();
});

it.each(['top', 'bottom', 'left', 'right'] as Edge[])('keeps the rendered transform and native size coherent on narrow %s placements', async (edge) => {
harness.textScale = 2.25;
const sf = 1.25;
const area = { x: -1973 / sf, y: -237 / sf, w: 397 / sf, h: 611 / sf };
const vertical = edge === 'left' || edge === 'right';
const strip = stripRect(area, edge, 1, vertical ? 90 : 270, vertical ? 270 : 90);
const state = {
...detailState,
area,
strip,
edge,
anchor: vertical ? strip.y + strip.h : strip.x + strip.w,
scaleFactor: sf,
maxHeight: panelHeightLimit(area, edge, strip),
};
const cleanup = await runPlacement([applied()], undefined, state);
// Re-render the real component with its committed fit and inspect its JSX style.
harness.stateIndex = 0;
harness.refIndex = 0;
const tree = DetailPanel();
if (!tree) throw new Error('Expected the detail panel to render');
const style = tree.props.children.props.style;
const zoom = panelScaleFromTransform(style.transform);
const physical = native.setDetailBounds.mock.calls[0][0] as PhysicalBounds;
expect(zoom).toBeLessThan(1);
expect(style.width).toBe(state.width);
expect(style.visibility).toBe('visible');
expect(physical.w).toBeGreaterThanOrEqual(style.width * zoom * harness.textScale * sf);
expect(physical.h).toBeGreaterThanOrEqual(panelHeight * zoom * harness.textScale * sf);
expect(physical.x).toBeGreaterThanOrEqual(-1973);
expect(physical.y).toBeGreaterThanOrEqual(-237);
expect(physical.x + physical.w).toBeLessThanOrEqual(-1576);
expect(physical.y + physical.h).toBeLessThanOrEqual(374);
const clip = native.setSurfaceClip.mock.calls[0][0];
expect(clip.width).toBe(physical.w);
expect(clip.height).toBe(physical.h);
expect(clip.radii[0]).toBeCloseTo(Math.min(physical.w / 2, physical.h / 2, 14 * zoom * harness.textScale * sf), 10);
expect(native.showDetail).toHaveBeenCalledTimes(1);
expect(native.hide).not.toHaveBeenCalled();
expect(failureNotices()).toEqual([]);
if (typeof cleanup === 'function') cleanup();
});

it('still requests native placement for a degenerate area rather than declaring placement failure', async () => {
const state = { ...detailState, area: { x: 0, y: 0, w: 0, h: 0 }, maxHeight: 1 };
const cleanup = await runPlacement([applied()], undefined, state);
expect(native.setDetailBounds).toHaveBeenCalledTimes(1);
expect(native.showDetail).toHaveBeenCalledTimes(1);
expect(failureNotices()).toEqual([]);
if (typeof cleanup === 'function') cleanup();
});

it('never places nor shows the panel when the native placement failed', async () => {
const cleanup = await runPlacement([readFailed()]);
// La colocación se vuelve a pedir: la inicial más el presupuesto acotado
Expand All @@ -247,6 +303,7 @@ describe('the detail placement effect (#250/S17)', () => {
it('shows the panel as before when the placement is confirmed', async () => {
const cleanup = await runPlacement([applied()]);
expect(native.setDetailBounds).toHaveBeenCalledTimes(1);
expect(native.setDetailBounds).toHaveBeenCalledWith(granted);
expect(native.showDetail).toHaveBeenCalledTimes(1);
expect(positioned()).toBe(true);
// Sólo la geometría confirmada (read-back) queda cacheada.
Expand Down
3 changes: 1 addition & 2 deletions src/DetailPanel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ describe('DetailPanel (SSR)', () => {
// clips and re-lays out with it; physical bounds keep the monitor scale alone.
it('fits and clips with the text scale of its own window', () => {
expect(source).toContain('const textScale = useTextScale();');
expect(source).toContain('fitPanel(data, layoutHeightOf(panel, entry), base, textScale)');
expect(source).toContain('fitDetailPanel(data, layoutHeightOf(panel, entry), base, textScale, data.scaleFactor)');
expect(source).toContain('measureSurfaceClip(panel, physical, next.zoom * textScale * data.scaleFactor)');
expect(source).toContain('physicalPanelBounds(detailBounds(data, next), data.scaleFactor)');
expect(source).toContain('}, [data, enqueue, textScale]);');
});
});
Expand Down
9 changes: 4 additions & 5 deletions src/DetailPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import { clipSurfaceSafely, measureSurfaceClip } from './lib/surface-clip';
import {
createLatestQueue,
basePanelZoom,
detailBounds,
fitPanel,
fitDetailPanel,
panelScaleFromTransform,
physicalPanelBounds,
sameFit,
DETAIL_EVENTS,
type DetailInteraction,
Expand Down Expand Up @@ -149,11 +147,12 @@ export function DetailPanel() {
const layout = (entry?: ResizeObserverEntry) => {
const panel = panelRef.current;
if (disposed || !panel) return;
const next = fitPanel(data, layoutHeightOf(panel, entry), base, textScale);
// Fit the DOM and native surface together, including physical rounding at
// the work-area edges; never clip the surface under a larger transform.
const { fit: next, physical } = fitDetailPanel(data, layoutHeightOf(panel, entry), base, textScale, data.scaleFactor);
setFit((old) => (old && sameFit(old, next) ? old : next));
// Compare native (physical) bounds, not logical ones: a DPI change with identical
// logical geometry must still resize the window.
const physical = physicalPanelBounds(detailBounds(data, next), data.scaleFactor);
// #215: the cache only ever holds
// read-back-confirmed geometry, so the ±1 px rounding tolerance of X11 applies
// by the same rule as the widget; on a platform without read-back the cache
Expand Down
Loading
Loading