Borderless modes have different padding inside the builtin apps

Most of the builtin apps had some padding between the window edge and
their content, because they expect to be displayed with a line border on
their edge. We added a customization option to remove the border, so,
that padding is not always necessary. Make the layouts dynamically
adjust, to omit the padding when it isn't needed.
This commit is contained in:
James Babcock committed 2026-11-11 15:19:29 -08:00
1 parent e158452ba4
commit a02b849200
115 files changed
+3600 -1583

No files matched your search

+37 -1
View File
@@ -2,9 +2,12 @@ const test = require('node:test');
const assert = require('node:assert/strict');
const { loader } = require('./helpers/load-typescript.cjs');
const load = loader();
const { TranscriptModel, TranscriptScroll, wrapTranscribeText } = load('app/apps/transcribe/transcript-model.ts');
const { TranscriptModel, TranscriptScroll, transcriptLayout, wrapTranscribeText } = load('app/apps/transcribe/transcript-model.ts');
const { SpeechPauseDetector } = load('app/native/speech-pause.ts');
const { TimedTranscript } = load('app/native/transcript-format.ts');
const { bordered, unbordered, edged } = require('./helpers/viewport.cjs');
const plain = value => JSON.parse(JSON.stringify(value));
function pcm(amplitude, ms = 50) {
const bytes = new Uint8Array(ms * 16 * 2);
@@ -82,6 +85,39 @@ test('short transcripts become scrollable without disabling automatic following'
assert.equal(s.layout(12, 10), 2);
});
test('the transcript lines up with the header inside the side padding and scrolls to the bottom edge', () => {
// 16px lines stepping 20, under a header that ends at y=38.
const framed = transcriptLayout(bordered(576, 260), 38, 16, 20);
assert.deepEqual(plain(framed), {
// In line with the header's title at the left padding; the right keeps the scrollbar's gutter.
textX: 8, textWidth: 576 - 8 - 8 - 8, pageLines: 10, drawnLines: 11,
scrollbar: { x: 576 - 8 - 2, y: 38, width: 2, height: 260 - 8 - 38 },
});
// Following the tail, the last line rests above the bottom padding; scrolled
// back, one more line fits above the window's edge itself.
const lineBottom = (firstLine, total) => 38 + (Math.min(total, firstLine + framed.drawnLines) - 1 - firstLine) * 20 + 16;
const s = new TranscriptScroll();
assert.equal(s.layout(40, framed.pageLines), 30);
assert.equal(lineBottom(30, 40), 234);
s.scroll(-3);
assert.equal(s.layout(40, framed.pageLines), 27);
assert.equal(lineBottom(27, 40), 254);
assert.ok(lineBottom(27, 40) > 260 - 8 && lineBottom(27, 40) <= 260);
// With nothing bordering the window, the column and the page gain the padding's room.
assert.deepEqual(plain(transcriptLayout(unbordered(576, 260), 38, 16, 20)), {
textX: 0, textWidth: 576 - 8, pageLines: 11, drawnLines: 11,
scrollbar: { x: 574, y: 38, width: 2, height: 222 },
});
const leftOnly = transcriptLayout(edged(576, 260, 'left'), 38, 16, 20);
assert.deepEqual([leftOnly.textX, leftOnly.textWidth, leftOnly.scrollbar.x], [8, 576 - 8 - 8, 574]);
// The scrollbar never stands over the text column.
for (const layout of [framed, leftOnly, transcriptLayout(bordered(476, 155), 38, 16, 20)]) {
assert.ok(layout.textX + layout.textWidth < layout.scrollbar.x);
assert.ok(layout.pageLines >= 1 && layout.drawnLines >= layout.pageLines);
}
});
test('pause detector uses 1.5 seconds of PCM, fires once per pause, and ignores leading silence', () => {
const d = new SpeechPauseDetector();
for (let i = 0; i < 60; i++) assert.equal(d.accept(pcm(0)), false);