From 6f642aa4cbbe73ea122622f15ac7ea3e0f807430 Mon Sep 17 00:00:00 2001 From: AraneaDev <12177132+AraneaDev@users.noreply.github.com> Date: Sat, 24 Oct 2026 18:51:32 +0200 Subject: [PATCH] fix(pane): space and style the header as the Knossos pane does The header hugged the pane's top and left edges, and its project name did not read as bold. - A blank row above the header (none on a narrow pane), the title set two cells in (one when narrow), then a blank row and a rule across the pane. - The project's name is bold in the theme's text colour. - Dim text is drawn in the theme's inactive colour, not the terminal's dim, whose reset also ends a bold beside it. Pressable labels keep dimColor, as a Button takes no colour. --- hooks/layout.test.ts | 16 +++++++++++----- hooks/layout.ts | 12 ++++++++++-- hooks/pane.tsx | 8 +++++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/hooks/layout.test.ts b/hooks/layout.test.ts index 7e38202..4d52b33 100644 --- a/hooks/layout.test.ts +++ b/hooks/layout.test.ts @@ -187,9 +187,15 @@ test('the wheel over a list moves its window, and stops at its ends so the pane }) test('the header names the project and where its checkout stands, as the Knossos pane does', () => { - const text = (where: Parameters[8]) => paneRows(LEDGER, [], null, 100, [], false, false, FOLDED, where)[0]!.segments.map((s) => s.text).join('').trimEnd() - expect(text({ project: 'minos', git: { branch: 'main', rev: '857857fdaa51' } })).toBe('minos main · 857857f') - expect(text({ project: 'minos', git: { branch: null, rev: '857857fdaa51' } })).toBe('minos @ 857857f') - expect(text({ project: 'minos', git: null })).toBe('minos') - expect(text(null)).toBe('Minos') + const text = (where: Parameters[8], room = 100) => paneRows(LEDGER, [], null, room, [], false, false, FOLDED, where).find((r) => r.key === 'head')!.segments.map((s) => s.text).join('').trimEnd() + expect(text({ project: 'minos', git: { branch: 'main', rev: '857857fdaa51' } })).toBe(' minos main · 857857f') + expect(text({ project: 'minos', git: { branch: null, rev: '857857fdaa51' } })).toBe(' minos @ 857857f') + expect(text({ project: 'minos', git: null })).toBe(' minos') + expect(text(null)).toBe(' Minos') + expect(text(null, 60)).toBe(' Minos') +}) + +test('the header has a blank row above it (none on a narrow pane), and a rule below it', () => { + expect(paneRows(LEDGER, [], null, 100).slice(0, 5).map((r) => r.key)).toEqual(['head-top', 'head', 'head-end', 'head-rule', 'head-gap']) + expect(paneRows(LEDGER, [], null, 60)[0]!.key).toBe('head') }) diff --git a/hooks/layout.ts b/hooks/layout.ts index 1cf795c..7a3079a 100644 --- a/hooks/layout.ts +++ b/hooks/layout.ts @@ -16,6 +16,8 @@ export type Row = { key: string; segments: Segment[]; code?: { source: string; d /** How much room the pane has: below 80 columns the tiles fold into one line. */ export type Tier = 'narrow' | 'medium' | 'wide' +/** Headings: the project's name, in the theme's own text colour, as Knossos draws its own. */ +const HEADING = 'text' /** Frames and rules. */ const FRAME = 'subtle' /** A card's glyph. */ @@ -228,13 +230,19 @@ export function paneRows( out.push(ruleRow(key, glyph, name, note, room)) gap(`space:${key}`) } - // The project and where its checkout stands, as the Knossos pane heads itself: the name in bold, then branch and commit, dim. + // The project and where its checkout stands, as the Knossos pane heads itself: a blank row above + // (none when narrow), then, set in from the edge, the name in bold and the branch and commit, dim. const git = where?.git ?? null const head: Segment[] = [ - { text: where?.project ?? 'Minos', bold: true }, + { text: spaces(tier === 'narrow' ? 1 : 2) }, + { text: where?.project ?? 'Minos', bold: true, color: HEADING }, ...(git === null ? [] : [{ text: ` ${git.branch === null ? '@ ' : `${git.branch} · `}${git.rev.slice(0, 7)}`, dim: true }]), ] + if (tier !== 'narrow') gap('head-top') out.push(row('head', head, room)) + // Below the header a blank row and a rule across the pane, as Knossos closes its own, then room before the tiles. + gap('head-end') + out.push({ key: 'head-rule', segments: [{ text: '─'.repeat(room), color: FRAME }] }) gap('head-gap') out.push(...tileRows(ledger.counts, room, tier)) diff --git a/hooks/pane.tsx b/hooks/pane.tsx index 0bc9ab0..ce3d859 100644 --- a/hooks/pane.tsx +++ b/hooks/pane.tsx @@ -204,11 +204,13 @@ async function openPrompt($: EngineInterface, ref: string): Promise { await update($, history, () => ({ file: ref, text: [prompt.text, prompt.summary, '', ...prompt.files].join('\n') })) } +/** Secondary text: what the layout marks dim, in the theme's inactive colour as Knossos draws it, never the terminal's dim, whose reset also ends a bold beside it. */ +const SECONDARY = 'inactive' + /** A plain segment's text style. */ const style = (s: Segment) => ({ - ...(s.color === undefined ? {} : { color: s.color }), + ...(s.color !== undefined ? { color: s.color } : s.dim === true ? { color: SECONDARY } : {}), ...(s.bold === true ? { bold: true } : {}), - ...(s.dim === true ? { dimColor: true } : {}), ...(s.italic === true ? { italic: true } : {}), }) @@ -272,7 +274,7 @@ export function livePane(on: On): void { ]) const room = Math.max(20, e.props.bodyColumns) if (failed !== null) return Minos could not run: {failed} - if (ledger === null) return Reading this session's ledger… + if (ledger === null) return Reading this session's ledger… const press = async (id: string): Promise => { if (id === FILES_PRESS) return update($, allFiles, (all) => !all) if (id === PROMPTS_PRESS) return update($, allPrompts, (all) => !all)