Files
lucioandClaude Opus 5.5 60532a4043 Rebuild the UI on vendored Textual; make the checkout self-contained
The internal servers have no access to outside package repositories and
run Python 3.8/3.9, so the UI moves from hand-drawn curses to Textual
6.2.1 (the last release supporting 3.8.1), vendored with its pure-Python
dependencies in vendor/. The launcher puts vendor/ first on sys.path, so a
plain checkout runs with no pip and no network.

- dsflow/: the single script split into a package (pure moves of the
  backend sections); action rules moved to ops.py, free of Textual
- dsflow/ui/: tabs, detail pane, live sanity-run panel, log viewer,
  modal dialogs, filter, themes, mouse support
- tests/test_ui.py: headless UI tests through Textual's pilot
- tools/vendor.py (refresh vendor/), tools/screenshots.py (README images)
- README, CLAUDE.md, TODO and the feature doc updated for the new layout,
  the Python 3.8.1 floor and the vendoring rules

Verified: 11 tests green on Python 3.12 and 3.8.20; the shipped file set
runs under `python -I -S` on both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-24 03:24:21 -07:00

131 lines
3.6 KiB
Python
Vendored

from __future__ import annotations
from dataclasses import dataclass
from textual import events, on
from textual.app import ComposeResult
from textual.binding import Binding
from textual.containers import Center, Horizontal, ItemGrid, Vertical, VerticalScroll
from textual.demo.page import PageScreen
from textual.widgets import Footer, Label, Link, Markdown, Static
from textual.demo._project_stars import STARS
from textual.demo._project_data import PROJECTS, ProjectInfo
PROJECTS_MD = """\
# Projects
There are many amazing Open Source Textual apps available for download.
And many more still in development.
See below for a small selection!
"""
class Project(Vertical, can_focus=True, can_focus_children=False):
"""Display project information and open repo links."""
ALLOW_MAXIMIZE = True
DEFAULT_CSS = """
Project {
width: 1fr;
height: auto;
padding: 0 1;
border: tall transparent;
box-sizing: border-box;
&:focus {
border: tall $text-primary;
background: $primary 20%;
&.link {
color: red !important;
}
}
#title { text-style: bold; width: 1fr; }
#author { text-style: italic; }
.stars {
color: $text-accent;
text-align: right;
text-style: bold;
width: auto;
}
.header { height: 1; }
.link {
color: $text-accent;
text-style: underline;
}
.description { color: $text-muted; }
&.-hover { opacity: 1; }
}
"""
BINDINGS = [
Binding(
"enter",
"open_repository",
"open repo",
tooltip="Open the GitHub repository in your browser",
)
]
def __init__(self, project_info: ProjectInfo) -> None:
self.project_info = project_info
super().__init__()
def compose(self) -> ComposeResult:
info = self.project_info
with Horizontal(classes="header"):
yield Label(info.title, id="title")
yield Label(f"★ {STARS[info.title]}", classes="stars")
yield Label(info.author, id="author")
yield Link(info.url, tooltip="Click to open project repository")
yield Static(info.description, classes="description")
@on(events.Enter)
@on(events.Leave)
def on_enter(self, event: events.Enter):
event.stop()
self.set_class(self.is_mouse_over, "-hover")
def action_open_repository(self) -> None:
self.app.open_url(self.project_info.url)
class ProjectsScreen(PageScreen):
AUTO_FOCUS = None
CSS = """
ProjectsScreen {
align-horizontal: center;
ItemGrid {
margin: 2 4;
padding: 1 2;
background: $boost;
width: 1fr;
height: auto;
grid-gutter: 1 1;
grid-rows: auto;
keyline:thin $foreground 30%;
}
Markdown { margin: 0; padding: 0 2; max-width: 100; background: transparent; }
}
"""
def compose(self) -> ComposeResult:
with VerticalScroll() as container:
container.can_focus = False
with Center():
yield Markdown(PROJECTS_MD)
with ItemGrid(min_column_width=40):
for project in PROJECTS:
yield Project(project)
yield Footer()
if __name__ == "__main__":
from textual.app import App
class GameApp(App):
def get_default_screen(self) -> Screen:
return ProjectsScreen()
app = GameApp()
app.run()