Skip to content

tidy up#111

Merged
ynqa merged 70 commits intov0.7.1/devfrom
tidy-up
Mar 30, 2026
Merged

tidy up#111
ynqa merged 70 commits intov0.7.1/devfrom
tidy-up

Conversation

@ynqa
Copy link
Copy Markdown
Owner

@ynqa ynqa commented Mar 30, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 30, 2026 10:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the TUI runtime by splitting the previously monolithic prompt/editor/processor/search implementation into focused modules (query editor, completion, JSON viewer, guide, event dispatcher, runtime tasks) and centralizing shared state and debouncing utilities.

Changes:

  • Introduces modular async tasks for query editing, completion navigation, JSON viewing, guide messages, and terminal event dispatch.
  • Adds a reusable debouncer utility and a shared Context to coordinate UI focus and processing state.
  • Removes legacy prompt/editor/search/processor modules and updates dependencies accordingly.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/utils/debounce.rs New shared debouncer utility for query/resize events.
src/utils.rs Exposes debouncer setup from utils.
src/runtime_tasks.rs Adds background tasks for query-change forwarding and resize-driven re-rendering.
src/query_editor.rs New query editor component + action-driven task loop.
src/json_viewer.rs New JSON viewer component + action-driven rendering and processing tasks.
src/guide.rs New guide message/action system + rendering task.
src/event_dispatcher.rs Centralized terminal event loop that dispatches actions to components.
src/completion.rs New completion store/navigator + loader and action-driven task loop.
src/context.rs Shared app context (area, active pane, processing state, current task handle).
src/json.rs Simplifies JSON utilities (deserialize, jaq runner, path extraction).
src/main.rs Rewires the app to the new module/task architecture and adds terminal cleanup guard.
src/search.rs Removes legacy incremental searcher implementation.
src/editor.rs Removes legacy editor implementation.
src/prompt.rs Removes legacy monolithic prompt runtime.
src/processor.rs Removes legacy processor implementation.
src/processor/init.rs Removes legacy processor initializer.
src/processor/monitor.rs Removes legacy context monitor used by the spinner.
Cargo.toml Drops unused deps and updates toml version constraint.
Cargo.lock Lockfile updated for dependency removals/updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main.rs
Comment on lines +169 to +176
fn drop(&mut self) {
let _ = crossterm::execute!(
io::stdout(),
crossterm::cursor::Show,
crossterm::event::DisableMouseCapture
);
let _ = crossterm::terminal::disable_raw_mode();
}
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terminal cleanup currently restores cursor visibility and disables mouse capture/raw mode, but it does not leave the alternate screen. If the user exits while in JsonViewer mode (after EnterAlternateScreen), the terminal can remain stuck in the alternate buffer. Consider adding terminal::LeaveAlternateScreen (and/or ensuring it’s executed on exit paths) in this Drop cleanup.

Copilot uses AI. Check for mistakes.
Comment thread src/main.rs
.await;
);

// Wrap the query editor and completion navigator in Arc<Mutex<>> to allow shared mutable access across async tasks.
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment says the query editor and completion navigator are wrapped in Arc<Mutex<>>, but the code uses Arc<RwLock<...>>. Please update the comment to match the actual synchronization primitive to avoid misleading future changes.

Suggested change
// Wrap the query editor and completion navigator in Arc<Mutex<>> to allow shared mutable access across async tasks.
// Wrap the query editor and completion navigator in Arc<RwLock<...>> to allow shared mutable access across async tasks.

Copilot uses AI. Check for mistakes.
Comment thread src/json_viewer.rs
let mut ctx = shared_ctx.lock().await;
if let Some(task) = ctx.current_task.take() {
task.abort();
}
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When aborting ctx.current_task on query changes, the task may be cancelled while ctx.state is Processing and never reset to Idle. This can leave the app permanently “busy” (spinner keeps running; copy/switch-mode disabled). Consider resetting ctx.state when aborting, or using a cancellation-safe state transition so Idle is always restored even on task cancellation.

Suggested change
}
}
// Ensure we do not leave the context stuck in a Processing state
// if the aborted task would have been responsible for resetting it.
if matches!(ctx.state, State::Processing) {
ctx.state = State::Idle;
}

Copilot uses AI. Check for mistakes.
Comment thread src/json_viewer.rs
Comment on lines +313 to +317
// Set state to Idle to allow rendering of spinner frames in terminal.
{
let mut ctx = shared_ctx.lock().await;
ctx.state = State::Idle;
}
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "Set state to Idle to allow rendering of spinner frames", but elsewhere (and per spinner::State::is_idle) Idle means the spinner should stop. This looks inverted/misleading—please correct the comment to reflect the actual intent (likely preventing spinner overwrites / stopping the spinner).

Copilot uses AI. Check for mistakes.
@ynqa ynqa merged commit dadc9c3 into v0.7.1/dev Mar 30, 2026
7 checks passed
@ynqa ynqa deleted the tidy-up branch March 30, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants