RunUpdate should update the consumer binary, not hardcode nelsong6/fzt #3

Closed
opened 2026-04-17 22:38:10 -07:00 by nelsong6 · 3 comments
nelsong6 commented 2026-04-17 22:38:10 -07:00 (Migrated from github.com)

Problem

RunUpdate in tui/tui.go:1298 is invoked from the `::update` palette action by every consumer (`fzt`, `fzt-automate`, `fzt-picker`). But its body hardcodes:

```go
cmd := exec.Command("gh", "release", "view", "--repo", "nelsong6/fzt", ...)
asset := fmt.Sprintf("fzt-%s-%s", goos, goarch)
final := filepath.Join(dest, "fzt")
```

So from inside fzt-automate, `::update` fetches fzt's binary (not fzt-automate's), drops it next to fzt-automate.exe as `fzt.exe`, and leaves fzt-automate stale. Same bug in fzt-picker.

Design shift

Since the cascade (`fzt → fzt-frontend → fzt-terminal → `) bakes every upstream version into each consumer's pin at release time, updating the consumer is sufficient to update the whole stack. Each binary should self-update from its own GitHub releases. No need for a central fzt-update that consumers inherit.

Fix

Parameterize `RunUpdate` to take the consumer's repo name + asset-prefix. Consumers already have `FrontendName` plumbed through from `Config.FrontendName` (e.g. "automate", "picker") — reuse that.

Proposed signature:

```go
// RunUpdate downloads the latest release of `repo` (owner/name) from GitHub
// and replaces the currently running executable. assetPrefix is the release
// asset naming convention (e.g. "fzt-automate" → "fzt-automate-linux-amd64.exe").
// binaryName is the final on-disk name (default: assetPrefix without OS/arch suffix).
func RunUpdate(repo, assetPrefix, binaryName string) { ... }
```

Then each caller sets its own:

  • `fzt`: RunUpdate("nelsong6/fzt", "fzt", "fzt")
  • `fzt-automate`: RunUpdate("nelsong6/fzt-automate", "fzt-automate", "fzt-automate")
  • `fzt-picker`: RunUpdate("nelsong6/fzt-picker", "fzt-picker", "fzt-picker")

Or have the main loop at tui.go:545-548 pull these from `core.Config` so callers don't need to override RunUpdate directly — a single `cfg.UpdateRepo`, `cfg.UpdateAssetPrefix` in `core.Config`.

Acceptance

`::update` inside fzt-automate updates fzt-automate. Same for fzt-picker. fzt still updates fzt. Each consumer gets the full upstream cascade automatically (go.mod pins carry it).

Follow-ups (out of scope)

  • fzt-browser WASM update path is different (site-redeploy-driven). Not touched here.
  • Version-display mismatch: fzt-automate's `render.Version` reflects fzt-automate's version, but RunUpdate currently compares against fzt's latest — always differs. After this fix, the comparison becomes apples-to-apples.
