Skip to content

Commit ac3b04b

Browse files
committed
fix(installer): pre-mark setup wizard complete on successful install
After a fresh install, the dashboard setup wizard overlays every route on every page load because routers/setup.py::setup_status reads ${SETUP_CONFIG_DIR}/setup-complete.json and returns first_run=true whenever the file is absent. The installer never wrote it, and it is only written by POST /api/setup/complete at the end of the wizard — so a user who never clicked through the 6 steps saw the wizard forever. Write the marker from all three installers (Linux phase 13, macOS install-macos.sh phase 6, Windows install-windows.ps1 phase 9) after the success card is shown and services are up. Payload matches the one written by POST /api/setup/complete: {"completed_at":"<ISO-8601 UTC>","version":"1.0.0"}. Host path: ${INSTALL_DIR}/data/config/setup-complete.json Container path: /data/config/setup-complete.json (via the ./data:/data bind mount in docker-compose.base.yml). Failure to write the marker is non-fatal (logged as a warning); wizard reappearing is cosmetic. The contract test in tests/contracts/test-installer-contracts.sh asserts all three installers emit the write.
1 parent d5154c3 commit ac3b04b

4 files changed

Lines changed: 63 additions & 0 deletions

File tree

dream-server/installers/macos/install-macos.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,22 @@ else
11501150
ai_warn "Perplexica auto-config skipped -- complete setup at http://localhost:3004"
11511151
fi
11521152

1153+
# ── Pre-mark setup wizard complete ──
1154+
# The dashboard-api reads ${INSTALL_DIR}/data/config/setup-complete.json
1155+
# (mounted at /data/config/setup-complete.json inside the container) to
1156+
# decide first_run state. Writing this here prevents the wizard from
1157+
# reappearing on every visit after a fresh install. Non-fatal.
1158+
_setup_config_dir="${INSTALL_DIR}/data/config"
1159+
_setup_complete_file="${_setup_config_dir}/setup-complete.json"
1160+
_completed_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)
1161+
if mkdir -p "${_setup_config_dir}" 2>/dev/null \
1162+
&& printf '{"completed_at": "%s", "version": "1.0.0"}\n' "${_completed_at}" > "${_setup_complete_file}" 2>/dev/null \
1163+
&& chmod 644 "${_setup_complete_file}" 2>/dev/null; then
1164+
ai_ok "Setup wizard pre-marked complete"
1165+
else
1166+
ai_warn "Could not write ${_setup_complete_file} (non-fatal)"
1167+
fi
1168+
11531169
# ── Success card ──
11541170
if ! $ALL_HEALTHY; then
11551171
echo ""

dream-server/installers/phases/13-summary.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ fi
4747
# Show the cinematic success card
4848
show_success_card "http://localhost:3000" "http://localhost:3001" "$LOCAL_IP"
4949

50+
# Mark the setup wizard as already completed for fresh installs. The
51+
# dashboard-api reads this file (container path /data/config/setup-complete.json,
52+
# mounted from ${INSTALL_DIR}/data) to decide first_run state; without it the
53+
# wizard reappears on every visit after a fresh install. Non-fatal — if the
54+
# write fails, the wizard simply shows once.
55+
if ! $DRY_RUN; then
56+
_setup_config_dir="${INSTALL_DIR}/data/config"
57+
_setup_complete_file="${_setup_config_dir}/setup-complete.json"
58+
_completed_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)
59+
if mkdir -p "${_setup_config_dir}" 2>/dev/null \
60+
&& printf '{"completed_at": "%s", "version": "1.0.0"}\n' "${_completed_at}" > "${_setup_complete_file}" 2>/dev/null \
61+
&& chmod 644 "${_setup_complete_file}" 2>/dev/null; then
62+
log "Setup wizard pre-marked complete at ${_setup_complete_file}"
63+
else
64+
ai_warn "Could not write ${_setup_complete_file} (non-fatal)"
65+
fi
66+
fi
67+
5068
# Check background tasks before showing additional info
5169
if [[ -f "$SCRIPT_DIR/installers/lib/background-tasks.sh" ]]; then
5270
. "$SCRIPT_DIR/installers/lib/background-tasks.sh"

dream-server/installers/windows/install-windows.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,23 @@ if ($allHealthy) {
877877
Write-SuccessCard
878878
}
879879

880+
# ── Pre-mark setup wizard complete ────────────────────────────────────────────
881+
# The dashboard-api reads ${INSTALL_DIR}/data/config/setup-complete.json
882+
# (mounted at /data/config/setup-complete.json inside the container) to decide
883+
# first_run state. Writing this here prevents the wizard from reappearing on
884+
# every visit after a fresh install. Non-fatal.
885+
try {
886+
$setupConfigDir = Join-Path $installDir "data\config"
887+
$setupCompleteFile = Join-Path $setupConfigDir "setup-complete.json"
888+
New-Item -Path $setupConfigDir -ItemType Directory -Force | Out-Null
889+
$completedAt = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
890+
$payload = @{ completed_at = $completedAt; version = "1.0.0" } | ConvertTo-Json -Compress
891+
Set-Content -Path $setupCompleteFile -Value $payload -Encoding UTF8
892+
Write-AISuccess "Setup wizard pre-marked complete"
893+
} catch {
894+
Write-AIWarn "Could not write setup-complete.json (non-fatal): $_"
895+
}
896+
880897
# ── Summary JSON (for CI / automation) ───────────────────────────────────────
881898
if ($SummaryJsonPath) {
882899
$summary = @{

dream-server/tests/contracts/test-installer-contracts.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,16 @@ if grep -q 'cdn.jsdelivr.net/npm/chart.js\|cdn.jsdelivr.net/npm/chartjs-adapter-
6767
exit 1
6868
fi
6969

70+
echo "[contract] installers pre-mark setup wizard complete"
71+
# All three installers must write data/config/setup-complete.json at install time
72+
# so the dashboard wizard doesn't reappear on every visit after a fresh install.
73+
# dashboard-api reads this file (container path /data/config/setup-complete.json,
74+
# mounted from ${INSTALL_DIR}/data) to decide first_run state.
75+
grep -q 'data/config/setup-complete.json' installers/phases/13-summary.sh \
76+
|| { echo "[FAIL] Linux phase 13 does not write data/config/setup-complete.json"; exit 1; }
77+
grep -q 'data/config/setup-complete.json' installers/macos/install-macos.sh \
78+
|| { echo "[FAIL] macOS installer does not write data/config/setup-complete.json"; exit 1; }
79+
grep -q 'data\\\\config\\\\setup-complete.json\|setup-complete.json' installers/windows/install-windows.ps1 \
80+
|| { echo "[FAIL] Windows installer does not write setup-complete.json"; exit 1; }
81+
7082
echo "[PASS] installer contracts"

0 commit comments

Comments
 (0)