mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-28 03:02:38 +01:00
The app held every flow in memory and redid all of its work for each new one: the sidebar mounted every domain and path node (its tree scrolled inside a container that never bounded it), every tree row looked up its atoms by scanning every atom the family had made, and the layout, detail pane and list rows re-rendered per flow. At 3,000 flows each new one cost about 90 ms of main thread, more than the traffic left time for. The app now holds a window of the newest 2,000 flows, applies new ones in batches, and loads older ones in pages from the database on scrolling to the top, through a new list_flows RPC that pages in SQL. The database keeps every flow. Also adds clear_flows: an RPC, POST /flows/clear on the control API, and a Clear button in the header that Cmd+K opens, confirming first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
1.7 KiB
Rust
58 lines
1.7 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use ts_rs::TS;
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
|
#[serde(rename_all = "snake_case")]
|
|
#[ts(export, export_to = "gen_rpc.ts")]
|
|
pub enum GlobalAction {
|
|
ProxyStart,
|
|
ProxyStop,
|
|
FlowsClear,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
|
#[serde(tag = "scope", rename_all = "snake_case")]
|
|
#[ts(export, export_to = "gen_rpc.ts")]
|
|
pub enum ActionInvocation {
|
|
Global { action: GlobalAction },
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
|
|
#[serde(rename_all = "camelCase")]
|
|
#[ts(export, export_to = "gen_rpc.ts")]
|
|
pub struct ActionMetadata {
|
|
pub label: String,
|
|
pub default_hotkey: Option<String>,
|
|
}
|
|
|
|
fn default_hotkey(mac: &str, other: &str) -> Option<String> {
|
|
if cfg!(target_os = "macos") { Some(mac.into()) } else { Some(other.into()) }
|
|
}
|
|
|
|
/// All global actions with their metadata, used by `list_actions` RPC.
|
|
pub fn all_global_actions() -> Vec<(ActionInvocation, ActionMetadata)> {
|
|
vec![
|
|
(
|
|
ActionInvocation::Global { action: GlobalAction::ProxyStart },
|
|
ActionMetadata {
|
|
label: "Start Proxy".into(),
|
|
default_hotkey: default_hotkey("Meta+Shift+P", "Ctrl+Shift+P"),
|
|
},
|
|
),
|
|
(
|
|
ActionInvocation::Global { action: GlobalAction::ProxyStop },
|
|
ActionMetadata {
|
|
label: "Stop Proxy".into(),
|
|
default_hotkey: default_hotkey("Meta+Shift+S", "Ctrl+Shift+S"),
|
|
},
|
|
),
|
|
(
|
|
ActionInvocation::Global { action: GlobalAction::FlowsClear },
|
|
ActionMetadata {
|
|
label: "Clear Flows".into(),
|
|
default_hotkey: default_hotkey("Meta+K", "Ctrl+K"),
|
|
},
|
|
),
|
|
]
|
|
}
|