Make the product pass its own lint gate

`cargo clippy -p lumbridge -- -D warnings` has been failing: LumbridgeShell::new
was 104 lines against a pedantic limit of 100. It stayed invisible because
three separate things were each enough to hide it. The rust-ui job is
continue-on-error and so cannot fail a push; the job had never run at all,
since the split that created it was never pushed; and every historical green
run predates the shell leaving spikes/, where the workspace excluded it.
`./scripts/ci.sh --ui` reproduces it in seconds on any machine.

The fix is not an allow. `new` was doing four unrelated things, and the two
detached poll loops in the middle of it were the reason nobody could see the
constructor. They become named functions that say what they are for:
drive_synthetic_surfaces animates the comparison fixture the framework
benchmark is measured against, poll_runtime_events drains real PTY output on
its own interval and repaints only when something arrived, and
launch_restored_terminals gives every restored panel a runtime actor while
keeping -- not dropping -- one whose session failed to start, because decision
0011 makes a panel identity durable and a saved pane vanishing with no
explanation is worse than a pane carrying its fault.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SPYebLiN2w4TqnHUYGdECq
This commit is contained in:
Metal Agent
2026-09-01 13:04:31 -07:00
co-authored by Claude Opus 5
parent 18226b98e4
commit 164ede11c4
+60 -19
View File
@@ -368,10 +368,14 @@ fn dim_color(color: Rgba) -> Rgba {
} }
impl LumbridgeShell { impl LumbridgeShell {
fn new(window: &mut Window, cx: &mut Context<Self>) -> Self { /// Advances the deterministic comparison surfaces and the usage feed.
let root_focus = cx.focus_handle(); ///
window.focus(&root_focus); /// These five surfaces are not decoration: they are the workload the UI
/// framework comparison is measured against, so they keep running whether
/// or not a terminal is selected. The loop ends when `update` reports the
/// entity is gone, which is the only signal a detached task gets that the
/// window it was feeding has closed.
fn drive_synthetic_surfaces(cx: &mut Context<Self>) {
cx.spawn(async move |this, cx| { cx.spawn(async move |this, cx| {
loop { loop {
cx.background_executor() cx.background_executor()
@@ -391,7 +395,16 @@ impl LumbridgeShell {
} }
}) })
.detach(); .detach();
}
/// Drains whatever the runtime actors have produced since the last poll.
///
/// Separate from the synthetic tick above and on its own interval, because
/// one is a fixture being animated and the other is real PTY output whose
/// latency a person can feel. Repainting only when `drain_runtime_events`
/// reports something arrived keeps an idle terminal from waking the
/// renderer on every poll.
fn poll_runtime_events(cx: &mut Context<Self>) {
cx.spawn(async move |this, cx| { cx.spawn(async move |this, cx| {
loop { loop {
cx.background_executor().timer(RUNTIME_POLL_INTERVAL).await; cx.background_executor().timer(RUNTIME_POLL_INTERVAL).await;
@@ -408,6 +421,47 @@ impl LumbridgeShell {
} }
}) })
.detach(); .detach();
}
/// Gives every restored Terminal panel a runtime actor of its own.
///
/// A panel whose session cannot be launched is kept, not dropped, and
/// carries the failure as its status. Decision 0011 makes a panel identity
/// durable, so a panel that came back from `SQLite` and then failed to spawn
/// still has to appear -- silently omitting it would leave a workspace
/// missing a pane the user saved, with nothing on screen to say why.
fn launch_restored_terminals(
panels: &PanelRegistry,
dimensions: TerminalDimensions,
) -> (
RuntimeRegistry<PanelId>,
BTreeMap<PanelId, LiveTerminalState>,
) {
let mut runtimes = RuntimeRegistry::new();
let mut live_terminals = BTreeMap::new();
for panel in panels
.panels()
.iter()
.filter(|panel| panel.kind == PanelKind::Terminal)
{
let mut terminal = LiveTerminalState::new(dimensions);
if let Err(error) = spawn_live_runtime(&mut runtimes, panel.id, panel.seed, dimensions)
{
terminal.status = LiveRuntimeStatus::Fault(error.to_string());
}
live_terminals.insert(panel.id, terminal);
}
(runtimes, live_terminals)
}
}
impl LumbridgeShell {
fn new(window: &mut Window, cx: &mut Context<Self>) -> Self {
let root_focus = cx.focus_handle();
window.focus(&root_focus);
Self::drive_synthetic_surfaces(cx);
Self::poll_runtime_events(cx);
let (store, panels, persistence_status) = persistence::load_panel_registry(&ProcessEnv); let (store, panels, persistence_status) = persistence::load_panel_registry(&ProcessEnv);
let sidebar = SidebarState::default(); let sidebar = SidebarState::default();
@@ -418,21 +472,8 @@ impl LumbridgeShell {
sidebar.width(), sidebar.width(),
cell, cell,
); );
let mut runtimes = RuntimeRegistry::new(); let (runtimes, live_terminals) =
let mut live_terminals = BTreeMap::new(); Self::launch_restored_terminals(&panels, terminal_dimensions);
for panel in panels
.panels()
.iter()
.filter(|panel| panel.kind == PanelKind::Terminal)
{
let mut terminal = LiveTerminalState::new(terminal_dimensions);
if let Err(error) =
spawn_live_runtime(&mut runtimes, panel.id, panel.seed, terminal_dimensions)
{
terminal.status = LiveRuntimeStatus::Fault(error.to_string());
}
live_terminals.insert(panel.id, terminal);
}
cx.observe_window_bounds(window, |shell, window, cx| { cx.observe_window_bounds(window, |shell, window, cx| {
let dimensions = terminal_dimensions_for_window( let dimensions = terminal_dimensions_for_window(