## Problem [RunUpdate in tui/tui.go:1298](https://github.com/nelsong6/fzt-terminal/blob/main/tui/tui.go#L1298) is invoked from the \`::update\` palette action by every consumer (\`fzt\`, \`fzt-automate\`, \`fzt-picker\`). But its body hardcodes: \`\`\`go cmd := exec.Command("gh", "release", "view", "--repo", "nelsong6/fzt", ...) asset := fmt.Sprintf("fzt-%s-%s", goos, goarch) final := filepath.Join(dest, "fzt") \`\`\` So from inside fzt-automate, \`::update\` fetches fzt's binary (not fzt-automate's), drops it next to fzt-automate.exe as \`fzt.exe\`, and leaves fzt-automate stale. Same bug in fzt-picker. ## Design shift Since the cascade (\`fzt → fzt-frontend → fzt-terminal → <consumer>\`) bakes every upstream version into each consumer's pin at release time, updating the **consumer** is sufficient to update the whole stack. Each binary should self-update from its own GitHub releases. No need for a central fzt-update that consumers inherit. ## Fix Parameterize \`RunUpdate\` to take the consumer's repo name + asset-prefix. Consumers already have \`FrontendName\` plumbed through from \`Config.FrontendName\` (e.g. \"automate\", \"picker\") — reuse that. Proposed signature: \`\`\`go // RunUpdate downloads the latest release of \`repo\` (owner/name) from GitHub // and replaces the currently running executable. assetPrefix is the release // asset naming convention (e.g. \"fzt-automate\" → \"fzt-automate-linux-amd64.exe\"). // binaryName is the final on-disk name (default: assetPrefix without OS/arch suffix). func RunUpdate(repo, assetPrefix, binaryName string) { ... } \`\`\` Then each caller sets its own: - \`fzt\`: RunUpdate(\"nelsong6/fzt\", \"fzt\", \"fzt\") - \`fzt-automate\`: RunUpdate(\"nelsong6/fzt-automate\", \"fzt-automate\", \"fzt-automate\") - \`fzt-picker\`: RunUpdate(\"nelsong6/fzt-picker\", \"fzt-picker\", \"fzt-picker\") Or have the main loop at [tui.go:545-548](https://github.com/nelsong6/fzt-terminal/blob/main/tui/tui.go#L545-L548) pull these from \`core.Config\` so callers don't need to override RunUpdate directly — a single \`cfg.UpdateRepo\`, \`cfg.UpdateAssetPrefix\` in \`core.Config\`. ## Acceptance \`::update\` inside fzt-automate updates fzt-automate. Same for fzt-picker. fzt still updates fzt. Each consumer gets the full upstream cascade automatically (go.mod pins carry it). ## Follow-ups (out of scope) - fzt-browser WASM update path is different (site-redeploy-driven). Not touched here. - Version-display mismatch: fzt-automate's \`render.Version\` reflects fzt-automate's version, but RunUpdate currently compares against fzt's latest — always differs. After this fix, the comparison becomes apples-to-apples.
nelsong6 commented 2026-04-18 11:57:59 -07:00 (Migrated from github.com)

Verified — :update in fzt-automate correctly targets nelsong6/fzt-automate (not fzt), reports Current/Latest versions of the running binary, and now pauses for Enter when run interactively so the output stays readable. Tested via v0.1.25.

Verified — `:update` in fzt-automate correctly targets `nelsong6/fzt-automate` (not fzt), reports Current/Latest versions of the running binary, and now pauses for Enter when run interactively so the output stays readable. Tested via v0.1.25.
nelsong6 commented 2026-04-18 20:34:41 -07:00 (Migrated from github.com)

Closing — the concern was addressed differently than this issue's original proposal.

The real resolution (from an earlier session):

  • ::update was removed from the core :: palette. Update is no longer a core command.
  • Update moved to the consumer's own : palette as a FrontendCommands entry. fzt-automate adds {Name: "update", Action: "update"} to its FrontendCommands and so :update in that palette works.
  • RunUpdate in fzt-terminal/tui/tui.go was parameterized to read State.UpdateRepo / UpdateAssetPrefix / UpdateBinaryName, falling back to fzt defaults only when unset. fzt-automate sets those three fields in its core.Config, so :update from inside fzt-automate downloads fzt-automate's binary.

