Repository navigation
10648 persist audiocom multiple windows - #10689
embarc-gabriel merged 5 commits into
Conversation
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe PR moves au3cloud service creation/exports from context to module/global scope, replaces many Sequence Diagram(s)sequenceDiagram
participant UI as UI / Model
participant Dispatcher as ActionsDispatcher
participant Controller as CloudActionsController / Module
participant Auth as IAuthorization (global)
participant Interactive as Interactive
UI->>Dispatcher: dispatch(audacity://cloud/open-signin-dialog, {sync:, showTourPage:false})
Dispatcher->>Controller: route action
Controller->>Auth: isAuthorized()
alt authorized
Controller-->>UI: signed-in state (no-op)
else not authorized
Controller->>Interactive: open / openSync SIGNIN_URI (based on sync param)
Interactive-->>Auth: perform OAuth flow
Auth-->>Controller: auth state updated
Controller-->>UI: update signed-in state
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
au3/libraries/au3-cloud-audiocom/CloudSyncService.cpp (1)
383-391: 🧹 Nitpick | 🔵 TrivialInconsistent promise-reset pattern between
OpenFromCloudandSyncProject.
OpenFromCloudnow correctly resetsmSyncPromiseafter checkingmSyncInProcess, butSyncProjectstill resets it before the check (line 386). WhileSyncProjectis protected byASSERT_MAIN_THREAD(), consider aligning the patterns for consistency and clarity.♻️ Suggested alignment with OpenFromCloud pattern
CloudSyncService::SyncFuture CloudSyncService::SyncProject( AudacityProject& project, const std::string& path, bool forceSync, sync::ProgressCallback callback) { ASSERT_MAIN_THREAD(); - // Reset promise - mSyncPromise = {}; - if (mSyncInProcess.exchange(true)) { - CompleteSync({ sync::ProjectSyncResult::StatusCode::Blocked }); - return mSyncPromise.get_future(); + auto blockedPromise = SyncPromise {}; + blockedPromise.set_value({ sync::ProjectSyncResult::StatusCode::Blocked, {}, {} }); + return blockedPromise.get_future(); } + + // Reset promise + mSyncPromise = {};src/project/internal/projectactionscontroller.cpp (1)
805-825:⚠️ Potential issue | 🟠 MajorDouble authorization check with potential race condition.
The authorization is checked both at line 805 (before download) and at line 823 (before resuming sync). Both calls are subject to the race condition in
ensureAuthorization(). Additionally, if the user is prompted to sign in twice (once at line 805 and once at line 823), it creates a poor user experience.Consider caching the authorization result from the first check, or using the
authState()reactive channel to properly await authorization completion.src/au3cloud/internal/au3cloudservice.h (1)
51-51: 🧹 Nitpick | 🔵 TrivialConsider documenting ownership of
m_replyHandler.
m_replyHandleris a raw pointer that's parented tothisduringinit(), which ensures proper Qt-based cleanup. A brief comment clarifying this ownership model would improve maintainability.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 74e360b2-b59d-4f4c-9928-d3e1912d6c13
📥 Commits
Reviewing files that changed from the base of the PR and between cc65295 and 27dcb305f0ca26a4ec438cb667592a7fec93fe65.
📒 Files selected for processing (25)
au3/libraries/au3-cloud-audiocom/CloudSyncService.cppsrc/appshell/qml/Audacity/AppShell/FirstLaunchSetup/appupdateusageinfopagemodel.hsrc/appshell/qml/Audacity/AppShell/FirstLaunchSetup/signinaudiocompagemodel.hsrc/au3cloud/au3cloudmodule.cppsrc/au3cloud/au3cloudmodule.hsrc/au3cloud/dev/cloudtestsmodel.hsrc/au3cloud/iauthorization.hsrc/au3cloud/internal/au3audiocomservice.cppsrc/au3cloud/internal/au3cloudactionscontroller.cppsrc/au3cloud/internal/au3cloudactionscontroller.hsrc/au3cloud/internal/au3cloudservice.cppsrc/au3cloud/internal/au3cloudservice.hsrc/au3cloud/internal/oauthhttpserverreplyhandler.cppsrc/au3cloud/internal/oauthhttpserverreplyhandler.hsrc/au3cloud/iusageinfo.hsrc/au3cloud/view/accountinfomodel.cppsrc/au3cloud/view/accountinfomodel.hsrc/project/internal/projectactionscontroller.cppsrc/project/internal/projectactionscontroller.hsrc/project/view/cloudaudiofilesmodel.cppsrc/project/view/cloudaudiofilesmodel.hsrc/project/view/cloudprojectsmodel.cppsrc/project/view/cloudprojectsmodel.hsrc/stubs/au3cloud/authorizationstub.cppsrc/stubs/au3cloud/authorizationstub.h
💤 Files with no reviewable changes (2)
- src/stubs/au3cloud/authorizationstub.cpp
- src/stubs/au3cloud/authorizationstub.h
27dcb30 to
60176d9
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/au3cloud/internal/au3audiocomservice.cpp (1)
460-477:⚠️ Potential issue | 🔴 Critical
projectSaveCallback()is ignored, so uploads get marked aborted unconditionally.Line 461 only schedules the save on the main thread, but Lines 468-477 call
OnSyncCompleted(...Aborted...)immediately on the worker thread regardless of whether the save succeeds. That aborts successful uploads and races the actual save result.🐛 Proposed fix
if (projectSaveCallback) { muse::async::Async::call(this, [project, projectSaveCallback = std::move(projectSaveCallback)]() { bool ret = projectSaveCallback(); if (ret) { return; } - }, muse::runtime::mainThreadId()); - - au::au3::Au3Project* au3Project = reinterpret_cast<au::au3::Au3Project*>(project->au3ProjectPtr()); - if (!au3Project) { - return; - } - - auto& projectCloudExtension = audacity::cloud::audiocom::sync::ProjectCloudExtension::Get(*au3Project); - projectCloudExtension.OnSyncCompleted(nullptr, - audacity::cloud::audiocom::sync::CloudSyncError { - audacity::cloud::audiocom::sync::CloudSyncError::Aborted, muse::trc("project", "Could not save project locally") }, - AudiocomTrace::SaveProjectSaveToCloudMenu); + au::au3::Au3Project* au3Project = + reinterpret_cast<au::au3::Au3Project*>(project->au3ProjectPtr()); + if (!au3Project) { + return; + } + + auto& projectCloudExtension = + audacity::cloud::audiocom::sync::ProjectCloudExtension::Get(*au3Project); + projectCloudExtension.OnSyncCompleted( + nullptr, + audacity::cloud::audiocom::sync::CloudSyncError { + audacity::cloud::audiocom::sync::CloudSyncError::Aborted, + muse::trc("project", "Could not save project locally") + }, + AudiocomTrace::SaveProjectSaveToCloudMenu); + }, muse::runtime::mainThreadId()); }src/au3cloud/iauthorization.h (1)
13-29:⚠️ Potential issue | 🔴 CriticalIAuthorization interface removal breaks active call sites.
The interface no longer exposes
ensureAuthorization()orcheckCloudIsAvailable(), but these methods are still called actively insrc/project/internal/opensaveprojectscenario.cpp(lines 185, 191). These will not compile.Additionally, the change from context-scoped to
MODULE_GLOBAL_INTERFACEaffects linked consumers inmusescore/musescorewhich expect context-scoped cloud/auth APIs andContextPtr-based constructors.
♻️ Duplicate comments (1)
src/au3cloud/internal/au3cloudactionscontroller.cpp (1)
32-34:⚠️ Potential issue | 🟠 Major
showTourPageis bypassed for already-authorized users.Line 32 returns before the
showTourPagebranch, so requests withshowTourPage=truebecome no-op when auth is already present.Proposed fix
void Au3CloudActionsController::openSignInDialog(const muse::actions::ActionQuery& query) { - if (authorization()->isAuthorized()) { - return; - } - const bool showTourPage = query.param("showTourPage").toBool(); const bool sync = query.param("sync").toBool(); - if (sync) { - muse::RetVal<muse::Val> rv = interactive()->openSync(SIGNIN_URI); - if (!rv.ret) { - return; - } - } else { - interactive()->open(SIGNIN_URI); + if (!authorization()->isAuthorized()) { + if (sync) { + muse::RetVal<muse::Val> rv = interactive()->openSync(SIGNIN_URI); + if (!rv.ret) { + return; + } + } else { + interactive()->open(SIGNIN_URI); + } } if (showTourPage) { platformInteractive()->openUrl(TOUR_PAGE_URL); } }Also applies to: 48-50
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2cf08c22-3e7e-4de7-b191-66e336f26fc6
📥 Commits
Reviewing files that changed from the base of the PR and between 27dcb305f0ca26a4ec438cb667592a7fec93fe65 and 60176d9f466e2440c915de9efbc2997ce424df9d.
📒 Files selected for processing (25)
au3/libraries/au3-cloud-audiocom/CloudSyncService.cppsrc/appshell/qml/Audacity/AppShell/FirstLaunchSetup/appupdateusageinfopagemodel.hsrc/appshell/qml/Audacity/AppShell/FirstLaunchSetup/signinaudiocompagemodel.hsrc/au3cloud/au3cloudmodule.cppsrc/au3cloud/au3cloudmodule.hsrc/au3cloud/dev/cloudtestsmodel.hsrc/au3cloud/iauthorization.hsrc/au3cloud/internal/au3audiocomservice.cppsrc/au3cloud/internal/au3cloudactionscontroller.cppsrc/au3cloud/internal/au3cloudactionscontroller.hsrc/au3cloud/internal/au3cloudservice.cppsrc/au3cloud/internal/au3cloudservice.hsrc/au3cloud/internal/oauthhttpserverreplyhandler.cppsrc/au3cloud/internal/oauthhttpserverreplyhandler.hsrc/au3cloud/iusageinfo.hsrc/au3cloud/view/accountinfomodel.cppsrc/au3cloud/view/accountinfomodel.hsrc/project/internal/projectactionscontroller.cppsrc/project/internal/projectactionscontroller.hsrc/project/view/cloudaudiofilesmodel.cppsrc/project/view/cloudaudiofilesmodel.hsrc/project/view/cloudprojectsmodel.cppsrc/project/view/cloudprojectsmodel.hsrc/stubs/au3cloud/authorizationstub.cppsrc/stubs/au3cloud/authorizationstub.h
💤 Files with no reviewable changes (2)
- src/stubs/au3cloud/authorizationstub.h
- src/stubs/au3cloud/authorizationstub.cpp
60176d9 to
05a545f
Compare
05a545f to
30e3c02
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/au3cloud/internal/au3audiocomservice.cpp (1)
460-477:⚠️ Potential issue | 🔴 CriticalDon't mark the upload aborted before
projectSaveCallback()finishes.The save callback is now only queued onto the main thread, but
OnSyncCompleted(...Aborted...)runs immediately afterward regardless of the callback result. That aborts successful uploads and races the save itself.🛠️ Suggested fix
if (projectSaveCallback) { muse::async::Async::call(this, [project, projectSaveCallback = std::move(projectSaveCallback)]() { bool ret = projectSaveCallback(); if (ret) { return; } - }, muse::runtime::mainThreadId()); - - au::au3::Au3Project* au3Project = reinterpret_cast<au::au3::Au3Project*>(project->au3ProjectPtr()); - if (!au3Project) { - return; - } - - auto& projectCloudExtension = audacity::cloud::audiocom::sync::ProjectCloudExtension::Get(*au3Project); - projectCloudExtension.OnSyncCompleted(nullptr, - audacity::cloud::audiocom::sync::CloudSyncError { - audacity::cloud::audiocom::sync::CloudSyncError::Aborted, muse::trc("project", "Could not save project locally") }, - AudiocomTrace::SaveProjectSaveToCloudMenu); + auto* au3Project = reinterpret_cast<au::au3::Au3Project*>(project->au3ProjectPtr()); + if (!au3Project) { + return; + } + + auto& projectCloudExtension = audacity::cloud::audiocom::sync::ProjectCloudExtension::Get(*au3Project); + projectCloudExtension.OnSyncCompleted( + nullptr, + audacity::cloud::audiocom::sync::CloudSyncError { + audacity::cloud::audiocom::sync::CloudSyncError::Aborted, + muse::trc("project", "Could not save project locally") }, + AudiocomTrace::SaveProjectSaveToCloudMenu); + }, muse::runtime::mainThreadId()); }
♻️ Duplicate comments (2)
src/au3cloud/internal/au3audiocomservice.cpp (1)
564-582:⚠️ Potential issue | 🟠 MajorHandle
Blockedexplicitly and clean upNotFoundby the requested path.
OpenFromCloud()can returnStatusCode::Blockedwith noResponseResult, and failed opens do not populateProjectPath. The currentelsebranch therefore misclassifies blocked opens, and Line 578 will not remove the stale DB row onNotFound.🛠️ Suggested fix
- if (result.Status == sync::ProjectSyncResult::StatusCode::Succeeded) { - progress->finish(muse::make_ok()); - } else { - const auto err = syncResultCodeToErr(result.Result.Code); - if (err == Err::SyncResultNotFound) { - removeProjectFromDatabase(result.ProjectPath); - } - - progress->finish(make_ret(err)); - } + switch (result.Status) { + case sync::ProjectSyncResult::StatusCode::Succeeded: + progress->finish(muse::make_ok()); + break; + case sync::ProjectSyncResult::StatusCode::Blocked: + progress->finish(muse::make_ret( + muse::Ret::Code::UnknownError, + muse::trc("cloud", "Another cloud sync is already in progress"))); + break; + case sync::ProjectSyncResult::StatusCode::Failed: { + const auto err = syncResultCodeToErr(result.Result.Code); + if (err == Err::SyncResultNotFound) { + removeProjectFromDatabase(muse::io::path_t(path)); + } + + progress->finish(make_ret(err)); + break; + } + }src/au3cloud/internal/au3cloudactionscontroller.cpp (1)
32-49:⚠️ Potential issue | 🟠 MajorDon't return before processing
showTourPage.Line 32 makes
showTourPageunreachable for already-authorized users. With persisted auth, that becomes the common path, so callers that deliberately passshowTourPage=truenow no-op.Proposed fix
void Au3CloudActionsController::openSignInDialog(const muse::actions::ActionQuery& query) { - if (authorization()->isAuthorized()) { - return; - } - const bool showTourPage = query.param("showTourPage").toBool(); const bool sync = query.param("sync").toBool(); - if (sync) { - muse::RetVal<muse::Val> rv = interactive()->openSync(SIGNIN_URI); - if (!rv.ret) { - return; + if (!authorization()->isAuthorized()) { + if (sync) { + muse::RetVal<muse::Val> rv = interactive()->openSync(SIGNIN_URI); + if (!rv.ret) { + return; + } + } else { + interactive()->open(SIGNIN_URI); } - } else { - interactive()->open(SIGNIN_URI); } if (showTourPage) { platformInteractive()->openUrl(TOUR_PAGE_URL); } }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: adec51ee-0eb9-4fb2-9af4-99637b69364e
📥 Commits
Reviewing files that changed from the base of the PR and between 60176d9f466e2440c915de9efbc2997ce424df9d and 30e3c02.
📒 Files selected for processing (25)
au3/libraries/au3-cloud-audiocom/CloudSyncService.cppsrc/appshell/qml/Audacity/AppShell/FirstLaunchSetup/appupdateusageinfopagemodel.hsrc/appshell/qml/Audacity/AppShell/FirstLaunchSetup/signinaudiocompagemodel.hsrc/au3cloud/au3cloudmodule.cppsrc/au3cloud/au3cloudmodule.hsrc/au3cloud/dev/cloudtestsmodel.hsrc/au3cloud/iauthorization.hsrc/au3cloud/internal/au3audiocomservice.cppsrc/au3cloud/internal/au3cloudactionscontroller.cppsrc/au3cloud/internal/au3cloudactionscontroller.hsrc/au3cloud/internal/au3cloudservice.cppsrc/au3cloud/internal/au3cloudservice.hsrc/au3cloud/internal/oauthhttpserverreplyhandler.cppsrc/au3cloud/internal/oauthhttpserverreplyhandler.hsrc/au3cloud/iusageinfo.hsrc/au3cloud/view/accountinfomodel.cppsrc/au3cloud/view/accountinfomodel.hsrc/project/internal/projectactionscontroller.cppsrc/project/internal/projectactionscontroller.hsrc/project/view/cloudaudiofilesmodel.cppsrc/project/view/cloudaudiofilesmodel.hsrc/project/view/cloudprojectsmodel.cppsrc/project/view/cloudprojectsmodel.hsrc/stubs/au3cloud/authorizationstub.cppsrc/stubs/au3cloud/authorizationstub.h
💤 Files with no reviewable changes (2)
- src/stubs/au3cloud/authorizationstub.cpp
- src/stubs/au3cloud/authorizationstub.h
| Q_OBJECT | ||
|
|
||
| muse::ContextInject<IAuthorization> authorization = { this }; | ||
| muse::GlobalInject<IAuthorization> authorization; |
There was a problem hiding this comment.
Update the stub export to match this global injection.
authorization now resolves through GlobalInject, but src/stubs/au3cloud/au3cloudstubmodule.cpp still publishes IAuthorization via ioc()->registerExport(...). In stub/dev builds this model will dereference an unresolved dependency until the stub export is moved to globalIoc().
|
|
||
| namespace au::au3cloud { | ||
| class IUsageInfo : MODULE_EXPORT_INTERFACE | ||
| class IUsageInfo : MODULE_GLOBAL_INTERFACE |
There was a problem hiding this comment.
Keep the stub IUsageInfo export in global scope too.
This interface is now global, but src/stubs/au3cloud/au3cloudstubmodule.cpp still registers IUsageInfo on the context IoC. Any GlobalInject<IUsageInfo> consumer will fail under stub builds until that export is moved to globalIoc().
| if (!ensureAuthorization()) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Consider whether re-checking authorization is necessary here.
This ensureAuthorization() call occurs inside the progress->finished().onReceive() callback after successfully opening a cloud project. The user was already authenticated at line 801 before initiating the download.
If the auth check at line 801 passed and the download succeeded, under what scenario would the user become unauthorized by the time this callback fires? If token expiration mid-operation is a concern, this makes sense; otherwise, it may be redundant.
| muse::Ret ProjectActionsController::ensureAuthorization() | ||
| { | ||
| if (authorization()->isAuthorized()) { | ||
| return make_ret(Ret::Code::Ok); | ||
| } | ||
|
|
||
| muse::actions::ActionQuery query("audacity://cloud/open-signin-dialog"); | ||
| query.addParam("sync", muse::Val(true)); | ||
| query.addParam("showTourPage", muse::Val(false)); | ||
|
|
||
| dispatcher()->dispatch(query); | ||
|
|
||
| return authorization()->isAuthorized() ? make_ret(Ret::Code::Ok) : make_ret(Ret::Code::Cancel); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if there's synchronization between dialog close and auth state update
echo "=== Searching for auth state synchronization mechanisms ==="
rg -n "authState\(\).*onReceive|authState.*ch\.|waitFor" src/au3cloud/ src/project/ --type cpp -B 2 -A 3
echo ""
echo "=== Check SigninAudiocomPageModel for when dialog closes ==="
rg -n "close\(\)|reject\(\)|accept\(\)" src/appshell/ --type cpp -B 2 -A 3 | head -40
echo ""
echo "=== Check if dispatcher->dispatch blocks on sync actions ==="
rg -n "dispatch.*sync\|synchronous" src/framework/actions/ --type cpp --type h -B 2 -A 3 | head -30Repository: audacity/audacity
Length of output: 5578
🏁 Script executed:
#!/bin/bash
# Find Au3CloudActionsController::openSignInDialog implementation
echo "=== Looking for Au3CloudActionsController::openSignInDialog ==="
find . -name "*.cpp" -o -name "*.h" | xargs grep -l "Au3CloudActionsController\|openSignInDialog" | head -10
echo ""
echo "=== Search for Au3CloudActionsController and openSignInDialog ==="
rg -n "openSignInDialog|class Au3CloudActionsController" --type cpp --type h -A 10 | head -80Repository: audacity/audacity
Length of output: 4023
🏁 Script executed:
#!/bin/bash
# Find where auth state is set in Au3CloudService
echo "=== Search for authState.set or m_authState in au3cloud ==="
rg -n "m_authState.*set|authState.*set|m_authState\s*=" src/au3cloud/ --type cpp -B 2 -A 2
echo ""
echo "=== Look for OAuth token callback mechanism ==="
rg -n "onAuthReceived|onTokenReceived|OAuth.*callback" src/au3cloud/ --type cpp -B 3 -A 3Repository: audacity/audacity
Length of output: 7428
🏁 Script executed:
#!/bin/bash
# Check if there's any waiting or synchronization after openSync
echo "=== Search for interactive()->openSync usage ==="
rg -n "openSync\|interactive\(\)" src/au3cloud/ src/appshell/ --type cpp -B 5 -A 5 | head -100Repository: audacity/audacity
Length of output: 109
🏁 Script executed:
#!/bin/bash
# Get the full openSignInDialog implementation
echo "=== Full openSignInDialog implementation ==="
sed -n '30,60p' src/au3cloud/internal/au3cloudactionscontroller.cpp
echo ""
echo "=== Check if there's anything after openSync call ==="
rg -n "openSync" src/au3cloud/internal/au3cloudactionscontroller.cpp -A 15Repository: audacity/audacity
Length of output: 1041
🏁 Script executed:
#!/bin/bash
# Look for what interactive()->openSync does and returns
echo "=== Search for openSync definition ==="
rg -n "openSync\|IInteractive" src/ --type cpp --type h | grep -i "opensync\|class.*Interactive" | head -20Repository: audacity/audacity
Length of output: 99
🏁 Script executed:
#!/bin/bash
# Search for any event loop processing or signal emission in openSync context
echo "=== Look for event processing in the codebase ==="
rg -n "exec\(\)|processEvents\|QEventLoop" src/au3cloud/ src/project/ --type cpp | head -30
echo ""
echo "=== Check if OAuthHttpServerReplyHandler emits signal immediately or deferred ==="
rg -n "callbackReceived\|emit.*callback" src/au3cloud/internal/oauthhttpserverreplyhandler.cpp -B 3 -A 3Repository: audacity/audacity
Length of output: 255
🏁 Script executed:
#!/bin/bash
# Check what exactly happens in the callback - is it immediate or queued?
echo "=== Full callback connection and processing ==="
sed -n '20,100p' src/au3cloud/internal/au3cloudservice.cpp | grep -A 20 "callbackReceived"Repository: audacity/audacity
Length of output: 1048
🏁 Script executed:
#!/bin/bash
# Search the entire codebase for where callbacks are emitted in OAuthHttpServerReplyHandler
echo "=== Find where callbackReceived signal is emitted ==="
rg -n "Q_EMIT callbackReceived\|emit callbackReceived" src/ --type cppRepository: audacity/audacity
Length of output: 114
🏁 Script executed:
#!/bin/bash
# Search for where callbackReceived is emitted (try variations)
echo "=== Search for callbackReceived emission with variations ==="
rg -n "callbackReceived" src/au3cloud/internal/oauthhttpserverreplyhandler.cpp
echo ""
echo "=== Get the full OAuthHttpServerReplyHandler class definition ==="
rg -n "class OAuthHttpServerReplyHandler\|callbackReceived\|signals:" src/au3cloud/internal/oauthhttpserverreplyhandler.h -A 5
echo ""
echo "=== Look for HTTP request handling that might emit the signal ==="
rg -n "handle\|request\|reply\|POST\|GET" src/au3cloud/internal/oauthhttpserverreplyhandler.cpp | head -30Repository: audacity/audacity
Length of output: 312
🏁 Script executed:
#!/bin/bash
# Check timing: look at ensureAuthorization in projectactionscontroller
echo "=== Look at ensureAuthorization and when dispatch returns ==="
sed -n '1110,1130p' src/project/internal/projectactionscontroller.cpp
echo ""
echo "=== Check if there's event loop processing between dispatch and isAuthorized ==="
rg -n "dispatcher\(\)->dispatch" src/project/internal/projectactionscontroller.cpp -A 3 | head -20Repository: audacity/audacity
Length of output: 1310
🏁 Script executed:
#!/bin/bash
# Critical: understand if dispatch() blocks or is async
echo "=== Search for dispatcher->dispatch behavior ==="
rg -n "dispatch\(.*ActionQuery\)" src/project/ --type cpp -B 2 -A 2 | head -50
echo ""
echo "=== Look for IActionsDispatcher interface definition ==="
rg -n "IActionsDispatcher\|dispatch.*virtual\|class.*Dispatcher" src/ --type h | grep -i "actions\|dispatch" | head -20
echo ""
echo "=== Check if dispatch is synchronous by looking at its implementation ==="
rg -n "void dispatch\|RetVal.*dispatch" src/ --type h -A 2 | head -30Repository: audacity/audacity
Length of output: 242
🏁 Script executed:
#!/bin/bash
# Check when the HTTP callback is received - is it during openSync or after?
echo "=== Look for HTTP server implementation that handles the callback ==="
sed -n '140,160p' src/au3cloud/internal/oauthhttpserverreplyhandler.cpp
echo ""
echo "=== Get more context around the emit ==="
sed -n '140,165p' src/au3cloud/internal/oauthhttpserverreplyhandler.cppRepository: audacity/audacity
Length of output: 2096
🏁 Script executed:
#!/bin/bash
# Check what openSync returns and if there's any sync with auth state
echo "=== Look at how openSync is implemented ==="
rg -n "openSync.*IInteractive" src/ --type h -B 2 -A 8 | head -40
echo ""
echo "=== Check how AuthorizeCode works - is it sync or async? ==="
rg -n "AuthorizeCode" src/au3cloud/ --type cpp -B 3 -A 10 | head -60
echo ""
echo "=== Check if there's any blocking/waiting after dispatch ==="
rg -n "ensure.*Authorization\|openCloud.*Project" src/project/internal/projectactionscontroller.cpp -A 15 | head -80Repository: audacity/audacity
Length of output: 1380
🏁 Script executed:
#!/bin/bash
# Look at the past commits mentioned in the review
echo "=== Check git history for the mentioned fix commits ==="
git log --oneline | grep -E "de79fa2|60176d9" | head -5
echo ""
echo "=== Get info about those commits ==="
git show de79fa2 --stat 2>/dev/null | head -30
git show 60176d9 --stat 2>/dev/null | head -30Repository: audacity/audacity
Length of output: 501
🏁 Script executed:
#!/bin/bash
# Understand the signal connection type and callback timing
echo "=== Check the connect call for callbackReceived - is it async/queued? ==="
rg -n "connect.*callbackReceived\|callbackReceived.*connect" src/ --type cpp -B 2 -A 2
echo ""
echo "=== Check if AuthorizeCode is async (uses callbacks) ==="
rg -n "AuthorizeCode.*callback\|std::function.*token" src/ --type cpp -B 2 -A 3 | head -40
echo ""
echo "=== Verify the timing: when does the token callback execute? ==="
rg -n "AuthorizeCode" src/ --type h -A 8Repository: audacity/audacity
Length of output: 258
🏁 Script executed:
#!/bin/bash
# Most critical: does openSync() pump the event loop?
echo "=== Search for what openSync actually does - is it a dialog exec()? ==="
rg -n "interactive\(\)->openSync\|openSync" src/ --type h | head -20
echo ""
echo "=== Check if muse framework is available in repo or external ==="
find . -name "*Interactive*" -o -name "*interactive*" | grep -E "\.(h|cpp)$" | head -10Repository: audacity/audacity
Length of output: 198
🏁 Script executed:
#!/bin/bash
# Check the actual flow and timing
echo "=== Detailed: connection type check ==="
sed -n '25,35p' src/au3cloud/internal/au3cloudservice.cpp
echo ""
echo "=== Check AuthorizeCode parameters ==="
rg -n "AuthorizeCode.*code\|void.*AuthorizeCode" src/ --type h -A 5Repository: audacity/audacity
Length of output: 776
🏁 Script executed:
#!/bin/bash
# The connect() uses default Qt connection type - need to check if it's queued or direct
echo "=== Read the full connect line to see if connection type is specified ==="
sed -n '28,35p' src/au3cloud/internal/au3cloudservice.cpp
echo ""
echo "=== Check if dispatch is in the same thread or queued ==="
rg -n "dispatch" src/project/internal/projectactionscontroller.cpp -B 5 -A 5 | grep -A 5 -B 5 "1122"
echo ""
echo "=== Look for the dispatcher implementation or interface ==="
find . -path ./build -prune -o -name "*.h" -print | xargs grep -l "class.*Dispatcher\|IActionsDispatcher" | head -5Repository: audacity/audacity
Length of output: 1308
🏁 Script executed:
#!/bin/bash
# Check if dispatch blocks or returns immediately
echo "=== Search for dispatcher()->dispatch calling patterns ==="
rg -n "dispatcher\(\)->dispatch" src/ --type cpp | head -30
echo ""
echo "=== Check what type dispatcher() returns ==="
rg -n "dispatcher\(\)" src/au3cloud/internal/au3cloudactionscontroller.h -B 2 -A 2Repository: audacity/audacity
Length of output: 3854
🏁 Script executed:
#!/bin/bash
# Find the dispatcher type and see if it's blocking
echo "=== Check Au3CloudActionsController header for dispatcher type ==="
cat src/au3cloud/internal/au3cloudactionscontroller.h
echo ""
echo "=== Check what ContextInject is ==="
rg -n "ContextInject.*dispatcher" src/ --type h -B 2 -A 2 | head -20Repository: audacity/audacity
Length of output: 3063
🏁 Script executed:
#!/bin/bash
# Search for the muse::actions namespace to understand dispatch behavior
echo "=== Look for dispatch method signature ==="
rg -n "dispatch.*ActionQuery\|dispatch.*action" src/ --type h | grep -v "^Binary" | head -30
echo ""
echo "=== Check if there are any event loop pumps or sync waits in the code path ==="
rg -n "processEvents\|QEventLoop\|exec\(\)" src/au3cloud/ --type cpp | head -20Repository: audacity/audacity
Length of output: 183
🏁 Script executed:
#!/bin/bash
# Check the actual flow and understand if openSync pumps the event loop
echo "=== Get context on what openSync does by looking for its usage ==="
rg -n "openSync" src/ --type cpp -B 3 -A 3 | head -80
echo ""
echo "=== Check if the callback is emitted synchronously or asynchronously ==="
sed -n '145,160p' src/au3cloud/internal/oauthhttpserverreplyhandler.cppRepository: audacity/audacity
Length of output: 7779
🏁 Script executed:
#!/bin/bash
# Critical: check if there's event loop pumping during openSync
echo "=== Check dialog implementation to see if it pumps event loop ==="
rg -n "class.*Dialog\|QDialog\|exec\|eventLoop" src/ --type h | grep -E "(Dialog|IInteractive)" | head -20
echo ""
echo "=== Search for specific test or timing fix related to authorization ==="
git log --oneline --all | grep -i "auth\|cloud\|sync\|race" | head -20
echo ""
echo "=== Check if there's any synchronization between openSync returning and auth check ==="
rg -n "openSync\|isAuthorized" src/au3cloud/internal/au3cloudactionscontroller.cpp -A 15Repository: audacity/audacity
Length of output: 1426
🏁 Script executed:
#!/bin/bash
# Check the Qt signal connection type more carefully
echo "=== Look at the full connection to see if connection type is specified ==="
sed -n '25,65p' src/au3cloud/internal/au3cloudservice.cppRepository: audacity/audacity
Length of output: 2000
🏁 Script executed:
#!/bin/bash
# Check the commit that says "Return early if authorized"
echo "=== Check commit 30e3c023 ==="
git show 30e3c023 --stat
echo ""
echo "=== Check the actual changes in that commit ==="
git show 30e3c023Repository: audacity/audacity
Length of output: 50376
🏁 Script executed:
#!/bin/bash
# See the flow: openSync pumps event loop, but AuthorizeCode is async
echo "=== Verify AuthorizeCode is indeed async ==="
rg -n "void AuthorizeCode\|AuthorizeCode.*callback" src/ --type h -A 3 | head -40
echo ""
echo "=== Check what happens in the token callback - when does m_authState actually get set? ==="
sed -n '40,55p' src/au3cloud/internal/au3cloudservice.cppRepository: audacity/audacity
Length of output: 882
🏁 Script executed:
#!/bin/bash
# Final verification: check if there's any synchronization we missed
echo "=== Check if AuthorizeCode is truly async or blocks somewhere ==="
rg -n "AuthorizeCode" src/ --type h -A 15 | head -50
echo ""
echo "=== Verify if there's any event loop pumping or waiting after dispatch ==="
sed -n '1112,1135p' src/project/internal/projectactionscontroller.cpp
echo ""
echo "=== Check if token callback sets m_authState synchronously ==="
sed -n '40,75p' src/au3cloud/internal/au3cloudservice.cppRepository: audacity/audacity
Length of output: 2588
The authorization state is not synchronized with the sign-in dialog close event.
After openSync() returns (dialog closed), the authorization state is checked immediately via isAuthorized(). However, the OAuth token callback is asynchronous—it fires in response to a network call (AuthorizeCode() takes a callback parameter, not a return value). The token response callback, which calls m_authState.set(Authorized()), may not have completed by the time the authorization check executes.
This timing gap causes a race condition: successful sign-in appears to fail because isAuthorized() returns false on line 1124, even though the user successfully authenticated. The returned Ret::Code::Cancel blocks subsequent cloud operations.
To fix, add a blocking wait for the token callback to complete before returning from ensureAuthorization(), or restructure to confirm auth state updates before the method returns.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/au3cloud/internal/au3audiocomservice.cpp (1)
476-494:⚠️ Potential issue | 🔴 CriticalRace condition:
OnSyncCompleted(Aborted)is called unconditionally after async dispatch.The
muse::async::Async::calldispatchesprojectSaveCallbackto the main thread asynchronously but does not block. The worker thread immediately continues and callsOnSyncCompleted(...Aborted...)regardless of whether the callback succeeded or failed.This means:
- If
projectSaveCallback()returnstrue(success), the sync is still incorrectly marked as Aborted- There's a race between the main-thread callback and the worker-thread
OnSyncCompletedcall🐛 Proposed fix: synchronize with callback result
if (projectSaveCallback) { + std::promise<bool> savePromise; + auto saveFuture = savePromise.get_future(); + muse::async::Async::call(this, [project, projectSaveCallback = std::move(projectSaveCallback)]() { - bool ret = projectSaveCallback(); - if (ret) { - return; - } + return projectSaveCallback(); + }, muse::runtime::mainThreadId()).onResolve(this, [&savePromise](bool result) { + savePromise.set_value(result); }); - au::au3::Au3Project* au3Project = reinterpret_cast<au::au3::Au3Project*>(project->au3ProjectPtr()); - if (!au3Project) { - return; - } + bool saveSucceeded = saveFuture.get(); + if (saveSucceeded) { + return; // Save succeeded, sync completion handled by status subscription + } - auto& projectCloudExtension = audacity::cloud::audiocom::sync::ProjectCloudExtension::Get(*au3Project); - projectCloudExtension.OnSyncCompleted(nullptr, - audacity::cloud::audiocom::sync::CloudSyncError { - audacity::cloud::audiocom::sync::CloudSyncError::Aborted, muse::trc("project", "Could not save project locally") }, - AudiocomTrace::SaveProjectSaveToCloudMenu); + // Save failed - mark sync as aborted + au::au3::Au3Project* au3Project = reinterpret_cast<au::au3::Au3Project*>(project->au3ProjectPtr()); + if (au3Project) { + auto& projectCloudExtension = audacity::cloud::audiocom::sync::ProjectCloudExtension::Get(*au3Project); + projectCloudExtension.OnSyncCompleted(nullptr, + audacity::cloud::audiocom::sync::CloudSyncError { + audacity::cloud::audiocom::sync::CloudSyncError::Aborted, muse::trc("project", "Could not save project locally") }, + AudiocomTrace::SaveProjectSaveToCloudMenu); + } }Note: The exact fix depends on whether
muse::async::Async::callreturns a chainable promise. If not, consider using astd::promise/std::futurepair set from within the callback lambda.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: ASSERTIVE
Plan: Pro
Run ID: ca856946-cb24-4e60-a3c4-697ed7edfab0
📒 Files selected for processing (2)
src/au3cloud/internal/au3audiocomservice.cppsrc/au3cloud/internal/au3audiocomservice.h
Resolves: #10648
The account should be the same for all opened windows.
Recommended:
QA: