fix(firmware): auto-connect 시 Scan UI 조건부 숨김 (cloud-mvp d0e5ca7 이식)

target 설정된 상태 (auto-connect 성공) 에서는 Scan 버튼 · Devices 리스트 숨김.
target 없거나 IDLE/SCANNING phase 에서만 노출.

Fallback: 연결 없이 진입하거나 auto-connect 실패 시 기존 스캔 UI 유지.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-08-03 15:44:13 +09:00
parent 33c4e94d07
commit 638b8e454c
@@ -233,9 +233,11 @@ fun DfuScreen(manager: DfuManager, modifier: Modifier = Modifier) {
}
// ── Actions ───────────────────────────────────────────────────────────────────────
// 2026-08-03: auto-connect 로 대부분 target 즉시 설정됨.
// target 없는 경우 (fresh install · 새 기기) 에만 수동 Scan/Stop 노출.
val hasTarget = target != null
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
// Keyed off the phase, not the scanner: the DFU re-scan also runs the scanner, and
// stopping that one from here would abort the update.
if (!hasTarget || phase == DfuPhase.IDLE || phase == DfuPhase.SCANNING) {
if (phase == DfuPhase.SCANNING) {
OutlinedButton(onClick = { manager.stopScan() }) { Text("Stop") }
} else {
@@ -244,6 +246,7 @@ fun DfuScreen(manager: DfuManager, modifier: Modifier = Modifier) {
enabled = !manager.isBusy,
) { Text("Scan") }
}
}
Button(
onClick = { manager.startDfu() },
@@ -261,7 +264,8 @@ fun DfuScreen(manager: DfuManager, modifier: Modifier = Modifier) {
}
}
// ── Discovered devices ────────────────────────────────────────────────────────────
// ── Discovered devices — target 없을 때만 (auto-connect 실패 · 첫 사용) ────────
if (!hasTarget) {
Text(
"Devices (${manager.devices.size})",
style = MaterialTheme.typography.labelLarge,
@@ -270,7 +274,6 @@ fun DfuScreen(manager: DfuManager, modifier: Modifier = Modifier) {
if (manager.devices.isEmpty()) {
Text(
when (phase) {
DfuPhase.CONNECTED -> "Connected — disconnect to scan again."
DfuPhase.SCANNING -> "Scanning…"
else -> "No devices yet — tap Scan."
},
@@ -290,6 +293,7 @@ fun DfuScreen(manager: DfuManager, modifier: Modifier = Modifier) {
}
}
}
}
// ── Log ───────────────────────────────────────────────────────────────────────────
Text("Log", style = MaterialTheme.typography.labelLarge)