Skip to content

[Repo Assist] refactor: extract App::switch_mode to eliminate tab-switching duplication #68

@github-actions

Description

@github-actions

🤖 This issue was created by Repo Assist, an automated AI assistant.

Motivation

The 7-line mode-switch sequence was duplicated verbatim in three places in handler.rs:

app.mode = (new);
app.selected = 0;
app.selected_packages.clear();
app.detail = None;
app.loading = true;
app.set_status("Loading...");
app.refresh_view();

Duplicated in:

  1. KeyCode::Tab | KeyCode::Right handler
  2. KeyCode::BackTab | KeyCode::Left handler
  3. handle_tab_click (mouse tab clicks)

Any future tab source (e.g. F1/F2/F3 shortcuts) would need to copy the same block again.

Change

Added App::switch_mode(mode: AppMode) to app.rs encapsulating the above sequence. All three call-sites now reduce to:

let new_mode = app.mode.cycle();
app.switch_mode(new_mode);
```

No behaviour change.

## Test Status

All 14 existing unit tests pass. `cargo clippy` — no warnings.

```
test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Click here to create the pull request

Generated by Repo Assist

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions