Skip to content

Commit a9a4bcf

Browse files
committed
fix(storage_setup): resolve setup flow issues for both GitHub and local modes
- Fix async step handle being cleared prematurely, causing setup to hang at "Validating token" step while subsequent steps completed silently - Fix incorrect "Storage already configured" error when a git repo exists at the default storage path but hasn't been configured yet
1 parent 0849566 commit a9a4bcf

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/app.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,12 @@ impl App {
241241
if let Some(handle) = &mut self.setup_step_handle {
242242
match handle.receiver.try_recv() {
243243
Ok(Ok(result)) => {
244+
// Note: handle_setup_step_result may set a NEW setup_step_handle
245+
// for the next step in the Continue case. We must NOT clear it here.
246+
// The old receiver is already consumed by try_recv() returning Ok.
244247
self.handle_setup_step_result(result)?;
245-
self.setup_step_handle = None;
248+
// Don't set setup_step_handle = None here! handle_setup_step_result
249+
// manages it: sets new handle for Continue, leaves as-is for Complete/Failed
246250
}
247251
Ok(Err(e)) => {
248252
error!("Setup step failed: {}", e);
@@ -1362,6 +1366,9 @@ impl App {
13621366
profiles,
13631367
is_new_repo,
13641368
} => {
1369+
// Clear the step handle - setup is complete
1370+
self.setup_step_handle = None;
1371+
13651372
// Update config with GitHub info
13661373
self.config.github = Some(github_config.clone());
13671374
self.config.repo_name = github_config.repo;
@@ -1402,6 +1409,9 @@ impl App {
14021409
error_message,
14031410
cleanup_repo,
14041411
} => {
1412+
// Clear the step handle - setup failed
1413+
self.setup_step_handle = None;
1414+
14051415
crate::services::StorageSetupService::cleanup_failed_setup(
14061416
&mut self.config,
14071417
&self.config_path,

src/screens/storage_setup.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,9 +1250,9 @@ impl Screen for StorageSetupScreen {
12501250
}
12511251

12521252
fn on_enter(&mut self, ctx: &ScreenContext) -> Result<()> {
1253-
// Check if already configured
1254-
let is_configured =
1255-
!ctx.config.repo_path.as_os_str().is_empty() && ctx.config.repo_path.exists();
1253+
// Check if already configured using the proper method
1254+
// This checks: GitHub mode with github config, OR Local mode with .git existing
1255+
let is_configured = ctx.config.is_repo_configured();
12561256

12571257
if is_configured {
12581258
// Reconfiguration mode - pre-fill with existing values

0 commit comments

Comments
 (0)