Theme the scrollbars

OpenTUI's default track is a fixed dark grey, which showed as a dark
strip in the light and terminal themes.
This commit is contained in:
Callum Alpass committed 2026-11-03 03:33:24 +11:00
1 parent ffade010a2
commit 3bc5f61704
6 files changed
+25 -8

No files matched your search

+2 -2
View File
@@ -3,7 +3,7 @@ import type { ReactNode } from "react";
import { MAX_DETAIL_FILES, type ChangedFile, type DetailsAction, type DetailsFold, type LineageLine, type ThreadDetails } from "../model/details.ts";
import { Button, ClickRow } from "./Button.tsx";
import { truncate } from "./text.ts";
import { colors, statusColor } from "./theme.ts";
import { colors, scrollbarOptions, statusColor } from "./theme.ts";
/** Rows stay readable when the panel takes the conversation's place on a narrow terminal. */
const IN_PLACE_MAX_WIDTH = 64;
@@ -46,7 +46,7 @@ export function DetailsPanel(props: {
overflow="hidden"
backgroundColor={colors.panel}
>
<scrollbox flexGrow={1} minHeight={0} paddingLeft={1} paddingRight={1}>
<scrollbox flexGrow={1} minHeight={0} paddingLeft={1} paddingRight={1} scrollbarOptions={scrollbarOptions()}>
{!details ? (
<text fg={colors.faint}>{props.empty ?? "No thread selected."}</text>
) : (
+2 -2
View File
@@ -4,7 +4,7 @@ import type { MouseEvent, ScrollBoxRenderable } from "@opentui/core";
import type { RefObject } from "react";
import { isLeftClick, useHover } from "./Button.tsx";
import { colors, useMarkdownStyle } from "./theme.ts";
import { colors, scrollbarOptions, useMarkdownStyle } from "./theme.ts";
export interface DiffState {
readonly cwd: string;
@@ -37,7 +37,7 @@ export function DiffView(props: { readonly diff: DiffState; readonly split: bool
{diff.status === "error" ? <text fg={colors.bad} flexShrink={0}>{`Could not load the diff: ${diff.error ?? "unknown error"}`}</text> : null}
{diff.status === "ready" && files.length === 0 ? <text fg={colors.muted} flexShrink={0}>No changes.</text> : null}
{diff.truncated ? <text fg={colors.warn} flexShrink={0}>The diff was too large and is cut short.</text> : null}
<scrollbox ref={props.scrollRef} flexGrow={1} minHeight={0}>
<scrollbox ref={props.scrollRef} flexGrow={1} minHeight={0} scrollbarOptions={scrollbarOptions()}>
{files.map((file, index) => (
<box key={file.path} id={`diff-file-${index}`} flexDirection="column" marginTop={1}>
<FileHeader path={file.path} selected={index === props.selected} canExpand={diff.source !== undefined} onPress={() => props.onFile(index)} />
+2 -2
View File
@@ -3,7 +3,7 @@ import type { RefObject } from "react";
import type { PullRequestLine } from "../model/pullRequests.ts";
import { Button, isLeftClick, isRightClick, useHover } from "./Button.tsx";
import { colors, type Palette } from "./theme.ts";
import { colors, type Palette, scrollbarOptions } from "./theme.ts";
export interface PullRequestViewState {
readonly status: "loading" | "ready" | "error";
@@ -41,7 +41,7 @@ export function PullRequestView(props: { readonly view: PullRequestViewState; re
</box>
{view.status === "loading" ? <text fg={colors.muted} flexShrink={0}>Loading pull request…</text> : null}
{view.status === "error" ? <text fg={colors.bad} flexShrink={0}>{`Could not load the pull request: ${view.error ?? "unknown error"}`}</text> : null}
<scrollbox ref={props.scrollRef} flexGrow={1} minHeight={0}>
<scrollbox ref={props.scrollRef} flexGrow={1} minHeight={0} scrollbarOptions={scrollbarOptions()}>
{view.lines.map((line, index) =>
line.kind === "title" && index > 0 ? (
<text key={index} fg={colors[LINE_COLORS[line.kind]]} marginTop={1}>
+2 -2
View File
@@ -18,7 +18,7 @@ import type { T3Session, ThreadHistory } from "../client/session.ts";
import { liveWorkEntryLabel, workEntryDisplayLabel, type MessagesTimelineRow, type Timeline, type WorkLogEntry } from "../model/timeline.ts";
import { blockFor } from "../model/transcript.ts";
import { firstLine, truncate } from "./text.ts";
import { colors, toneColor, useMarkdownStyle } from "./theme.ts";
import { colors, scrollbarOptions, toneColor, useMarkdownStyle } from "./theme.ts";
/** What a right-click in the conversation was on. */
export type ConversationTarget =
@@ -74,7 +74,7 @@ export function ThreadView(props: {
</box>
) : null}
{props.error ? <text fg={colors.bad} flexShrink={0}>{props.error}</text> : null}
<scrollbox ref={props.scrollRef} flexGrow={1} flexShrink={1} minHeight={0} stickyScroll stickyStart="bottom">
<scrollbox ref={props.scrollRef} flexGrow={1} flexShrink={1} minHeight={0} stickyScroll stickyStart="bottom" scrollbarOptions={scrollbarOptions()}>
{/* Prose stops at reading width on wide terminals; the composer below stays full width. */}
<box flexDirection="column" maxWidth={CONTENT_WIDTH}>
{props.loading && !timeline ? <text fg={colors.muted}>Loading…</text> : null}
+3
View File
@@ -162,6 +162,9 @@ export const statusColor = (tone: StatusTone): string => colors[STATUS_COLORS[to
const TONE_COLORS: Record<Tone, keyof Palette> = { normal: "text", muted: "muted", good: "good", bad: "bad", warn: "warn" };
export const toneColor = (tone: Tone): string => colors[TONE_COLORS[tone]];
/** A scrollbox's bars in the palette: OpenTUI's own track is dark whatever the theme. */
export const scrollbarOptions = () => ({ trackOptions: { foregroundColor: colors.muted, backgroundColor: colors.element } });
let markdownStyles = new WeakMap<NativeResourceOwner, SyntaxStyle>();
/** One per renderer: a SyntaxStyle belongs to the renderer's native scene that created it. */