4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
56 lines
2.2 KiB
Python
56 lines
2.2 KiB
Python
"""prompt-toolkit style construction and live theme refresh."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from contextlib import suppress
|
|
|
|
from prompt_toolkit.styles import Style
|
|
|
|
from platform.terminal import theme as ui_theme
|
|
from surfaces.interactive_shell.runtime import Session
|
|
|
|
|
|
def _build_prompt_style() -> Style:
|
|
theme = ui_theme.get_active_theme()
|
|
text_fg = f"fg:{theme.TEXT}"
|
|
return Style.from_dict(
|
|
{
|
|
"prompt-frame-line": f"bold {theme.HIGHLIGHT}",
|
|
"": text_fg,
|
|
"default": text_fg,
|
|
"repl-slash-command": f"bold {theme.HIGHLIGHT} bg:{theme.BG}",
|
|
"completion-menu": f"bg:{theme.BG}",
|
|
"completion-menu.completion": f"{theme.TEXT} bg:{theme.BG}",
|
|
"completion-menu.completion.current": f"bold {theme.HIGHLIGHT} bg:{theme.BG}",
|
|
"completion-menu.meta.completion": f"{theme.DIM} bg:{theme.BG}",
|
|
"completion-menu.meta.completion.current": f"{theme.HIGHLIGHT} bg:{theme.BG}",
|
|
"completion-menu.border": theme.DIM,
|
|
"scrollbar.background": f"bg:{theme.BG}",
|
|
"scrollbar.button": f"bg:{theme.DIM}",
|
|
# prompt_toolkit defaults the ``bottom-toolbar`` style to
|
|
# ``reverse:noinherit``, which paints the toolbar as a dark
|
|
# highlighted band across the terminal. Clear the reverse
|
|
# so the spinner + hint sit on the regular terminal bg
|
|
# (Claude Code-style flat layout).
|
|
"bottom-toolbar": "noreverse",
|
|
"bottom-toolbar.text": "noreverse",
|
|
}
|
|
)
|
|
|
|
|
|
def refresh_prompt_theme(session: Session) -> None:
|
|
"""Apply the active palette to the running prompt (input text + placeholder)."""
|
|
app = session.terminal.prompt_app
|
|
if app is None:
|
|
return
|
|
app.style = _build_prompt_style()
|
|
# Between prompt_async turns the Application is not running; invalidate() then
|
|
# triggers ESC[6n CPR queries whose responses leak as literal text on the
|
|
# next idle-hint line (e.g. ``^[[1;1R/ for commands``).
|
|
if not app.is_running:
|
|
return
|
|
if app.renderer is not None:
|
|
with suppress(Exception):
|
|
app.renderer.clear()
|
|
app.invalidate()
|