Skip to content

Use core v0.61.0: safe mode says which line of the config is wrong, and repairs it in one click - #277

Merged
fylorn merged 1 commit into
devfrom
fix/safe-mode-config-error
Oct 4, 2026
Merged

fylorn merged 1 commit into
devfrom
fix/safe-mode-config-error

Conversation

@fylorn

@fylorn fylorn commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Why

After updating to 2026.10.2, a config that still had client_probes.titling: passthrough made core exit in safe mode too, and the app showed only "core 未运行 / 已停止" with no reason. Safe mode exists for exactly this case. Core 0.61.0 (ThinkWatch-Core#284) now serves the control plane with a stand-in when the configuration does not load and offers a one-click repair; this is the app side.

What

  • Config error page (safe mode, Status.config_rejected): file, line and stage, reason (the commonest field errors are now translated), the line itself, and actions: 一键修复 (when core offers one), 打开配置文件 (editor marks the line), 版本历史, 重新启动. It replaces every page except Settings, since the others would show core's stand-in.
  • One-click repair (ConfigRepairPlan / RepairConfig): lists the fixes (a value outside its choices goes back to the default, an unknown field is removed), then writes through the normal path; the previous version stays in version history. The yellow "config rejected" banner offers the same repair.
  • Back to normal on its own: when a working configuration lands in safe mode (repair, save, rollback, external edit), the shell restarts core in normal mode.
  • safe_mode:<pid>: the app connects to a safe-mode core on a cold start too; before, it only connected to running: and never learned the reason.
  • exited:<reason>: when the safe-mode core still exits (another instance holds the lock, YAML too broken to read the control key), the shell keeps core's stderr and shows its last error as "core 无法启动" + the reason, instead of "已停止". Menu bar and notices treat it like a failed start. Core's stderr is still echoed to the shell's stderr.
  • Pin core v0.61.0 (protocol 37), regenerate tw-api.ts, whitelist the two endpoints, zh translations for the new codes, fixtures.

Tests

  • pnpm typecheck, pnpm test (752, new: repair.test.ts, trouble.exited.test.ts)
  • cargo fmt, cargo clippy --all-targets -D warnings, cargo test with twcore 0.61.0 (new: a safe-mode core that exits reports what it said; last-error parsing)
  • Preview harness (?safe, ?rejected, ?down=exited): the page, the banner, and a repair that brings the app back to the overview
  • End to end against twcore: serve --safe on a broken config → /status → /config/repair → repaired file and history

🤖 Generated with Claude Code

…nd repairs it in one click

When the configuration did not load, core exited in safe mode too and the
app showed "core 未运行 / 已停止" with no reason. Core 0.61.0 now serves the
control plane with a stand-in in that case and reports the rejection from
the start; this is the app side.

- New page in safe mode when the configuration does not load: file, line,
  reason (translated: the commonest field errors now have their own
  codes), the line itself, and actions: one-click repair (when core offers
  one: values outside their choices go back to the default, unknown
  fields are removed), open the configuration file at that line, version
  history, restart. Other pages are replaced by it (settings stays).
- The yellow "config rejected" banner lists the same fixes with a Repair
  button.
- Once a working configuration lands in safe mode (repair, save,
  rollback, an edit in another editor), the shell restarts core in normal
  mode on its own.
- `safe_mode:<pid>`: the app connects to a safe-mode core on a cold start
  too; before, it only connected to `running:` and never learned the
  reason.
- `exited:<reason>`: when the safe-mode core still exits, the shell keeps
  core's stderr and shows its last error ("core 无法启动" + the reason)
  instead of "Stopped". Menu bar and notices treat it like a failed start.
- ConfigRepairPlan / RepairConfig whitelisted; zh translations for the new
  codes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit 790ab4a into dev Oct 4, 2026
4 checks passed
@fylorn
fylorn deleted the fix/safe-mode-config-error branch October 4, 2026 07:56
@fylorn fylorn mentioned this pull request Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant