Skip to content

Fix first added label not entering title edit mode - #11618

Merged
grliszas14 merged 4 commits into
audacity:masterfrom
grliszas14:first_label_fix
Sep 8, 2026
Merged

grliszas14 merged 4 commits into
audacity:masterfrom
grliszas14:first_label_fix

Conversation

@grliszas14

Copy link
Copy Markdown
Contributor

Resolves: #10083

  • 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

@grliszas14
grliszas14 requested a review from Eism August 7, 2026 14:09
@coderabbitai

coderabbitai Bot commented Aug 7, 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 6fe07239-a046-4bd6-a7b5-14d9488eb8c5

📥 Commits

Reviewing files that changed from the base of the PR and between a25a815488e2b661d4d063881ff14c0ec4b9a6f6 and 25f85f870628449bc40c1538723f6cbf67128073.

📒 Files selected for processing (10)
  • src/projectscene/view/tracksitemsview/tracklabelslistmodel.cpp
  • src/projectscene/view/tracksitemsview/tracklabelslistmodel.h
  • src/trackedit/CMakeLists.txt
  • src/trackedit/internal/trackeditactionscontroller.cpp
  • src/trackedit/internal/trackeditactionscontroller.h
  • src/trackedit/internal/tracksviewrequestsservice.cpp
  • src/trackedit/internal/tracksviewrequestsservice.h
  • src/trackedit/itracksviewrequestsservice.h
  • src/trackedit/trackeditmodule.cpp
  • src/trackedit/trackeditmodule.h
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/trackedit/trackeditmodule.h
  • src/trackedit/internal/trackeditactionscontroller.cpp
  • src/trackedit/internal/trackeditactionscontroller.h
  • src/projectscene/view/tracksitemsview/tracklabelslistmodel.cpp

📝 Walkthrough

Walkthrough

Label creation now returns the created LabelKey through muse::RetVal. Rename actions send title-edit requests through ITracksViewRequestsService. The service tracks pending requests and notifies TrackLabelsListModel. The model marks the matching TrackLabelItem, and QML starts editing asynchronously. Completed edits clear the request state and notify the service. Existing tests now read operation status from .ret.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TrackeditActionsController
  participant TracksViewRequestsService
  participant TrackLabelsListModel
  participant TrackLabelsContainer
  participant TrackLabelItem
  TrackeditActionsController->>TracksViewRequestsService: requestLabelTitleEdit(LabelKey)
  TracksViewRequestsService->>TrackLabelsListModel: publish label title-edit request
  TrackLabelsListModel->>TrackLabelItem: set titleEditRequested
  TrackLabelItem->>TrackLabelsContainer: titleEditRequestedChanged
  TrackLabelsContainer->>TrackLabelItem: editTitle()
  TrackLabelsContainer->>TrackLabelsListModel: titleEditRequestHandled(LabelKey)
  TrackLabelsListModel->>TracksViewRequestsService: clear handled request
Loading
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary fix for the first added label not entering title edit mode.
Description check ✅ Passed The description links issue #10083 and completes the required checklist, but it omits the template's short change and motivation summary.
Linked Issues check ✅ Passed The changes address issue #10083 by requesting title editing for newly created labels and preserving later rename behavior.
Out of Scope Changes check ✅ Passed The changes remain focused on the label title-edit workflow, including request handling, service plumbing, and related tests.

Warning

Review ran into problems

🔥 Problems

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/musescore.


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.

@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: 2

🧹 Nitpick comments (1)
src/trackedit/tests/au3labelsinteractions_tests.cpp (1)

92-95: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Assert the returned LabelKey, not only .ret.

These tests check only the success flag. A wrong LabelKey would pass the current assertions and could target the wrong label during title editing.

Capture the full muse::RetVal<LabelKey> result in at least one creation test. Compare result.val.trackId and result.val.itemId with the created label. Add the same check to the focused-track test.

Proposed test update
-    bool result = m_labelsInteraction->addLabelToSelection().ret;
+    const auto result = m_labelsInteraction->addLabelToSelection();

-    ASSERT_TRUE(result) << "Adding label to selection should succeed";
+    ASSERT_TRUE(result.ret) << "Adding label to selection should succeed";
...
+    EXPECT_EQ(result.val.trackId, TrackId(labelTrack->GetId()));
+    EXPECT_EQ(result.val.itemId, label->GetId());

Also applies to: 136-139, 183-186, 220-223, 257-270, 322-325, 378-383, 433-438


ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro Plus

Run ID: d1f547fe-ae71-408a-9830-66b3180dcc11

📥 Commits

Reviewing files that changed from the base of the PR and between c5a20ac and 09a601d6dcacee3f4432264488164b3310090e1f.

