Skip to content

Commit

Permalink
tweak themes
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Nov 21, 2024
1 parent 1d975c9 commit 9739694
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/inspect_ai/_display/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from ..core.footer import task_footer
from ..core.panel import task_targets, task_title, tasks_title
from ..core.rich import record_console_input, rich_initialise, rich_theme
from .theme import inspect_light, inspect_dark
from .widgets.console import ConsoleView
from .widgets.footer import AppFooter
from .widgets.samples import SamplesView
Expand Down Expand Up @@ -67,11 +68,8 @@ def __init__(self) -> None:
# all tasks processed by app
self._app_tasks: list[TaskWithResult] = []

# dynamically enable dark mode or light mode
self.dark = detect_terminal_background().dark

# enable rich hooks
rich_initialise(self.dark)
rich_initialise(detect_terminal_background().dark)

def run_app(self, main: Coroutine[Any, Any, TR]) -> TaskScreenResult[TR]:
# create the worker
Expand Down Expand Up @@ -193,6 +191,12 @@ def compose(self) -> ComposeResult:
yield ConsoleView()

def on_mount(self) -> None:
# register and set theme
dark = detect_terminal_background().dark
self.register_theme(inspect_dark)
self.register_theme(inspect_light)
self.theme = "inspect-dark" if dark else "inspect-light"

# capture stdout/stderr (works w/ on_print)
self.begin_capture_print(self)

Expand Down
30 changes: 30 additions & 0 deletions src/inspect_ai/_display/textual/theme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from textual.theme import Theme

inspect_dark = Theme(
name="inspect-dark",
primary="#3376CD",
secondary="#004578",
accent="#ffa62b",
warning="#ffa62b",
error="#ba3c5b",
success="#64CE91",
foreground="#e0e0e0",
)


inspect_light = Theme(
name="inspect-light",
primary="#4283CA",
secondary="#0178D4",
accent="#ffa62b",
warning="#ffa62b",
error="#ba3c5b",
success="#64CE91",
surface="#D8D8D8",
panel="#DFDFDF",
background="#F8F8F8",
dark=False,
variables={
"footer-key-foreground": "#0178D4",
},
)
1 change: 1 addition & 0 deletions src/inspect_ai/_display/textual/widgets/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ConsoleView(RichLog):
scrollbar-size-horizontal: 1;
scrollbar-size-vertical: 1;
scrollbar-gutter: stable;
background: transparent;
}
"""

Expand Down
5 changes: 3 additions & 2 deletions src/inspect_ai/_display/textual/widgets/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ class SamplesView(Widget):
scrollbar-size-vertical: 1;
margin-bottom: 1;
row-span: 2;
background: transparent;
}
SamplesView OptionList:focus > .option-list--option-highlighted {
background: $primary 40%;
background: $primary 20%;
}
SamplesView OptionList > .option-list--option-highlighted {
background: $primary 40%;
background: $primary 20%;
text-style: none;
}
Expand Down
2 changes: 1 addition & 1 deletion src/inspect_ai/_util/transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def transcript_panel(


def transcript_separator(title: str) -> RenderableType:
return Rule(title=title, style="orange1 bold", align="center", end="\n\n")
return Rule(title=title, style="#3376CD bold", align="center", end="\n\n")


LINE = Box(" ── \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n")
Expand Down

0 comments on commit 9739694

Please sign in to comment.