Skip to content

10546 Revaluate focused track after undo redo - #10973

Merged
embarc-gabriel merged 1 commit into
audacity:masterfrom
embarc-gabriel:10546-revaluate-focused-track-on-undo-redo
Jun 2, 2026
Merged

embarc-gabriel merged 1 commit into
audacity:masterfrom
embarc-gabriel:10546-revaluate-focused-track-on-undo-redo

Conversation

@embarc-gabriel

Copy link
Copy Markdown
Contributor

Resolves: #10546

The focused track will emit the correct signal that will activate the correct navigation section.
This will allow the shortcuts to work again.

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

QA:

  • Testflow test cases have been run

@coderabbitai

coderabbitai Bot commented May 20, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds automatic focus revalidation to TrackNavigationController when the project's track list changes. A new private method, revalidateFocusedTrack(), checks whether the currently focused track ID still exists in the ordered track list. If the focused track is missing—after a track removal or other mutation—focus is updated to the first available track or marked as invalid if the list is empty. The method is wired into project track-change events (trackAdded, trackInserted, trackRemoved) so revalidation occurs automatically whenever tracks are mutated.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Revaluate focused track after undo redo' clearly describes the main change—adding functionality to revalidate focused track state after undo/redo operations, which is the primary objective of this PR.
Description check ✅ Passed The PR description adequately addresses the issue, explains the motivation (correct signal emission for navigation), includes issue reference (#10546), and completes required checklist items including CLA signature and commit verification.
Linked Issues check ✅ Passed The code changes directly address issue #10546 by implementing the revalidateFocusedTrack() method that hooks into track-change events to restore correct focused-track state and enable navigation-section activation after undo/redo operations.
Out of Scope Changes check ✅ Passed All changes are focused and in-scope: adding a private revalidateFocusedTrack() method, connecting it to track mutation events, and including the necessary algorithm header—all directly support the stated objective of restoring focused-track handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/trackedit/internal/undomanager.cpp (1)

81-86: ⚡ Quick win

Add a direct <algorithm> include for std::any_of.

std::any_of is used at line 85, but this translation unit does not explicitly include <algorithm>. Relying on transitive includes is brittle.

Proposed fix
 `#include` "undomanager.h"
 `#include` "changedetection.h"
+#include <algorithm>

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 26b3eddd-83ec-41db-b570-e7313a063bc0

📥 Commits

Reviewing files that changed from the base of the PR and between 4801978 and 2e2b31da6e4ff99f204c8d74dc9b373da0829362.

📒 Files selected for processing (2)
  • src/trackedit/internal/undomanager.cpp
  • src/trackedit/internal/undomanager.h

@embarc-gabriel
embarc-gabriel force-pushed the 10546-revaluate-focused-track-on-undo-redo branch from 2e2b31d to 05dfdd8 Compare May 20, 2026 12:26
@luapmartin luapmartin self-assigned this May 20, 2026

@luapmartin luapmartin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe that revalidate shouldn't be part of undomanager

Comment thread src/trackedit/internal/undomanager.cpp Resolved
Comment thread src/trackedit/internal/undomanager.cpp Resolved
@embarc-gabriel
embarc-gabriel force-pushed the 10546-revaluate-focused-track-on-undo-redo branch from 05dfdd8 to 61fc415 Compare May 20, 2026 15:03

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/trackedit/internal/undomanager.cpp (1)

28-29: ⚡ Quick win

Add regression coverage for all new revalidation hooks.

Please add/extend tests to assert revalidateFocusedTrack() is invoked on successful undo(), redo(), and undoRedoToIndex(), and not invoked on early-return paths.

Also applies to: 54-55, 80-81


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: caf80ae2-1060-4d69-bd7c-f60f81f346d2

📥 Commits

Reviewing files that changed from the base of the PR and between 05dfdd89bd2f75d8c0c3d4f53568c3aee55d6929 and 61fc4154071af1bbb42463431fcd817efe09b5bb.

📒 Files selected for processing (6)
  • src/trackedit/internal/itracknavigationcontroller.h
  • src/trackedit/internal/tracknavigationcontroller.cpp
  • src/trackedit/internal/tracknavigationcontroller.h
  • src/trackedit/internal/undomanager.cpp
  • src/trackedit/internal/undomanager.h
  • src/trackedit/tests/mocks/tracknavigationcontrollermock.h

Comment thread src/trackedit/internal/undomanager.cpp Resolved
@embarc-gabriel
embarc-gabriel force-pushed the 10546-revaluate-focused-track-on-undo-redo branch from 61fc415 to d90af3f Compare May 20, 2026 15:11
Comment thread src/trackedit/internal/undomanager.cpp Resolved
@embarc-gabriel
embarc-gabriel force-pushed the 10546-revaluate-focused-track-on-undo-redo branch from d90af3f to c456469 Compare May 21, 2026 09:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: af9197f3-d125-44bd-907d-b013556bd9cd

📥 Commits

Reviewing files that changed from the base of the PR and between d90af3f4bc1663ed59cb69f7a5b2e86bcbbf0f85 and c45646986bcde30960a44de6826102bc12c141df.

📒 Files selected for processing (2)
  • src/trackedit/internal/tracknavigationcontroller.cpp
  • src/trackedit/internal/tracknavigationcontroller.h

@embarc-gabriel
embarc-gabriel force-pushed the 10546-revaluate-focused-track-on-undo-redo branch from c456469 to 75f21fb Compare May 21, 2026 09:30
@embarc-gabriel
embarc-gabriel requested review from Eism and luapmartin May 21, 2026 09:33
@embarc-gabriel
embarc-gabriel merged commit b245ca5 into audacity:master Jun 2, 2026
9 checks passed
@embarc-gabriel
embarc-gabriel deleted the 10546-revaluate-focused-track-on-undo-redo branch August 28, 2026 10:22
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.

Edit shortcuts and menu commands are broken after editing and Undo/Redo

3 participants