Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): activate verified AppImage updates #21622

Openjuliusmarmingewants to merge 5 commits intodesktop-app-12/appimage-replacement fromrefs/pull/21622/headopened View on GitHub

juliusmarmingecommented

Use verified replacement for explicit installation and defensively cover install-on-quit if enabled; T3 currently disables automatic installation on quit. Activate it lazily on the real AppImage updater and preserve filename events, forced relaunch, and synchronous exit-after-install behavior. Bridge dependency logs into the existing desktop updater tracing context and restore the prior logger when the service closes.

This is the integration layer rebuilt from @MarMarLabs's #20117, above the verified file-replacement layer. It deliberately excludes the original shutdown wrappers and OTLP/file-drain changes. It does not guarantee delivery of final logs at process exit. Raw updater messages remain log messages, outside span attributes. The logger bridge also affects macOS and Windows: updater logs use the existing Effect logging configuration, including its minimum level; those native updater flows were not exercised.

Stack: #21621 is the required file-replacement layer.

Verification:

  • The original had 47 passing tests and 1 skipped across two files. The rebuilt stack has 22 passing tests in one existing file, including tests against the real AppImageUpdater, lazy activation, metadata verification, both launch modes, and the configured logger. Before integration, 6 new cases failed; bypassing production hook activation makes all four targeted integration cases fail.
  • 43 existing desktop update/lifecycle tests pass. Desktop typecheck, scoped lint and formatting pass.
  • Live Linux: actual updater installation under real cross-filesystem ENOSPC preserves the runnable 40 MiB installed executable; stock updater leaves an unrunnable 24 MiB partial file. A real bind-mounted cache alias retains the new executable after cleanup. These use shell executable fixtures, not packaged Electron/FUSE.
cross-filesystem ENOSPC: stock installedBytes=25165824 oldAppRuns=false
cross-filesystem ENOSPC: rebuilt installedBytes=41943040 oldAppRuns=true
bind-mounted cache alias: rebuilt newAppRuns=true destinationSurvivesCleanup=true

The boundary override relies on electron-updater 6.8.9 internals (doInstall, downloaded metadata, spawnLog); upgrades require revalidation. Packaged Linux success/failure, Electron shutdown/relaunch, and single-instance locking require human qualification before landing. An upstream electron-builder fix would remove the need for this local override; no upstream change was submitted. macOS, Windows, iOS, Android and Electron desktop UI were not exercised. No UI changed, so evidence is test/CLI output.

Staging always copies the download so a later verification, sync, or final-rename failure leaves the cached download available. This requires another AppImage-sized allocation even on one filesystem, and copy/hash/sync run synchronously during installation. Rename-first staging would need rollback handling to preserve a valid cache after later failures; that optimization is outside this repair.

Two independent full-stack review rounds (Claude Opus 5.5 and GPT-6-Sol) found no remaining code defects. The full-copy allocation/I/O cost is accepted and documented; packaged qualification remains a landing gate.

Implementation and tests: GPT-6.1-Sol and GPT-6-Astra through Codex in T3 Code; independent review: Claude Opus 5.5 and GPT-6-Sol in T3 Code.

Closes https://git.cafe/pingdotgg/t3code/issues/10685

