feat(tui): replace O(N) scanning with progressive loading and VisualHeightIndex

Replace synchronous file loading with AppLoadingState state machine (Empty/Loading/Ready/Error) for instant interactivity. Add ViewportCache for on-demand viewport computation, replacing global wrap/level caches. Integrate background indexer polling and file watcher events into the TUI event loop. Add loading UI with progress percentage, estimated line numbers with ~ prefix, and error state display. Eliminate all O(N) linear scans using VisualHeightIndex binary search.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
dailz
2026-04-14 09:07:18 +08:00
parent f9f451e0d6
commit bab3d9078a
4 changed files with 1161 additions and 251 deletions

View File

@@ -31,6 +31,8 @@ fn main() -> anyhow::Result<()> {
}
while !app.should_quit {
app.poll_background_indexer();
app.poll_file_watcher();
terminal.draw(|frame| ui::render(frame, &mut app))?;
if crossterm::event::poll(std::time::Duration::from_millis(100))? {
match crossterm::event::read()? {