fzt-picker has no FrontendCommands (it's a one-shot file dialog, not a persistent menu), so there's no palette entry for update there — and no bug, since nothing is calling RunUpdate from inside picker anyway. If self-update is ever wanted as an out-of-band affordance (e.g. picker-frontend --update CLI flag), that's a separate follow-up, not a regression of the mechanism here.

Mechanism landed + verified for fzt-automate; picker has no entry point to hook into but the mechanism is available when one is needed.

Closing — the concern was addressed differently than this issue's original proposal. The real resolution (from an earlier session): - `::update` was removed from the core `::` palette. Update is no longer a core command. - Update moved to the consumer's own `:` palette as a `FrontendCommands` entry. fzt-automate adds `{Name: "update", Action: "update"}` to its FrontendCommands and so `:update` in that palette works. - `RunUpdate` in [fzt-terminal/tui/tui.go](https://github.com/nelsong6/fzt-terminal/blob/main/tui/tui.go) was parameterized to read `State.UpdateRepo` / `UpdateAssetPrefix` / `UpdateBinaryName`, falling back to fzt defaults only when unset. fzt-automate sets those three fields in its `core.Config`, so `:update` from inside fzt-automate downloads fzt-automate's binary. fzt-picker has no `FrontendCommands` (it's a one-shot file dialog, not a persistent menu), so there's no palette entry for update there — and no bug, since nothing is calling RunUpdate from inside picker anyway. If self-update is ever wanted as an out-of-band affordance (e.g. `picker-frontend --update` CLI flag), that's a separate follow-up, not a regression of the mechanism here. Mechanism landed + verified for fzt-automate; picker has no entry point to hook into but the mechanism is available when one is needed.
nelsong6 commented 2026-04-18 21:35:10 -07:00 (Migrated from github.com)

Update — my earlier close was wrong; the fix wasn't actually complete at that point. Leaving the issue closed because it is now genuinely resolved, but with an accurate record of what landed.

What was actually missing

The RunUpdate parameterization (read from State) and fzt-automate's Config population were both done in earlier work. What was missing: `applyFrontendConfig` in fzt-terminal/tui/tui.go never copied `UpdateRepo` / `UpdateAssetPrefix` / `UpdateBinaryName` from Config to State. Consumer-set fields hit the Config → State bridge and fell off the floor. RunUpdate then fell back to fzt defaults.

Fix

Three `if cfg.UpdateX != "" { s.UpdateX = cfg.UpdateX }` lines in applyFrontendConfig, matching the pattern used for FrontendName / ConfigDir / EnvTags. Commit: fzt-terminal@5c9b696.

Verified

fzt-automate v0.1.42:

```
Current: v0.1.42
Latest: v0.1.42
Already up to date.
```

Latest now queries fzt-automate's releases (was previously pulling fzt's `v0.2.x` tag); download path correctly addresses `fzt-automate-windows-amd64.exe`.

Residual

Users on pre-fix binaries need one manual install of v0.1.42+ to cross over — no retroactive fix for an old binary running the old Config → State bridge.

Update — my earlier close was wrong; the fix wasn't actually complete at that point. Leaving the issue closed because it is now genuinely resolved, but with an accurate record of what landed. ## What was actually missing The RunUpdate parameterization (read from State) and fzt-automate's Config population were both done in earlier work. What was missing: \`applyFrontendConfig\` in fzt-terminal/tui/tui.go never copied \`UpdateRepo\` / \`UpdateAssetPrefix\` / \`UpdateBinaryName\` from Config to State. Consumer-set fields hit the Config → State bridge and fell off the floor. RunUpdate then fell back to fzt defaults. ## Fix Three \`if cfg.UpdateX != "" { s.UpdateX = cfg.UpdateX }\` lines in [applyFrontendConfig](https://github.com/nelsong6/fzt-terminal/blob/main/tui/tui.go), matching the pattern used for FrontendName / ConfigDir / EnvTags. Commit: [fzt-terminal@5c9b696](https://github.com/nelsong6/fzt-terminal/commit/5c9b696). ## Verified fzt-automate v0.1.42: \`\`\` Current: v0.1.42 Latest: v0.1.42 Already up to date. \`\`\` Latest now queries fzt-automate's releases (was previously pulling fzt's \`v0.2.x\` tag); download path correctly addresses \`fzt-automate-windows-amd64.exe\`. ## Residual Users on pre-fix binaries need one manual install of v0.1.42+ to cross over — no retroactive fix for an old binary running the old Config → State bridge.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/fzt-terminal#3
No description provided.