Repository navigation
Fix first added label not entering title edit mode - #11618
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between a25a815488e2b661d4d063881ff14c0ec4b9a6f6 and 25f85f870628449bc40c1538723f6cbf67128073. 📒 Files selected for processing (10)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughLabel creation now returns the created 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
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Warning Review ran into problems🔥 ProblemsLinked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/trackedit/tests/au3labelsinteractions_tests.cpp (1)
92-95: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAssert the returned
LabelKey, not only.ret.These tests check only the success flag. A wrong
LabelKeywould 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. Compareresult.val.trackIdandresult.val.itemIdwith 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.qmlsrc/projectscene/view/tracksitemsview/tracklabelitem.cppsrc/projectscene/view/tracksitemsview/tracklabelitem.hsrc/projectscene/view/tracksitemsview/tracklabelslistmodel.cppsrc/projectscene/view/tracksitemsview/tracklabelslistmodel.hsrc/trackedit/CMakeLists.txtsrc/trackedit/iitemrenamecontroller.hsrc/trackedit/ilabelsinteraction.hsrc/trackedit/internal/au3/au3labelsinteraction.cppsrc/trackedit/internal/au3/au3labelsinteraction.hsrc/trackedit/internal/itemrenamecontroller.cppsrc/trackedit/internal/itemrenamecontroller.hsrc/trackedit/internal/trackeditactionscontroller.cppsrc/trackedit/internal/trackeditactionscontroller.hsrc/trackedit/internal/trackeditinteraction.cppsrc/trackedit/internal/trackeditinteraction.hsrc/trackedit/internal/trackeditoperationcontroller.cppsrc/trackedit/internal/trackeditoperationcontroller.hsrc/trackedit/itrackeditinteraction.hsrc/trackedit/tests/au3labelsinteractions_tests.cppsrc/trackedit/tests/mocks/trackeditinteractionmock.hsrc/trackedit/trackeditmodule.cppsrc/trackedit/trackeditmodule.h
| function startRequestedTitleEdit() { | ||
| if (!Boolean(itemData)) { | ||
| return | ||
| } | ||
|
|
||
| item.editTitle() | ||
| labelsModel.titleEditRequestHandled(itemData.key) | ||
| } |
There was a problem hiding this comment.
🎯 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
| virtual void requestLabelTitleEdit(const LabelKey& labelKey) = 0; | ||
| virtual std::optional<LabelKey> pendingLabelTitleEdit() const = 0; | ||
| virtual void labelTitleEditRequestHandled() = 0; |
There was a problem hiding this comment.
🎯 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: changelabelTitleEditRequestHandled()to acceptconst LabelKey&.src/trackedit/internal/itemrenamecontroller.h#L32-L35: update the override signature.src/trackedit/internal/itemrenamecontroller.cpp#L43-L57: resetm_pendingLabelTitleEditonly when the handled key matches it.src/projectscene/view/tracksitemsview/tracklabelslistmodel.cpp#L198-L205: passkey.keyto 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-L35src/trackedit/internal/itemrenamecontroller.cpp#L43-L57src/projectscene/view/tracksitemsview/tracklabelslistmodel.cpp#L198-L205
There was a problem hiding this comment.
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!
37f8561 to
c3718bb
Compare
| @@ -204,6 +204,23 @@ TrackItemsContainer { | |||
|
|
|||
| property var itemData: labelLoader.itemData | |||
|
|
|||
| readonly property bool titleEditRequested: Boolean(itemData) && itemData.titleEditRequested | |||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
a25a815 to
25f85f8
Compare
25f85f8 to
c320725
Compare
Fix first added label not entering title edit mode (#11618)
Resolves: #10083
Recommended:
QA: