Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

chore(canvas): prune narrative comments to terse constraints

Josh Corbett21addcbdbcc0
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/extractMaskedAreaController.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/extractMaskedAreaController.ts
index 75fabc68cb..50b8555f2a 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/extractMaskedAreaController.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/extractMaskedAreaController.ts
@@ -64,11 +64,7 @@ export interface ExtractMaskedAreaControllerOptions {
) => void;
}
-/**
- * The raster forest reduced to `keep` leaves with the GROUP topology intact:
- * an adjusted group's stack must apply to the extracted composite exactly as
- * it applies on screen, so groups cannot be flattened away here.
- */
+/** The raster forest reduced to `keep` leaves, groups intact so their stacks still apply. */
const filterRasterForest = (nodes: readonly CanvasNodeContract[], keep: ReadonlySet<string>): CanvasNodeContract[] =>
nodes.flatMap((node): CanvasNodeContract[] => {
if (isGroupNode(node)) {
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/mergeLayerController.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/mergeLayerController.ts
index 265d6e5058..b0084d3d94 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/mergeLayerController.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/mergeLayerController.ts
@@ -207,10 +207,8 @@ export class MergeLayerController {
) {
return 'not-ready';
}
- // Leaf identity alone misses two mid-await edits this feature introduces:
- // an ancestor group's STACK changing (leaf objects untouched), and a
- // re-parent in/out of an adjusted group that keeps the flat order. The
- // scope plan folds both, so compare it against the pre-export plan.
+ // Leaf identity misses a mid-await ancestor-stack edit or an order-preserving
+ // re-parent; the scope plan folds both.
const scopes = planGroupAdjustmentScopes(contributorLeaves, collectAdjustedGroups(document));
const liveScopes = planGroupAdjustmentScopes(liveLeaves, collectAdjustedGroups(liveDocument));
if (JSON.stringify(liveScopes) !== JSON.stringify(scopes)) {
@@ -230,10 +228,8 @@ export class MergeLayerController {
const context = pixels.ctx;
context.setTransform(1, 0, 0, 1, 0, 0);
context.clearRect(0, 0, rect.width, rect.height);
- // Contributors inside an adjusted group composite through an isolated
- // buffer with the group's stack applied, exactly as the screen draws
- // them — merged pixels must reproduce the screen, and a per-leaf bake
- // cannot under member opacity/blending.
+ // Merged pixels must reproduce the screen; a per-leaf bake cannot under
+ // member opacity/blending.
const drawMerged = (
target: RasterSurface['ctx'],
from: number,
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/psdExportController.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/psdExportController.ts
index 61d66d3625..6b380db2ac 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/psdExportController.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/psdExportController.ts
@@ -93,12 +93,9 @@ export class PsdExportController {
// The raster tree as it stands, minus leaves with nothing captured; the planner derives
// effective visibility from the own flags, the same way Photoshop will.
let missing: string | null = null;
- // PSD has no representation for a GROUP's adjustment stack, so each
- // enclosing stack is baked into every descendant leaf (own stack
- // first, then innermost ancestor outward). Exact for opaque
- // source-over members; under member opacity/blending it is the
- // accepted approximation — and the merged preview flattens the same
- // baked pixels, so the file stays self-consistent.
+ // PSD cannot represent a group stack: bake enclosing stacks into each
+ // leaf (own first, then innermost outward). Approximate under member
+ // opacity/blending; the merged preview flattens the same baked pixels.
const toInputs = (
nodes: readonly CanvasNodeContract[],
ancestorStacks: readonly CanvasAdjustmentsContract[] = []
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.ts
index e7b734e147..2fcc784845 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/document-model/documentModel.ts
@@ -1187,11 +1187,7 @@ export const createDocumentModel = (
return { entry, layer: entry.node };
};
- /**
- * The unlocked node a config patch may target: leaves through their own
- * arms, and RASTER-stack groups through the 'group' arm (an overlay group
- * composites coverage, not color — its adjustments patch is refused).
- */
+ /** The unlocked config-patch target: a leaf, or a RASTER-stack group through the 'group' arm. */
const editableConfigNode = (
id: string,
layerType: CanvasLayerConfigPatch['layerType']
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/document/documentMirror.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/document/documentMirror.ts
index 7b2965e178..fa512ab041 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/document/documentMirror.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/document/documentMirror.ts
@@ -27,11 +27,9 @@ export interface DocumentMirrorCallbacks {
*/
onLayersChanged(changed: string[], sourceChanged: string[]): void;
/**
- * Leaves whose rendered contribution changed ONLY because an ancestor
- * group's adjustment stack did: their pixels, sources, and effective flags
- * are untouched, so the engine must recomposite them but must NOT run the
- * destructive reactions `onLayersChanged` carries (float and pixel-edit
- * cancellation). Optional so minimal harnesses need not care.
+ * Leaves changed ONLY by an ancestor group's adjustment stack: recomposite
+ * without `onLayersChanged`'s destructive reactions (float and pixel-edit
+ * cancellation).
*/
onLayersRecomposite?(ids: string[]): void;
/** The forests were restructured without any leaf changing: recomposite with the new order. */
@@ -97,8 +95,7 @@ const diffForests = (prev: CanvasDocumentIndex, next: CanvasDocumentIndex): Fore
const changed = new Set<string>();
const sourceChanged = new Set<string>();
const recompositeOnly = new Set<string>();
- // A group whose adjustment stack changed re-renders every leaf beneath it.
- // `next.nodes` is preorder, so these ids are collected before their leaves.
+ // Preorder: a changed group's id is collected before its leaves are visited.
const adjustedGroups = new Set<string>();
let restructured = false;
for (const entry of next.nodes) {
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts
index 92ed69bff4..4dc482fd4e 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts
@@ -531,9 +531,8 @@ export const createCanvasEngine = (opts: CanvasEngineOptions): CanvasEngineCoreC
return rasterController.getAdjustedSurface(layer, entry);
};
- // Memoized document-space composites of adjusted GROUPS. Members draw
- // through the guarded `getAdjustedSurface` above, so a member's own stack
- // (and the pixel-edit double-apply guard) behave identically inside a group.
+ // Members draw through the guarded `getAdjustedSurface`, so the pixel-edit
+ // double-apply guard holds inside groups too.
const groupSurfaces = createGroupSurfaceCache({
createSurface: (width, height) => backend.createSurface(width, height),
getAdjustedSurface: (layer, entry) => getAdjustedSurface(layer, entry),
@@ -550,8 +549,6 @@ export const createCanvasEngine = (opts: CanvasEngineOptions): CanvasEngineCoreC
*/
const syncMemoryBaselines = (): void => {
rasterController.memory.setBaseBytes(layerCache.byteSize());
- // Group surfaces are derived pixels too: they must count against the same
- // budget or an adjusted group's doc-space composite is invisible memory.
rasterController.memory.setDerivedBytes(derivedSurfaceCache.byteSize() + groupSurfaces.byteSize());
};
@@ -1027,16 +1024,10 @@ export const createCanvasEngine = (opts: CanvasEngineOptions): CanvasEngineCoreC
}
/**
- * A one-shot color sample requested from outside the canvas — the color
- * picker's eyedropper button. While one is pending, the color-picker tool
- * hands its samples here instead of writing the brush color: press and drag
- * stash the latest color (`sampledHex`), and the release settles the promise
- * and restores the tool that was active beforehand. Settling on release, not
- * press, matters — the pointer gesture is already over, so a caller that
- * commits the sample through the document transaction seam is not refused as
- * `gesture-active`. Cancelled (resolving `null`) by Escape, by any other tool
- * switch, and by teardown, so the promise the caller is awaiting can never
- * dangle.
+ * A one-shot sample claim from a picker's eyedropper button. Press/drag
+ * stash `sampledHex`; the RELEASE settles (the gesture is over, so the
+ * caller may commit structurally). Escape, tool switch, and teardown settle
+ * `null`, so the awaited promise never dangles.
*/
let pendingColorSample: {
previousToolId: ToolId;
@@ -1586,14 +1577,11 @@ export const createCanvasEngine = (opts: CanvasEngineOptions): CanvasEngineCoreC
scheduler.invalidate({ all: true });
},
onLayersRecomposite: (ids) => {
- // An ancestor group's stack changed: leaf pixels and caches are intact,
- // and the group surface rebuilds itself off its key. Only recomposite.
scheduler.invalidate({ layers: ids });
},
onLayersChanged: (ids, sourceChangedIds) => {
const cleanup = createCleanupAccumulator();
- // A removal that deletes a group together with its leaves reports leaf
- // ids here (not onLayerOrderChanged), so the group cache prunes on both.
+ // A group deleted with its leaves reports here, not onLayerOrderChanged.
{
const doc = mirror.getDocument();
cleanup.run(() => groupSurfaces.prune(doc ? new Set(getDocumentIndex(doc).byId.keys()) : new Set()));
@@ -1865,12 +1853,9 @@ export const createCanvasEngine = (opts: CanvasEngineOptions): CanvasEngineCoreC
};
/**
- * Arms the eyedropper for one sample and resolves with the picked `#rrggbb`,
- * or `null` if the user cancels. Backs the color picker's eyedropper button,
- * which reads the composited document rather than the screen (and so works
- * outside Chromium, and sees through the window chrome). The promise settles
- * on pointer release, after the sampling gesture ends, so the caller may
- * commit the color through the document transaction seam synchronously.
+ * Arms the eyedropper for one sample; resolves `#rrggbb` on pointer release
+ * (after the gesture, so the caller may commit structurally) or `null` on
+ * cancel. Reads the composited document, not the screen.
*/
const requestColorSample = (): Promise<string | null> => {
// A second request supersedes the first; the earlier caller gets a cancel.
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/colorSample.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/colorSample.ts
index 1f37589ac9..a247971c8c 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/colorSample.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/colorSample.ts
@@ -54,9 +54,6 @@ export const sampleDocumentColor = (
// Reuse the canonical compositor so sampling shares its layer ordering,
// cache-origin placement, transforms, blend modes, and display effects.
// Omitting a checkerboard tile and staged preview keeps empty space transparent.
- // The providers make the sample WYSIWYG: layer and group adjustment stacks
- // apply exactly as the screen draws them. Absent (minimal harnesses), the
- // sample reads raw cached pixels.
compositeDocument(scratch, doc, layers, view, { backend, ...providers });
const { data } = scratch.ctx.getImageData(0, 0, 1, 1);
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.ts
index fa7750aacf..b785525ae4 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/compositor.ts
@@ -192,13 +192,9 @@ export interface CompositeOptions {
/** Optional deterministic render counters; omitted in the normal zero-overhead path. */
diagnostics?: CanvasDiagnostics | null;
/**
- * Returns an adjusted GROUP's document-space composite (its members drawn,
- * the group's stack applied), or `null` when the group currently has no
- * drawable content. The engine wires a memoizing {@link
- * import('./groupSurfaceCache').GroupSurfaceCache}. Members named in
- * `excludeIds` are left out of the composite so the caller can draw them
- * separately (pixel-edit skips, filter previews). Absent ⇒ group stacks are
- * ignored and members draw flat (a bare test call).
+ * An adjusted group's document-space composite (stack applied), `null` when
+ * it has no drawable content; `excludeIds` members are left out for the
+ * caller to draw separately. Absent ⇒ members draw flat.
*/
groupSurface?:
| ((
@@ -567,11 +563,7 @@ export const compositeDocument = (
isolationLayerId: opts.isolationLayerId ?? null,
showOverlayStacks: ALL_OVERLAY_STACKS_SHOWN,
});
- // Adjusted-group scopes: their members composite through an isolated,
- // stack-adjusted surface instead of drawing flat. Isolation mode inspects
- // raw members, so scopes are bypassed while it is active; without a
- // provider (bare test calls, color sampling in minimal harnesses) members
- // draw flat too.
+ // Isolation mode inspects raw members, so scopes are bypassed while active.
const scopes =
opts.groupSurface && !isIsolated(opts) ? planGroupAdjustmentScopes(plan.leaves, collectAdjustedGroups(doc)) : [];
let scopeIndex = 0;
@@ -605,10 +597,7 @@ export const compositeDocument = (
if (scope && index === scope.start) {
const members = plan.leaves.slice(scope.start, scope.end);
const matrices = members.map((member) => getEffectiveLayerMatrix(member, opts));
- // Members the caller draws through other channels are left out of the
- // composite: a pixel-edit skip target, and filter-preview targets (the
- // preview replaces the member's pixels and draws separately, without the
- // group stack — a transient divergence that ends with the operation).
+ // Skip targets and filter previews draw separately, without the group stack.
const excluded = new Set<string>();
for (const member of members) {
if (member.id === opts.skipLayerId || opts.layerPreviews?.has(member.id)) {
@@ -624,9 +613,7 @@ export const compositeDocument = (
ctx.drawImage(result.surface.canvas, result.rect.x, result.rect.y);
ctx.restore();
opts.diagnostics?.increment('layersDrawn');
- // Excluded members and in-flight floats still draw on top. A float
- // whose member IS in the composite draws alone — its member's pixels
- // are already in the group surface.
+ // A float whose member is in the composite draws alone.
for (const member of members) {
if (member.id === opts.skipLayerId) {
continue;
@@ -641,7 +628,6 @@ export const compositeDocument = (
scopeIndex += 1;
continue;
}
- // No drawable content (or no cache yet): fall through to flat drawing.
scopeIndex += 1;
}
const leaf = plan.leaves[index]!;
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentScopes.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentScopes.ts
index 8868e6a758..4f446c4962 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentScopes.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentScopes.ts
@@ -1,13 +1,7 @@
/**
- * Group adjustment scopes: which contiguous runs of a flat drawn-leaf list
- * must composite through an isolated buffer so a group's adjustment stack can
- * apply to the composite (not to each member). Both renderers — the screen
- * compositor and the export/generation raster composite — consume the same
- * scope shape, so their isolation semantics cannot drift.
- *
- * The planners rely on one structural fact: any list derived from the
- * document's preorder (or its reversal) keeps every subtree contiguous, so a
- * group's drawn members always form one run.
+ * Nested contiguous [start, end) scopes over a flat drawn list, one per
+ * adjusted group; both renderers consume the same shape. Relies on preorder
+ * (or its reversal) keeping every subtree contiguous.
*/
import type { CanvasAdjustmentsContract, CanvasDocumentContractV3 } from '@workbench/canvas-engine/contracts';
@@ -27,11 +21,7 @@ export interface GroupAdjustmentScope {
readonly children: readonly GroupAdjustmentScope[];
}
-/**
- * The raster-stack groups whose adjustment stacks contribute (enabled group,
- * non-identity stack). Disabled groups drop out of drawing entirely upstream;
- * an identity stack composites pass-through by definition.
- */
+/** The raster-stack groups whose stacks contribute (non-identity; disabled groups never draw). */
export const collectAdjustedGroups = (
document: CanvasDocumentContractV3
): ReadonlyMap<string, CanvasAdjustmentsContract> => {
@@ -56,11 +46,7 @@ interface OpenScope {
children: GroupAdjustmentScope[];
}
-/**
- * Plans the nested scopes covering `items` (a flat drawn list; each item
- * carries its ancestor chain outermost-first). Items outside every adjusted
- * group produce no scope. Returns outermost scopes in list order.
- */
+/** Plans nested scopes over `items` (ancestor chains outermost-first); outermost scopes in list order. */
export const planGroupAdjustmentScopes = (
items: readonly { readonly parentIds: readonly string[] }[],
adjusted: ReadonlyMap<string, CanvasAdjustmentsContract>
@@ -82,7 +68,6 @@ export const planGroupAdjustmentScopes = (
items.forEach((item, index) => {
const chain = item.parentIds.filter((id) => adjusted.has(id));
- // Keep the still-matching prefix of open scopes, close the rest, open the new tail.
let shared = 0;
while (shared < open.length && shared < chain.length && open[shared]!.id === chain[shared]) {
shared += 1;
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupSurfaceCache.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupSurfaceCache.ts
index bb1a1fc603..55569f36ff 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupSurfaceCache.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupSurfaceCache.ts
@@ -1,20 +1,9 @@
/**
- * Document-space composites of adjusted groups, memoized per group. The
- * screen compositor draws one cached surface per adjusted group instead of
- * the group's members, so pans and zooms cost one blit while member edits
- * rebuild only the owning group's surface.
- *
- * The cache key folds in everything the pixels depend on: the group's stack,
- * nested scopes, and every drawn member's cache version, appearance, and
- * effective matrix (transform overrides included — a transform session inside
- * an adjusted group rebuilds per tick, which is correct, just not free).
- *
- * Accepted fidelity tradeoff: the surface is document-resolution, so a
- * transformed member resamples twice (into doc space, then through the view),
- * and zoom > 100% upscales the group from doc resolution while flat layers
- * sample their caches in one pass. Buying per-frame LUT application on the
- * viewport back with per-edit memoization is the point; sharper zoomed-in
- * group rendering is a measured follow-up, not a default.
+ * Per-group memoized document-space composites of adjusted groups. Keyed on
+ * the scope shape plus every drawn member's cache version, appearance, and
+ * effective matrix (so a transform session inside an adjusted group rebuilds
+ * per tick). Accepted tradeoff: document resolution, so transformed members
+ * resample twice and zoom > 100% upscales the group surface.
*/
import type { CanvasRasterLayerContractV2 } from '@workbench/canvas-engine/contracts';
@@ -59,7 +48,6 @@ export interface GroupSurfaceCache {
const matKey = (m: Mat2d): string => `${m.a},${m.b},${m.c},${m.d},${m.e},${m.f}`;
-/** The stack surface budget: an adjusted group holds one doc-space surface. */
export const createGroupSurfaceCache = (deps: GroupSurfaceDeps): GroupSurfaceCache => {
const cache = new Map<string, { key: string; result: GroupSurfaceResult }>();
@@ -83,10 +71,7 @@ export const createGroupSurfaceCache = (deps: GroupSurfaceDeps): GroupSurfaceCac
return `${scopeShapeKey(scope)}|${memberKeys.join('|')}|x:${[...excludeIds].sort().join(',')}`;
};
- /**
- * Draws `[from, to)` (absolute plan indices; list order = bottom first) onto
- * `ctx`. `baseIndex` is the absolute index of `members[0]`.
- */
+ /** Draws `[from, to)` (absolute plan indices, bottom first); `baseIndex` = absolute index of `members[0]`. */
const drawRange = (
ctx: RasterSurface['ctx'],
view: Mat2d,
@@ -102,7 +87,6 @@ export const createGroupSurfaceCache = (deps: GroupSurfaceDeps): GroupSurfaceCac
for (let i = from; i < to;) {
const child = childIndex < children.length ? children[childIndex]! : null;
if (child && i >= child.start && i < child.end) {
- // Nested adjusted group: isolate it exactly like the parent.
const nested = build(child, members, memberMatrices, excludeIds, baseIndex);
if (nested) {
ctx.save();
@@ -144,7 +128,6 @@ export const createGroupSurfaceCache = (deps: GroupSurfaceDeps): GroupSurfaceCac
excludeIds: ReadonlySet<string>,
baseIndex: number
): GroupSurfaceResult | null => {
- // Document-space bounds of the drawn members.
let bounds: Rect | null = null;
for (let i = scope.start; i < scope.end; i += 1) {
const leaf = members[i - baseIndex]!;
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/rasterComposite.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/rasterComposite.ts
index 8e0a0ac64e..1dda71518a 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/rasterComposite.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/rasterComposite.ts
@@ -38,12 +38,7 @@ export interface CompositeLayerRef {
export interface CompositeEntry {
bbox: Rect;
layers: readonly CompositeLayerRef[];
- /**
- * Adjusted-group isolation scopes over `layers` (index ranges, top-first,
- * nested). A scope's members composite into an isolated buffer, the group's
- * stack applies to the buffer, and the buffer composites onward — the
- * pixels a pass-through walk cannot produce. Absent ⇒ fully pass-through.
- */
+ /** Adjusted-group isolation scopes over `layers` (top-first, nested). Absent ⇒ fully pass-through. */
groupScopes?: readonly GroupAdjustmentScope[];
}
@@ -250,12 +245,7 @@ export const renderRasterComposite = async (
ctx.restore();
};
- /**
- * Draws `[start, end)` bottom→top onto `ctx`. A scope's members render into
- * an isolated bbox-sized buffer first, the group's stack applies to that
- * composite, and the buffer lands source-over — the group-adjustment
- * semantics a per-leaf bake cannot reproduce under member opacity/blending.
- */
+ /** Draws `[start, end)` bottom→top; a scope isolates into a buffer, applies its stack, lands source-over. */
const renderRange = async (
ctx: Ctx,
start: number,
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/tool.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/tool.ts
index 81015b44ef..66e771d40a 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/tool.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/tool.ts
@@ -173,27 +173,15 @@ export interface ToolContext {
* engine-standalone behavior. Absent in minimal test harnesses.
*/
resolveColorSample?(hex: string): boolean;
- /**
- * The compositor providers that make color sampling WYSIWYG (layer and
- * group adjustment stacks, display effects). Absent in minimal harnesses;
- * the sampler then reads raw cached pixels.
- */
+ /** Compositor providers that make sampling WYSIWYG; absent ⇒ raw cached pixels. */
sampleProviders?: Pick<CompositeOptions, 'adjustedSurface' | 'derivedSurfaces' | 'groupSurface'>;
/**
- * Settles a pending one-shot sample request with the latest color the
- * gesture stashed via `resolveColorSample`. The color-picker tool calls this
- * on pointer up — never mid-gesture — so the requester's promise resolves
- * after the gesture ends and a structural commit in its continuation is not
- * refused as `gesture-active`. No-op without a pending request or a stashed
- * color.
+ * Settles a pending one-shot sample with the gesture's stashed color. Called
+ * on pointer up only, so a structural commit in the requester's continuation
+ * is not refused as `gesture-active`.
*/
commitColorSample?(): void;
- /**
- * Drops the color a pending sample request's gesture has stashed, without
- * settling the request. The color-picker tool calls it when a gesture is
- * cancelled and at the start of each fresh press, so a dead gesture's color
- * can never be committed by a later release that sampled nothing.
- */
+ /** Drops the stashed sample (gesture cancel, fresh press) without settling the request. */
discardColorSample?(): void;
/**
* Re-evaluates the active tool's CSS cursor and applies it to the input
diff --git a/invokeai/frontend/webv2/src/workbench/canvasProjectMutations.ts b/invokeai/frontend/webv2/src/workbench/canvasProjectMutations.ts
index b708f4c165..c3f2ea61e1 100644
--- a/invokeai/frontend/webv2/src/workbench/canvasProjectMutations.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvasProjectMutations.ts
@@ -513,13 +513,7 @@ const patchNode = (node: CanvasNodeContract, patch: CanvasLayerBasePatch): Canva
return { ...node, ...rest, transform: transform ? { ...node.transform, ...transform } : node.transform };
};
-/**
- * The reducer-level half of the group-adjustments invariant: a group config
- * applies only to RASTER-stack groups (the model refuses earlier with a
- * reason; unvalidated dispatchers — previews, replays — must still be unable
- * to stamp a contract-invalid overlay-group stack). Mirrors the
- * `isHideableNode` guard on `setCanvasLayersHidden`.
- */
+/** Group configs apply only to raster-stack groups, even from unvalidated dispatchers (previews, replays). */
const isConfigTargetValid = (
document: CanvasDocumentContractV3,
id: string,
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts
index bd6b98c606..a63eb66ee6 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts
@@ -133,7 +133,6 @@ const adjustmentOwnerNode = (document: CanvasDocumentContractV3, id: string) =>
return node && (node.type === 'raster' || node.type === 'group') ? node : null;
};
-/** The whole-stack patch both adjustment owners share; the arm follows the owner's type. */
const adjustmentsPatch = (
ownerType: 'raster' | 'group',
id: string,
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
index e7a50d1d14..fa8ed008cb 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
@@ -201,11 +201,7 @@ export interface LayerContextAction {
export type LayerConfigPatchKind = 'control-transparency-effect' | 'regional-auto-negative';
const ALL_LAYER_TYPES = ['raster', 'control', 'inpaint_mask', 'regional_guidance'] as const;
-/**
- * The one add-adjustment catalog: the leaf context menu derives its `add-*`
- * actions from it and the group context menu renders it directly, so a new
- * entry type lands in both menus from one edit.
- */
+/** The one add-adjustment catalog; the leaf action registry and the group menu both render from it. */
export const ADJUSTMENT_ADD_ITEMS: readonly {
readonly defaultLabel: string;
readonly icon: LucideIcon;
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.ts
index d33e2ac0b4..b073aaf5b6 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.ts
@@ -32,11 +32,7 @@ export type PanelRow =
/** Projected child rows the node owns; `0` for bare leaves and rowless groups. */
readonly childCount: number;
readonly childrenExpanded: boolean;
- /**
- * The node's ARIA position among the parent group's COMBINED children
- * (modifier rows first, then nodes) when the parent owns modifier rows;
- * equal to the tree row's own values otherwise.
- */
+ /** Position among the parent group's COMBINED children (modifier rows first, then nodes). */
readonly ariaPosInSet: number;
readonly ariaSetSize: number;
}
@@ -87,15 +83,10 @@ export const flattenPanelRows = (
stack,
});
if (!collapsed) {
- // A group whose parent owns modifier rows shifts its node children into
- // one COMBINED ARIA set (rows first, then nodes) so AT hears a single
- // coherent set at that level.
const rowOffsetByParent = new Map<string, number>();
for (const row of stack.rows) {
const isGroup = row.vm.kind === 'group';
- // A group's modifier rows fold WITH its subtree: `aria-expanded`
- // reflects the subtree, so nothing may render beneath a collapsed
- // group. Leaves keep their separate per-owner fold.
+ // A group's rows fold WITH its subtree, keeping aria-expanded truthful.
const children = isGroup && !row.expanded ? [] : (childRows?.rowsFor(row) ?? []);
const childrenExpanded = children.length > 0 && (isGroup || !childRows!.collapsedLayerIds.has(row.id));
const offset = rowOffsetByParent.get(row.vm.parentId ?? '') ?? 0;
@@ -186,7 +177,6 @@ export const navigateTree = (
return null;
}
const { row } = current;
- // A group expands its subtree before its modifier rows; a leaf has only rows.
if (row.vm.kind === 'group' && row.vm.childCount > 0 && !row.expanded) {
return { expand: row.id, expanded: true };
}
@@ -210,8 +200,6 @@ export const navigateTree = (
return { focus: current.child.layerId };
}
const { row } = current;
- // Mirror of ArrowRight. A group's rows fold with its subtree, so only a
- // LEAF's rows fold separately here.
if (row.vm.kind !== 'group' && current.childrenExpanded) {
return { expandChildren: row.id, expanded: false };
}