📒 Files selected for processing (23)
  • src/projectscene/qml/Audacity/ProjectScene/tracksitemsview/TrackLabelsContainer.qml
  • src/projectscene/view/tracksitemsview/tracklabelitem.cpp
  • src/projectscene/view/tracksitemsview/tracklabelitem.h
  • src/projectscene/view/tracksitemsview/tracklabelslistmodel.cpp
  • src/projectscene/view/tracksitemsview/tracklabelslistmodel.h
  • src/trackedit/CMakeLists.txt
  • src/trackedit/iitemrenamecontroller.h
  • src/trackedit/ilabelsinteraction.h
  • src/trackedit/internal/au3/au3labelsinteraction.cpp
  • src/trackedit/internal/au3/au3labelsinteraction.h
  • src/trackedit/internal/itemrenamecontroller.cpp
  • src/trackedit/internal/itemrenamecontroller.h
  • src/trackedit/internal/trackeditactionscontroller.cpp
  • src/trackedit/internal/trackeditactionscontroller.h
  • src/trackedit/internal/trackeditinteraction.cpp
  • src/trackedit/internal/trackeditinteraction.h
  • src/trackedit/internal/trackeditoperationcontroller.cpp
  • src/trackedit/internal/trackeditoperationcontroller.h
  • src/trackedit/itrackeditinteraction.h
  • src/trackedit/tests/au3labelsinteractions_tests.cpp
  • src/trackedit/tests/mocks/trackeditinteractionmock.h
  • src/trackedit/trackeditmodule.cpp
  • src/trackedit/trackeditmodule.h

Comment on lines +209 to +216
function startRequestedTitleEdit() {
if (!Boolean(itemData)) {
return
}

item.editTitle()
labelsModel.titleEditRequestHandled(itemData.key)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Re-check the request before running the deferred callback.

Both changed paths schedule startRequestedTitleEdit() for a later event-loop turn. If titleEditRequested becomes false or changes before the callback runs, the function still calls item.editTitle() because it checks only itemData. This can edit the wrong label or acknowledge a stale request.

Add the request-state check before starting the edit.

Proposed fix
 function startRequestedTitleEdit() {
-    if (!Boolean(itemData)) {
+    if (!Boolean(itemData) || !titleEditRequested) {
         return
     }

Also applies to: 218-223, 369-374

Comment thread src/trackedit/itracksviewcontroller.h Outdated
Comment on lines +23 to +25
virtual void requestLabelTitleEdit(const LabelKey& labelKey) = 0;
virtual std::optional<LabelKey> pendingLabelTitleEdit() const = 0;
virtual void labelTitleEditRequestHandled() = 0;

@coderabbitai coderabbitai Bot Aug 7, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Associate title-edit acknowledgments with the pending label.

An older asynchronous delegate acknowledgment can clear a newer pending request. This prevents the newer label from entering title edit mode.

  • src/trackedit/iitemrenamecontroller.h#L23-L25: change labelTitleEditRequestHandled() to accept const LabelKey&.
  • src/trackedit/internal/itemrenamecontroller.h#L32-L35: update the override signature.
  • src/trackedit/internal/itemrenamecontroller.cpp#L43-L57: reset m_pendingLabelTitleEdit only when the handled key matches it.
  • src/projectscene/view/tracksitemsview/tracklabelslistmodel.cpp#L198-L205: pass key.key to the controller.
Proposed fix
- virtual void labelTitleEditRequestHandled() = 0;
+ virtual void labelTitleEditRequestHandled(const LabelKey& labelKey) = 0;

- void labelTitleEditRequestHandled() override;
+ void labelTitleEditRequestHandled(const LabelKey& labelKey) override;

- void ItemRenameController::labelTitleEditRequestHandled()
+ void ItemRenameController::labelTitleEditRequestHandled(const LabelKey& labelKey)
  {
-     m_pendingLabelTitleEdit.reset();
+     if (m_pendingLabelTitleEdit && *m_pendingLabelTitleEdit == labelKey) {
+         m_pendingLabelTitleEdit.reset();
+     }
  }

- itemRenameController()->labelTitleEditRequestHandled();
+ itemRenameController()->labelTitleEditRequestHandled(key.key);
📍 Affects 4 files
  • src/trackedit/iitemrenamecontroller.h#L23-L25 (this comment)
  • src/trackedit/internal/itemrenamecontroller.h#L32-L35
  • src/trackedit/internal/itemrenamecontroller.cpp#L43-L57
  • src/projectscene/view/tracksitemsview/tracklabelslistmodel.cpp#L198-L205

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@grliszas14 I agree with bot, let's do it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@@ -204,6 +204,23 @@ TrackItemsContainer {

property var itemData: labelLoader.itemData

readonly property bool titleEditRequested: Boolean(itemData) && itemData.titleEditRequested

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you please explain how the logic works in qml? And can we convert it to a simple signal call instead of setting a property?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, we cannot emit a signal -> titleEditRequested stores a state and it is entire point of this fix. Previously we had simple signal call but it was often made before the delegate existed -> at that moment it reached no one and was lost, label never entered edit mode

@grliszas14
grliszas14 merged commit 07e6c36 into audacity:master Sep 8, 2026
5 of 10 checks passed
@grliszas14
grliszas14 deleted the first_label_fix branch September 8, 2026 13:47
kryksyh added a commit that referenced this pull request Sep 22, 2026
Fix first added label not entering title edit mode (#11618)
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.

One cannot immediately edit the name of the first label created in a project

2 participants