fix(autocomplete): strip lastAccepted boundary from exported workflows (#1093)

The hidden __lm_autocomplete_meta_* widget persisted lastAccepted
(insertedText/textSnapshot) into exported workflow JSON, leaking old
prompt text even after the user deleted it.

Patch app.graphToPrompt (shared by workflow export, Export API and
queueing) to strip lastAccepted from the serialized result's
widgets_values / widgets_values_named / output inputs. Only the
exported artifact is touched; live node state, undo snapshots,
copy/paste and local saves keep the boundary intact.
This commit is contained in:
Will Miao
2026-09-03 08:29:55 +08:00
parent 7c4c8b8f30
commit da71985c3e
5 changed files with 435 additions and 1 deletions
+17
View File
@@ -45,6 +45,23 @@ import { app } from '../../../scripts/app.js'
import { api } from '../../../scripts/api.js'
// @ts-ignore
import { getPoolConfigFromConnectedNode, getActiveLorasFromNode, updateConnectedTriggerWords, updateDownstreamLoaders } from '../../web/comfyui/utils.js'
// @ts-ignore
import { stripAutocompleteMetadataFromPromptResult } from '../../web/comfyui/autocomplete.js'
// Strip the autocomplete lastAccepted boundary from exported workflows.
// lastAccepted carries old prompt text (insertedText/textSnapshot) and is
// session-only state; it must not leak into exported JSON (#1093).
// graphToPrompt is shared by workflow export, Export API and queueing.
// Local saves go through the change-tracker snapshot (no graphToPrompt) and
// are intentionally left untouched so cross-session caret continuity is kept.
// Post-processing the resolved result avoids any window/race with
// change-tracker or copy/paste serialization of live state.
const originalGraphToPrompt = app.graphToPrompt.bind(app)
app.graphToPrompt = async (...args: unknown[]) => {
const result = await originalGraphToPrompt(...args)
stripAutocompleteMetadataFromPromptResult(result)
return result
}
function forwardMiddleMouseToCanvas(container: HTMLElement) {
if (!container) return