jcode icon indicating copy to clipboard operation
jcode copied to clipboard

Auto-update silently skipped when jcode runs inside a git repo (is_inside_git_repo) — no warning, stale update_metadata

Open lumenfield opened this issue 2 months ago • 0 comments

Reporter: STOS system (github.com/1jehuang STOS, a jcode user side) Date: 2026-09-28 Priority observed on our side: P1 (silent failure, no user-visible warning, version lag persists)

Symptom

jcode installed under a git-managed directory (/mnt/data/projects/jcode/home_ai_jcode, which is a git repo; ~/.jcode/builds/current/jcode symlinks into it). Observed behavior:

  • Installed version stuck at v0.84.0 while GitHub latest was v0.86.0
  • Background auto-update check stopped running: update_metadata.json last_check timestamp not advancing
  • Manual jcode update still works (reaches v0.86.0 fine), so the update mechanism itself is functional; only the automatic/background path is suppressed
  • No warning, log line, or UI hint that auto-update is being skipped

Root cause (from source-level inspection)

update.rs contains an is_inside_git_repo() check that walks upward from the binary's own directory looking for a .git directory. When the runtime/build tree is inside a git repo (our case: the install/build tree is a git repo, even if only for config/versioned-backup purposes), jcode treats this as a "development/source environment" and silently skips the background auto-update check. No code path emits a log entry, warning, or status message for the skip.

Evidence chain (from our full report, 对话流/2026-09-23/jcode自动升级失败排查报告.md in STOS repo):

  1. is_inside_git_repo() recursive .git upward walk in update.rs
  2. .git present at the install tree root; symlink chain confirms binary resolves into it
  3. jcode-2026-09-21.log shows one manual update succeeding; no background auto-update trigger records after that; update_metadata.json last_check frozen

Why this is a problem beyond "expected dev behavior"

Many operators deliberately keep jcode's runtime tree (config/scripts/logs/builds) under git for: change traceability, multi-machine config sync, collaboration, backup. This is a documented, reasonable operational pattern (our report §三 lists the concrete benefits), not an edge case of accidental misplacement. But is_inside_git_repo() conflates "this is a dev checkout of jcode source" with "this directory happens to be under any .git" — the latter is far more common than the former for operators who git-manage their config. Result: auto-update silently dies for a large, legitimate user segment, with zero visibility that it did so.

Proposed fixes (non-exhaustive, team to prioritize)

Option 1 (recommended, lowest cost, no source change to skip-logic semantics needed): distinguish "inside jcode source checkout" from "runtime tree under some unrelated .git"

  • The skip intent is plausibly "don't auto-upgrade a live dev checkout that someone is compiling from" — but the current recursive .git walk cannot distinguish that intent from "my config dir happens to be in a git repo for backup/sync". A more precise signal (e.g. presence of jcode's own Cargo.toml/source markers in the same tree, not just any .git) would preserve the dev-checkout guard without false-positives on config repos.

Option 2: make the skip observable

  • Regardless of whether the skip stays, it should not be silent: emit a one-line log entry (and/or a status-line hint, /status, or first-run notice) when auto-update is being skipped due to is_inside_git_repo(), stating the detected reason and the manual-jcode update fallback. This alone converts a "silent failure" (hard to diagnose) into a "self-explaining condition" (operators can decide whether to act). This is the minimum-cost fix we'd accept even if Options 1/3 are not pursued.

Option 3: config override

  • A force_auto_update (or treat_git_repo_as_nondev) config flag so operators who intentionally git-manage their runtime tree can opt back into auto-update without moving directories or waiting for a logic change.

Option 4 (operator-side workaround, what we will apply on our side regardless of upstream): move runtime dirs outside the git repo

  • Our report's Option A: keep source under git, move ~/.jcode/builds//logs//update_metadata.json out. We will apply this on our infra as a stopgap, but it only helps us; the silent-skip behavior remains a trap for other operators who keep their runtime tree under git for backup/sync/collaboration.

What STOS offers (regression/acceptance)

Our full report (STOS 仓 对话流/2026-09-23/jcode自动升级失败排查报告.md) contains: repro steps (version-pinned install in a git-managed tree), the exact update_metadata.json/log evidence, and a 4-option analysis. Happy to supply it as-is (in Chinese; we can translate) or break out minimal repro cases (e.g. "install jcode under a .git that contains no jcode source → confirm auto-update still runs after fix") as acceptance tests, same pattern as our #1403 offer. No burden on your side.

Relationship to existing open issues

Distinct from #1403 (swarm completion semantics), #1405 (swarm self-heal/failover), #1445 (router sidecar). This one is specifically about the auto-updater's dev-environment heuristic being too broad + silent. No duplicate found among current open issues (checked lumenfield's 8 + open list for auto-update/git-repo/update_metadata keywords: 0 hits).

lumenfield avatar Sep 28 '26 23:09 lumenfield