Skip to content

Commit b0ad5e1

Browse files
fix(workspace): /integrations upgrades an offer still waiting for the store
An automatic offer waiting for the kv store to hydrate holds the slot, so the request found it taken, and the waiting offer was then suppressed by "Not now": nothing showed. The request now marks the pending offer as asked for, and it skips the latch. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HRUhVhg6XwxSKJs1iTufiA
1 parent 4c639dd commit b0ad5e1

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎packages/opencode/src/plugin/tui/altimate/workspace.tsx‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,12 @@ let engineOfferVisible = false
19861986
/** Identifies which raise owns the latch, so a superseded dialog's teardown
19871987
* cannot free a slot that a newer dialog is still holding. */
19881988
let engineOfferGeneration = 0
1989+
/** Set when `/integrations` asks while a raise holds the slot but has not
1990+
* shown its dialog yet (it may be waiting for the store to hydrate). That raise
1991+
* then skips the "Not now" latch, as the request would have; otherwise the
1992+
* request would find the slot taken and the raise would be latched, and the
1993+
* user would get nothing. */
1994+
let engineOfferRequested = false
19891995
/** Held for the lifetime of an `npm i -g`, independently of the dialog.
19901996
*
19911997
* The install outlives the dialog that started it: dismissing mid-install
@@ -2031,7 +2037,10 @@ async function showEngineInstallOffer(api: TuiPluginApi, opts: { onDemand?: bool
20312037
})
20322038
return
20332039
}
2034-
if (engineOfferVisible) return
2040+
if (engineOfferVisible) {
2041+
if (opts.onDemand) engineOfferRequested = true
2042+
return
2043+
}
20352044
if (engineInstallInFlight) {
20362045
// An install started from an earlier dialog is still running; offering
20372046
// again would invite a second concurrent global install.
@@ -2040,6 +2049,7 @@ async function showEngineInstallOffer(api: TuiPluginApi, opts: { onDemand?: bool
20402049
return
20412050
}
20422051
engineOfferVisible = true
2052+
engineOfferRequested = false
20432053
const generation = ++engineOfferGeneration
20442054
const release = () => {
20452055
// Only the current owner may free the slot.
@@ -2069,7 +2079,7 @@ async function showEngineInstallOffer(api: TuiPluginApi, opts: { onDemand?: bool
20692079
// engine appeared, or the project is no longer bound. Say nothing.
20702080
if (!offer) return release()
20712081
const latchScope = await currentLatchScope()
2072-
if (!opts.onDemand && isEngineSkipActive(api, offer.workspaceId, latchScope, Date.now())) {
2082+
if (!opts.onDemand && !engineOfferRequested && isEngineSkipActive(api, offer.workspaceId, latchScope, Date.now())) {
20732083
log.info("engine install offer suppressed by 7-day latch", { workspaceId: offer.workspaceId })
20742084
return release()
20752085
}
@@ -2737,6 +2747,7 @@ export const engineOfferInternals = {
27372747
reset() {
27382748
engineOfferVisible = false
27392749
engineInstallInFlight = false
2750+
engineOfferRequested = false
27402751
},
27412752
}
27422753

‎packages/opencode/test/altimate/plugin/workspace.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,23 @@ describe("/integrations", () => {
11421142
expect(read).not.toHaveBeenCalled()
11431143
})
11441144

1145+
test("asked while an automatic offer waits for the store, the offer still shows after Not now", async () => {
1146+
linked(binding)
1147+
engine(null)
1148+
statusRead()
1149+
const { tui, h } = harness(false)
1150+
let ready = false
1151+
Object.defineProperty(tui.kv, "ready", { get: () => ready })
1152+
recordEngineSkip(tui, "42", { tenant: "acme", apiUrl: "https://api.acme.example.com" }, Date.now())
1153+
// The turn's raise holds the slot while the store hydrates; the request finds it taken.
1154+
const automatic = showEngineInstallOffer(tui)
1155+
await runIntegrations(tui, os.tmpdir())
1156+
expect(h.replaced).toBe(0)
1157+
ready = true
1158+
await automatic
1159+
expect(h.replaced).toBe(1)
1160+
})
1161+
11451162
test("an install still running is reported, not offered again", async () => {
11461163
linked(binding)
11471164
engine(null)

0 commit comments

Comments
 (0)