Skip to content

Fix DAG list cursor carrying over between environments - #695

Open
jvanbuel wants to merge 2 commits into
mainfrom
claude/airflow-dag-list-cache-bug-axik1p
Open

Fix DAG list cursor carrying over between environments#695
jvanbuel wants to merge 2 commits into
mainfrom
claude/airflow-dag-list-cache-bug-axik1p

Conversation

@jvanbuel

@jvanbuel jvanbuel commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Problem

Switching Airflow environments carried the DAG list cursor over from the previous environment. Landing in an environment with fewer DAGs parked the selection on the last row instead of the top, and the list rendered scrolled to the bottom.

Cause

clear_state() resets the view when switching environments, but only cleared each table's underlying data (table.all). The filtered view and its TableState — which holds the selected index and scroll offset — survived the switch.

Ratatui clamps an out-of-range selection to the last row when it renders (table.rs:757) and clamps the offset likewise (:998), so nothing rendered incorrectly. The cursor simply ended up somewhere the user never chose.

Fix

Reset the whole FilterableTable instead of just its data. FilterableTable::new() already clears items, filtered view, selection, scroll offset, filter and visual mode — so this is an assignment rather than a new helper.

self.dags.table = FilterableTable::new();
self.dagruns.table = FilterableTable::new();
self.task_instances.table = FilterableTable::new();

Note this also resets the filter on an environment switch, which the previous code preserved. That is intentional: a dag_id= filter written for one environment silently hides DAGs in the next, which is the same class of invisible stale state as the bug itself.

Also included

Removes FilterableTable::activate_filter, which had no callers — filter activation happens inside FilterStateMachine::update() when it sees /, reached via handle_filter_key().

Verification

cargo test --workspace --lib --bins (94 passing), cargo clippy --workspace --all-targets --all-features -- -D warnings, and cargo fmt --all --check all clean.

No regression test added: the fix is now an assignment to FilterableTable::new(), so a unit test would be exercising the language rather than the logic. A meaningful guard would need an App fixture at the clear_state level.

🤖 Generated with Claude Code

https://claude.ai/code/session_0127jzUgqqy8JVX5RydfQxh8


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Clearing application state now fully resets DAG, DAG run, and task instance tables.
    • Resolved stale table filters and state after clearing data.

claude added 2 commits July 24, 2026 20:15
clear_state(), which resets the view when switching Airflow environments,
only cleared each table's underlying data (table.all) and left the
filtered view and its TableState behind. The selected index therefore
survived the switch; ratatui clamps an out-of-range index to the last row
when it renders, so landing in a smaller environment silently parked the
cursor on the final DAG rather than at the top.

Reset the whole FilterableTable instead, which already clears the items,
filtered view, selection, scroll offset, filter and visual mode.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0127jzUgqqy8JVX5RydfQxh8
Filter activation happens inside FilterStateMachine::update() when it
sees '/', reached via handle_filter_key(); this wrapper had no callers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0127jzUgqqy8JVX5RydfQxh8
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c6aa9a41-cdac-48a2-86ea-10474c3575a3

📥 Commits

Reviewing files that changed from the base of the PR and between c16ad73 and 250cdc0.

📒 Files selected for processing (2)
  • src/app/model/filterable_table/mod.rs
  • src/app/state/mod.rs
💤 Files with no reviewable changes (1)
  • src/app/model/filterable_table/mod.rs

📝 Walkthrough

Walkthrough

The change removes FilterableTable::activate_filter() and updates App::clear_state to fully reset the DAG, DAG run, and task instance tables while leaving log collection clearing unchanged.

Changes

Filterable table state

Layer / File(s) Summary
Remove filter activation helper
src/app/model/filterable_table/mod.rs
Removes the public activate_filter() method from FilterableTable<T>.
Reset tables during state clearing
src/app/state/mod.rs
Imports FilterableTable and replaces the dags, dagruns, and task_instances tables with new instances during App::clear_state.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: stale DAG list cursor/state carrying over when switching environments.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/airflow-dag-list-cache-bug-axik1p

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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