Fixes pingdotgg/t3code#10685

    1. juliusmarminge changed the title

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. juliusmarminge added labelsmacroscope-review

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs Human Approval

      Macroscope's review found this PR requires human approval — The changes include extensive release and preview automation plus a new pnpm hook. That hook adds a lint suppression at .pnpmfile.cjs:31, which requires human review even with its documented justification.

      Needs human approval because:

      • 5 blocking correctness issues found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      Important

      Review skipped

      We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • Trigger review

      No actionable comments were generated in the recent review.

      Walkthrough

      The desktop updater now initializes its shared updater when service operations run. It adds scoped logging and tracing, and verifies AppImage update metadata and installation before relaunching.

      Changes: Desktop updater

      Layer / File(s)Summary
      AppImage installation verification
      apps/desktop/src/electron/AppImageInstall.ts, apps/desktop/src/electron/ElectronUpdater.test.ts
      The AppImage install hook validates the image path and update metadata, installs the update, emits a filename-change event when needed, and relaunches the destination. Integration tests cover invalid or incomplete updates, versioned filenames, and custom filenames.
      Effectful updater lifecycle
      apps/desktop/src/electron/ElectronUpdater.ts, apps/desktop/src/electron/ElectronUpdater.test.ts, apps/desktop/src/main.ts
      The updater service initializes the shared updater when operations run. It adds a scoped component logger, registers and removes listeners within a scope, and receives desktop observability through the foundation layer. Tests cover deferred access and logger and tracing capture.

      Estimated code review effort: 3 (Moderate) | ~25 minutes

      Change: Bug fix

      Sequence Diagram(s)

      sequenceDiagram
        participant ElectronUpdater
        participant AppImageUpdater
        participant verifyAppImageInstalls
        participant AppImageProcess
        ElectronUpdater->>AppImageUpdater: call quitAndInstall
        AppImageUpdater->>verifyAppImageInstalls: invoke doInstall
        verifyAppImageInstalls->>verifyAppImageInstalls: validate APPIMAGE path and update metadata
        verifyAppImageInstalls->>AppImageUpdater: install update and emit filename event when changed
        verifyAppImageInstalls->>AppImageProcess: relaunch with silent-install flag

      Suggested reviewers: maria-rcks

      Merge Risk: Minimal · previous review 74d7f

      No actionable defect remains from the reviewed changes; the PR is mergeable after normal checks.

      Pre-merge checks: Passed 3 · Failed 1

      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Description checkWarningThe description gives detailed implementation and verification information, but it does not state the underlying problem or expected behavior in a dedicated Problem section. It also does not provide e…Add a Problem section that states the issue, expected behavior, and relevant reproduction context. Add the triaged issue or approval discussion with the maintainer’s explicit approval comment, or explain why this is a small, focused fix tha…
      Passed Passed checks: 3 passed

      Check nameStatusExplanation
      Title checkPassedThe title is concise, conventional, and accurately describes the main change: activating verified AppImage updates in the desktop updater.
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Description check

      Explanation

      The description gives detailed implementation and verification information, but it does not state the underlying problem or expected behavior in a dedicated Problem section. It also does not provide explicit maintainer approval for the scope; closing a linked issue does not show that approval.

      Resolution

      Add a Problem section that states the issue, expected behavior, and relevant reproduction context. Add the triaged issue or approval discussion with the maintainer’s explicit approval comment, or explain why this is a small, focused fix that qualifies for the exception.

      Finishing Touches

      Generate docstrings

      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      ℹ️ Recent review info

      ⚙️ Run configuration

      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: 4a5a6d14-6bde-4db6-81bb-70f67320e2b9
      📥 Commits

      Reviewing files that changed from the base of the PR and between 4e41d353b0eb7b5096d064a9323521146d382d1a and 74d7f48541b5d3831e784633a890ce2d9a4aab24.

      📒 Files selected for processing: 4

      • apps/desktop/src/electron/AppImageInstall.ts
      • apps/desktop/src/electron/ElectronUpdater.test.ts
      • apps/desktop/src/electron/ElectronUpdater.ts
      • apps/desktop/src/main.ts

      Limit details: You’ve used all 10 included reviews currently available.

    6. juliusmarminge added labelsbugfix

    7. juliusmarminge added labelspr:needs-julius

    8. P2 — the forced relaunch path can still report a successful install when the new process fails to spawn. spawnLog is asynchronous and returns a Promise; this override discards that Promise with void and immediately returns true. A spawn error/rejection therefore cannot reach the install failure/error path, while the updater treats doInstall as successful and proceeds with its quit handoff. The new tests only mock spawnLog as Promise.resolve(true) and assert that it was called; they do not cover a rejected spawn. This is directly relevant to the fresh 5 Nov report on #10685 (comment #6665498679): the updated AppImage was full-size and the target version was present, but the desktop/server did not relaunch. That report does not prove this exact cause, but it makes this untested failure boundary material. Please add an original-scenario regression with spawnLog rejecting (for example, an executable/launch failure) and propagate that failure through the updater's install result/error path so the old process is not told to quit as though relaunch succeeded. Preserve the downloaded recovery artifact or otherwise document the safe retry path. Packaged Electron launch acceptance remains a separate gate.

    9. @@ -0,0 +79,21 @@
      79+ - name: Destroy preview stage
      80+ run: vp run --filter t3code-relay destroy --stage "$STAGE" --yes --no-input
      81+ env:
      82+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
      83+ PLANETSCALE_API_TOKEN_ID: ${{ secrets.PLANETSCALE_API_TOKEN_ID }}
      84+ PLANETSCALE_API_TOKEN: ${{ secrets.PLANETSCALE_API_TOKEN }}
      85+ AXIOM_TOKEN: ${{ secrets.AXIOM_TOKEN }}
      86+ CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
      87+
      88+ # Only reached after a successful destroy. A failed one keeps the label,
      89+ # so the scheduled retry picks the PR up again.
      90+ - name: Clear the teardown marker
      91+ if: github.event.action == 'closed'
      92+ run: gh pr edit "${{ github.event.pull_request.number }}" --repo "$GITHUB_REPOSITORY" --remove-label relay:preview
      93+
      94+ # An unlabeled event has already removed the label, so a failed teardown
      95+ # must put it back or no retry will ever see the stage. Labels added with
      96+ # GITHUB_TOKEN do not start new runs, so this does not redeploy.
      97+ - name: Restore the teardown marker after a failed destroy
      98+ if: failure() && github.event.action == 'unlabeled'
      99+ run: gh pr edit "${{ github.event.pull_request.number }}" --repo "$GITHUB_REPOSITORY" --add-label relay:preview
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium workflows/relay-preview-cleanup.yml:99

      When teardown fails after relay:preview is removed from an open PR, this step restores the deployment opt-in, so a later synchronize can redeploy the preview; the retry sweep then ignores that PR because it lists only closed PRs and skips open ones. Use a separate teardown marker and retry disabled previews without restoring relay:preview.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @.github/workflows/relay-preview-cleanup.yml around line 99:
      
      When teardown fails after `relay:preview` is removed from an open PR, this step restores the deployment opt-in, so a later `synchronize` can redeploy the preview; the retry sweep then ignores that PR because it lists only closed PRs and skips open ones. Use a separate teardown marker and retry disabled previews without restoring `relay:preview`.
      @@ -0,0 +93,21 @@
      93+ let existing = null;
      94+ for (let page = 1; existing === null; page++) {
      95+ const comments = await github(
      96+ `/repos/${repository}/issues/${pr}/comments?per_page=100&page=${page}`,
      97+ );
      98+ // Only this workflow's own comment: anyone can post the marker, and nobody else's is editable.
      99+ existing =
      100+ comments.find(
      101+ (comment) =>
      102+ comment.user?.login === "github-actions[bot]" && readState(comment.body) !== null,
      103+ ) ?? null;
      104+ if (comments.length < 100) break;
      105+ }
      106+ const state = mergeState(readState(existing?.body), {
      107+ fingerprint: process.env.FINGERPRINT ?? "",
      108+ client: process.env.CLIENT ?? "",
      109+ group: process.env.GROUP ?? "",
      110+ });
      111+ const body = JSON.stringify({ body: render(state, runUrl) });
      112+ if (existing) {
      113+ await github(`/repos/${repository}/issues/comments/${existing.id}`, { method: "PATCH", body });
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium scripts/mobile-preview-comment.cjs:113

      Concurrent android-build and android jobs can overwrite each other's comment state: the older build can restore a stale fingerprint/group, or the update can erase the newly added install link. Each PATCH replaces the complete body using a state read before either write, so mergeState's fingerprint guard checks a stale snapshot; serialize both writers per PR across the read/merge/write transaction.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @.github/scripts/mobile-preview-comment.cjs around line 113:
      
      Concurrent `android-build` and `android` jobs can overwrite each other's comment state: the older build can restore a stale fingerprint/group, or the update can erase the newly added install link. Each PATCH replaces the complete body using a state read before either write, so `mergeState`'s fingerprint guard checks a stale snapshot; serialize both writers per PR across the read/merge/write transaction.
      @@ -0,0 +60,21 @@
      60+ - name: Checkout default branch
      61+ uses: actions/checkout@v6
      62+ with:
      63+ ref: ${{ github.event.repository.default_branch }}
      64+ sparse-checkout: |
      65+ /*
      66+ !/.repos/
      67+ sparse-checkout-cone-mode: false
      68+
      69+ - name: Setup Vite+
      70+ uses: voidzero-dev/setup-vp@v1
      71+ with:
      72+ node-version-file: package.json
      73+ cache: true
      74+ run-install: |
      75+ args:
      76+ - --filter=t3code-relay...
      77+
      78+ # Destroy also runs the preview tunnel sweep, which is part of the stack.
      79+ - name: Destroy preview stage
      80+ run: vp run --filter t3code-relay destroy --stage "$STAGE" --yes --no-input
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium workflows/relay-preview-cleanup.yml:80

      A delayed closed or unlabeled run can destroy the active pr-<n> stage after the PR has been reopened and redeployed, and a stale closed run can also remove its deployment label. The concurrency group prevents overlap but does not guarantee event ordering, and cleanup_pr never checks the PR’s current state or labels before destroying the stage; recheck eligibility after acquiring the lock and skip stale runs.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @.github/workflows/relay-preview-cleanup.yml around line 80:
      
      A delayed `closed` or `unlabeled` run can destroy the active `pr-<n>` stage after the PR has been reopened and redeployed, and a stale `closed` run can also remove its deployment label. The concurrency group prevents overlap but does not guarantee event ordering, and `cleanup_pr` never checks the PR’s current state or labels before destroying the stage; recheck eligibility after acquiring the lock and skip stale runs.
      @@ -0,0 +209,21 @@
      209+ - id: update
      210+ name: Publish the Android update
      211+ if: steps.expo-token.outputs.present == 'true'
      212+ working-directory: apps/mobile
      213+ shell: bash
      214+ env:
      215+ EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
      216+ PR: ${{ github.event.pull_request.number }}
      217+ run: |
      218+ group="$(eas update --auto --branch "pr-$PR" --platform android --environment preview --non-interactive --json | sed -n '/^\[/,$p' | jq -er '.[0].group')"
      219+ echo "group=$group" >> "$GITHUB_OUTPUT"
      220+
      221+ - name: Comment
      222+ if: steps.expo-token.outputs.present == 'true'
      223+ env:
      224+ GH_TOKEN: ${{ github.token }}
      225+ PR: ${{ github.event.pull_request.number }}
      226+ FINGERPRINT: ${{ steps.client.outputs.fingerprint }}
      227+ CLIENT: ${{ steps.client.outputs.link }}
      228+ GROUP: ${{ steps.update.outputs.group }}
      229+ run: node .trusted/.github/scripts/mobile-preview-comment.cjs
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High workflows/mobile-eas-preview-fork.yml:229

      Fork-controlled scripts can replace .trusted/.github/scripts/mobile-preview-comment.cjs before this step executes it, so the replacement runs with GH_TOKEN and the job’s pull-requests: write permission. This lets the fork modify other PRs’ comments or labels; the Android build job repeats the same trust-boundary problem. Run commenting in a separate trusted job that never executes fork code.

      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @.github/workflows/mobile-eas-preview-fork.yml around line 229:
      
      Fork-controlled scripts can replace `.trusted/.github/scripts/mobile-preview-comment.cjs` before this step executes it, so the replacement runs with `GH_TOKEN` and the job’s `pull-requests: write` permission. This lets the fork modify other PRs’ comments or labels; the Android build job repeats the same trust-boundary problem. Run commenting in a separate trusted job that never executes fork code.
      @@ -0,0 +4,21 @@
      4+# This job runs the PR's own code with account credentials, so it waits for an
      5+# approval in the `relay-preview` environment on every run. Teardown is in
      6+# relay-preview-cleanup.yml and never runs PR code.
      7+on:
      8+ pull_request:
      9+ types: [labeled, synchronize, reopened]
      10+
      11+permissions:
      12+ contents: read
      13+ pull-requests: read
      14+
      15+concurrency:
      16+ group: relay-preview-${{ github.event.pull_request.number }}
      17+ cancel-in-progress: false
      18+
      19+jobs:
      20+ deploy_preview:
      21+ name: Deploy relay preview
      22+ if: >-
      23+ github.event.pull_request.head.repo.full_name == github.repository &&
      24+ contains(github.event.pull_request.labels.*.name, 'relay:preview')
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium workflows/relay-preview.yml:15

      A labeled run after relay:preview is removed replaces the queued cleanup run for the same PR, leaving the preview resources running even though deploy_preview is skipped. Workflow-level concurrency applies before the job’s eligibility check; move the concurrency block onto deploy_preview after its if condition so skipped runs cannot replace cleanup.

      - concurrency:
      -   group: relay-preview-${{ github.event.pull_request.number }}
      -   cancel-in-progress: false
      -
       jobs:
         deploy_preview:
           name: Deploy relay preview
           if: >-
             github.event.pull_request.head.repo.full_name == github.repository &&
             contains(github.event.pull_request.labels.*.name, 'relay:preview')
      +    concurrency:
      +      group: relay-preview-${{ github.event.pull_request.number }}
      +      cancel-in-progress: false
           runs-on: blacksmith-8vcpu-ubuntu-2404
      🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
      In file @.github/workflows/relay-preview.yml around lines 15-24:
      
      A `labeled` run after `relay:preview` is removed replaces the queued cleanup run for the same PR, leaving the preview resources running even though `deploy_preview` is skipped. Workflow-level concurrency applies before the job’s eligibility check; move the concurrency block onto `deploy_preview` after its `if` condition so skipped runs cannot replace cleanup.
    10. Evidence

      Real packaged Linux x64 desktop apps under Xvfb, 1920×1080 display, 1100×780 app, light theme, fresh isolated state. Both downloaded the same 214476155-byte packaged update through the real desktop updater.

      Steps: place t3code.AppImage on a separate destination filesystem; download the update; leave only 8 MiB free on the destination; invoke install/restart; inspect the executable and cached download; close and reopen the installed executable.

      BeforeAfter
      c82e1ba5159154000891
      Before: partial AppImage cannot reopenAfter: original AppImage preserved and reopened
      Replacement truncated to 8388608 bytes; reopening failed. Complete cached download remained.Original 214480274-byte executable preserved byte-for-byte; complete cached download remained; reopening succeeded.
      Before recordingAfter recording

      Adequate-space control: repeat the same download/install action without filling the destination. Both installed the complete payload with matching SHA-512, preserved t3code.AppImage, and automatically relaunched. Observed launch flags: APPIMAGE_SILENT_INSTALL=true; exit-after-install flag absent.

      Before: adequate spaceAfter: adequate space
      c82e1ba5159154000891
      Before: successful installation and relaunchAfter: successful verified installation and relaunch
      Before recordingAfter recording

      Drivers, local feed, reproduction instructions, and runtime observations. Screenshots and recording frames were inspected before upload. Disposable processes, mount, state, and checkouts were removed.

      AI-assisted; verified with the tests and tools listed above.

      Not shown:

      • The original unexplained zero-byte incident was not reproduced; the demonstrated failure is a real ENOSPC cross-filesystem partial replacement.
      • Independent checksum corruption, versioned filename advancement, same-filesystem rename behavior, and the non-forced installation flag path were not exercised; this proof covers the specified custom filename and cross-filesystem install/restart flow.
    11. Evidence

      Ran the real packaged Linux x64 desktop on both commits with fresh isolated state, light theme, identical layout, and the same fully built update payload. All captures use Xvfb and a 1920×840 recording region. The black rectangle redacts an unrelated local CLI path.

      Steps: launch t3code.AppImage, select Stable, download 0.1.10 completely, leave exactly 8 MiB free on its filesystem (separate from the cache), invoke install/restart, inspect the executable and cache, then close and reopen the installed filename. Repeat with 600 MiB free to verify installation and automatic relaunch.

      BeforeAfter
      31eea883c75cf4f63505
      8 MiB free: executable truncated to 8,388,608 bytes. Before: truncated executable8 MiB free: original SHA-512 and complete cached download preserved. After: original and cache preserved
      Reopening fails, exit 127. Before: AppImage cannot reopenOriginal reopens as 0.1.9. After: original reopens
      Before low-space recordingAfter low-space recording
      600 MiB free: full payload installed and 0.1.10 automatically relaunched. Before: adequate-space control600 MiB free: full payload installed and 0.1.10 automatically relaunched. After: adequate-space control
      Before adequate-space recordingAfter adequate-space recording

      Driver · Build and reproduction instructions · Sanitized runtime transcript

      AI-assisted; verified with the tests and tools listed above.

      Not shown:

      • Rejection of deliberately corrupted or wrong-size cached downloads was not exercised; the prescribed reproduction used a valid release payload.
      • Same-filesystem installation, versioned filenames, alias paths, and interruption or power-loss atomicity were outside this reproduction.
    12. The automated pipeline stopped on this pull request and will not merge it:

      not finished after 6 rounds

      It stays open for a person to finish or close.

Sign in to join this conversation.