RunUpdate should update the consumer binary, not hardcode nelsong6/fzt #3
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-verification
question
queue
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
romaine-life/fzt-terminal#3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
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)
Verified —
:updatein fzt-automate correctly targetsnelsong6/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.Closing — the concern was addressed differently than this issue's original proposal.
The real resolution (from an earlier session):
::updatewas removed from the core::palette. Update is no longer a core command.:palette as aFrontendCommandsentry. fzt-automate adds{Name: "update", Action: "update"}to its FrontendCommands and so:updatein that palette works.RunUpdatein fzt-terminal/tui/tui.go was parameterized to readState.UpdateRepo/UpdateAssetPrefix/UpdateBinaryName, falling back to fzt defaults only when unset. fzt-automate sets those three fields in itscore.Config, so:updatefrom 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 --updateCLI 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.
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.