Skip to content

Commit fc71d7f

Browse files
paulr34cursoragent
andcommitted
cleanup
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent c19e349 commit fc71d7f

2 files changed

Lines changed: 16 additions & 80 deletions

File tree

src/store/zap/actions.js

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -292,39 +292,22 @@ export function updateSelectedEvents(context, selectionContext) {
292292
export function updateSelectedComponent(context, payload) {
293293
let op = payload.added ? restApi.uc.componentAdd : restApi.uc.componentRemove
294294
return axiosRequests.$serverPost(op, payload).then((response) => {
295-
// ZAP owns the install/remove decision locally. Studio's follow-up "tree"
296-
// WS messages can spuriously mark just-installed components as
297-
// isSelected:false during settle, which used to make the missing-component
298-
// warning flicker back. We trust two things:
299-
// 1. The component ids Studio returned 2xx (or its "fake-ok" 4xx with
300-
// componentAdded/componentRemoved) for, mirrored into
301-
// selectedUcComponents.
302-
// 2. The cluster id we just acted on -- recorded here directly so the
303-
// missing-component check can short-circuit regardless of any
304-
// id-format mismatches between POST responses and Studio's tree.
295+
// Record the cluster as install-requested so the missing-component warning
296+
// gate short-circuits regardless of any contradictory Studio WS updates.
305297
const list = Array.isArray(response?.data) ? response.data : []
306-
const successIds = list
307-
.filter((r) => {
308-
const s = Number(r?.status)
309-
const ok = s >= 200 && s < 300
310-
const fakeOk =
311-
(payload.added === true && r?.data?.componentAdded === true) ||
312-
(payload.added !== true && r?.data?.componentRemoved === true)
313-
return ok || fakeOk
314-
})
315-
.map((r) => r?.id)
316-
.filter((id) => id != null && String(id).length > 0)
317-
if (successIds.length) {
318-
context.commit('locallyMarkUcComponents', {
319-
added: payload.added === true,
320-
ids: successIds
298+
const anySuccess = list.some((r) => {
299+
const s = Number(r?.status)
300+
return (
301+
(s >= 200 && s < 300) ||
302+
(payload.added && r?.data?.componentAdded === true) ||
303+
(!payload.added && r?.data?.componentRemoved === true)
304+
)
305+
})
306+
if (anySuccess && payload?.clusterId != null) {
307+
context.commit('markClusterInstallRequested', {
308+
clusterId: payload.clusterId,
309+
added: payload.added === true
321310
})
322-
if (payload?.clusterId != null) {
323-
context.commit('markClusterInstallRequested', {
324-
clusterId: payload.clusterId,
325-
added: payload.added === true
326-
})
327-
}
328311
}
329312
return response
330313
})

src/store/zap/mutations.js

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,9 +1000,8 @@ export function updateSelectedUcComponentState(state, data) {
10001000
* - leaves with isSelected:false -> ignored (Studio cannot remove)
10011001
* - leaves not mentioned at all -> left alone (no wipe)
10021002
*
1003-
* Removals happen only via locallyMarkUcComponents when ZAP itself issues a
1004-
* remove POST and Studio responds 2xx. ucComponents (the catalog used for
1005-
* labels / metadata) is always merged so we keep accumulating entries.
1003+
* ucComponents (the catalog used for labels / metadata) is always merged so
1004+
* we keep accumulating entries.
10061005
*
10071006
* @param {*} state
10081007
* @param {any[]} treeLeaves Flattened list of leaf nodes from Studio's tree.
@@ -1037,52 +1036,6 @@ export function applyUcComponentUpdate(state, treeLeaves) {
10371036
vue3Set(state.studio, 'ucComponents', [...allById.values()])
10381037
}
10391038

1040-
/**
1041-
* Apply the result of a locally-issued component install/uninstall POST.
1042-
*
1043-
* ZAP is the local source of truth for what it has asked Studio to install or
1044-
* remove. A 2xx response from the POST means Studio acknowledged the change,
1045-
* so we mirror that result into selectedUcComponents immediately. Any later
1046-
* Studio WebSocket tree that contradicts this (see applyUcComponentUpdate)
1047-
* is ignored for the unselect direction.
1048-
*
1049-
* @param {*} state
1050-
* @param {{ ids: string[], added: boolean }} payload
1051-
*/
1052-
export function applyLocalUcComponentChange(state, payload) {
1053-
if (!payload || !Array.isArray(payload.ids) || payload.ids.length === 0)
1054-
return
1055-
const added = payload.added === true
1056-
const prevSelected = Array.isArray(state.studio.selectedUcComponents)
1057-
? state.studio.selectedUcComponents
1058-
: []
1059-
const selectedById = new Map(
1060-
prevSelected.filter((x) => x && x.id != null).map((x) => [String(x.id), x])
1061-
)
1062-
for (const rawId of payload.ids) {
1063-
if (rawId == null) continue
1064-
const key = String(rawId)
1065-
if (added) {
1066-
if (!selectedById.has(key)) {
1067-
selectedById.set(key, { id: key, isSelected: true })
1068-
}
1069-
} else {
1070-
selectedById.delete(key)
1071-
}
1072-
}
1073-
vue3Set(state.studio, 'selectedUcComponents', [...selectedById.values()])
1074-
}
1075-
1076-
/**
1077-
* Backward-compat alias for the action's commit name. Kept thin so call sites
1078-
* can use either name interchangeably.
1079-
* @param {*} state
1080-
* @param {*} payload
1081-
*/
1082-
export function locallyMarkUcComponents(state, payload) {
1083-
applyLocalUcComponentChange(state, payload)
1084-
}
1085-
10861039
/**
10871040
* Track which cluster ids ZAP has successfully asked Studio to install (or
10881041
* uninstall) components for. The missing-component warning is gated by this

0 commit comments

Comments
 (0)