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
16 changes: 11 additions & 5 deletions hooks/layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof paneRows>[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<typeof paneRows>[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')
})
12 changes: 10 additions & 2 deletions hooks/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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))

Expand Down
8 changes: 5 additions & 3 deletions hooks/pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,13 @@ async function openPrompt($: EngineInterface, ref: string): Promise<void> {
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 } : {}),
})

Expand Down Expand Up @@ -272,7 +274,7 @@ export function livePane(on: On): void {
])
const room = Math.max(20, e.props.bodyColumns)
if (failed !== null) return <Text wrap="truncate-end" color="error">Minos could not run: {failed}</Text>
if (ledger === null) return <Text dimColor>Reading this session's ledger…</Text>
if (ledger === null) return <Text color={SECONDARY}>Reading this session's ledger…</Text>
const press = async (id: string): Promise<unknown> => {
if (id === FILES_PRESS) return update($, allFiles, (all) => !all)
if (id === PROMPTS_PRESS) return update($, allPrompts, (all) => !all)
Expand Down
Loading