feat(web): Outliner restriction columns write the native flags

The web Outliner drew a single eye toggle while desktop draws the seven
restriction columns from SpaceOutliner.show_restrict_flags. The engine row
projection now carries restrict{...} read from the same flags the desktop
buttons use: the eye is Base.hide_viewport, the monitor/camera/select bits
live on Object, and exclusion/holdout/indirect-only come from the layer
collection. OUTLINER_SET_RESTRICTION writes the property through RNA; Shift
recurses through the collection subtree and its objects, Ctrl goes through
outliner_collection_isolate_flag (whose second click restores the default
visibility set). OUTLINER_SET_RESTRICT_COLUMNS toggles the popover
checkboxes; both are Main edits with changed=true.

The App renders the restriction buttons and the 限制列 popover group from
restrictColumns with optimistic drafts, except for isolate clicks, where
outliner_collection_isolate_flag forces the clicked collection back to
visible and a draft for that row could never reconcile with the snapshot.

Headed case [outliner-restrict-web] covers the popover columns, the object
eye plus the native VISIBLE filter, Shift recursion into a collection and
Ctrl isolate/restore on a product-created sibling collection; receipt
OUTLINER-HEADED-20261130-072807 (NOT_CLAIMED, 7/7). The armature panel
regression fails identically with this batch stashed, so it is tracked as
pre-existing.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-11-30 07:37:01 +08:00
parent 1c8cc73e3d
commit ecf69c6ef5
13 changed files with 596 additions and 24 deletions

View File

@@ -354,10 +354,11 @@ export interface NativeAreaLayout {
screenState: 'NORMAL' | 'MAXIMIZED' | 'FULLSCREEN';
headerMenusVisible?: boolean;
}
export interface NativeOutlinerRow { id: string; label: string; depth: number; selected: boolean; active: boolean; expanded: boolean; hasChildren: boolean; objectId: string | null; remapId?: string | null }
export interface NativeOutlinerRestrict { enable?: boolean; select?: boolean; hide?: boolean; viewport?: boolean; render?: boolean; holdout?: boolean; indirectOnly?: boolean }
export interface NativeOutlinerRow { id: string; label: string; depth: number; selected: boolean; active: boolean; expanded: boolean; hasChildren: boolean; objectId: string | null; kind?: string; restrict?: NativeOutlinerRestrict; restrictionEditable?: boolean; remapId?: string | null }
export interface NativeOutlinerRemapID { id: string; name: string; idType: number; library: string; editable: boolean }
export interface NativeOutlinerFilter { searchString: string; caseSensitive: boolean; complete: boolean; sortAlpha: boolean; invert: boolean; state: 'ALL' | 'VISIBLE' | 'SELECTED' | 'ACTIVE' | 'SELECTABLE'; showObjects: boolean; showObjectContents: boolean; showChildren: boolean; showCollections: boolean; showViewLayers: boolean }
export interface NativeOutlinerTree { rows: NativeOutlinerRow[]; truncated: boolean; syncSelection: boolean; displayMode?: string; displayModes?: Array<{ id: string; label: string }>; filter?: NativeOutlinerFilter; remapIds?: NativeOutlinerRemapID[] }
export interface NativeOutlinerTree { rows: NativeOutlinerRow[]; truncated: boolean; syncSelection: boolean; displayMode?: string; displayModes?: Array<{ id: string; label: string }>; filter?: NativeOutlinerFilter; restrictColumns?: NativeOutlinerRestrict; remapIds?: NativeOutlinerRemapID[] }
export interface EditorAreaIR { nativeLayout?: NativeAreaLayout; id: string; editor: EditorTypeIR; regions: EditorRegionIR[]; rect: { x: number; y: number; width: number; height: number }; maximized: boolean; filterText?: string; space?: { outliner?: NativeOutlinerTree; kind: string; dataId?: string | null; view?: NativeViewportState; textSelection?: TextSelectionIR; imageView?: NativeImageView; uvPackTarget?: NativeUVPackTarget; properties?: NativePropertiesContext; spreadsheet?: NativeSpreadsheetContext } }
export interface EditorWorkspaceIR { id: string; name: string; screenId?: string; writable?: boolean; areas: EditorAreaIR[]; activeAreaId: string; revision: number }
// ACTION operator RNA identifiers; the native caller resolves them against the
@@ -463,6 +464,8 @@ export type EditorContextEdit = { workspaceId: string; screenId: string } & (
| { action: 'OUTLINER_SET_DISPLAY_MODE'; areaId: string; displayMode: string }
| { action: 'OUTLINER_SET_FILTER'; areaId: string; filter: NativeOutlinerFilter }
| { action: 'OUTLINER_SET_SYNC_SELECT'; areaId: string; sync: boolean }
| { action: 'OUTLINER_SET_RESTRICTION'; areaId: string; rowId: string; column: keyof NativeOutlinerRestrict; value: boolean; extend: boolean; isolate: boolean }
| { action: 'OUTLINER_SET_RESTRICT_COLUMNS'; areaId: string; columns: NativeOutlinerRestrict }
| { action: "SET_EDITOR_TYPE"; areaId: string; editorType: string }
| { action: "SPLIT_AREA"; areaId: string; direction: 'HORIZONTAL' | 'VERTICAL'; factor: number }
| { action: "JOIN_AREA"; areaId: string; targetAreaId: string }
@@ -569,6 +572,14 @@ export class EditorWorkflowValidationError extends Error {
const EDITOR_REGION_KINDS = new Set<EditorRegionKind>(["HEADER", "MAIN", "TOOLBAR", "SIDEBAR", "FOOTER", "OTHER"]);
function record(value: unknown): value is Record<string, unknown> { return typeof value === "object" && value !== null && !Array.isArray(value); }
function text(value: unknown, name: string, maximum = 256): string { if (typeof value !== "string" || value.length === 0 || value.length > maximum) throw new EditorWorkflowValidationError("EDITOR_LAYOUT_INVALID", `${name} is invalid`); return value; }
const OUTLINER_RESTRICT_COLUMNS = ['enable', 'select', 'hide', 'viewport', 'render', 'holdout', 'indirectOnly'] as const;
function restrictState(value: unknown, name: string): NativeOutlinerRestrict {
if (!record(value) || OUTLINER_RESTRICT_COLUMNS.some(key => value[key] !== undefined && typeof value[key] !== 'boolean')) {
throw new EditorWorkflowValidationError('EDITOR_LAYOUT_INVALID', `${name} is invalid`);
}
return Object.fromEntries(OUTLINER_RESTRICT_COLUMNS.filter(key => value[key] !== undefined)
.map(key => [key, value[key]])) as NativeOutlinerRestrict;
}
function finite(value: unknown, name: string, minimum: number, maximum: number): number { if (typeof value !== "number" || !Number.isFinite(value) || value < minimum || value > maximum) throw new EditorWorkflowValidationError("EDITOR_LAYOUT_INVALID", `${name} is outside the bounded range`); return value; }
function integer(value: unknown, name: string, minimum: number, maximum: number): number { if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum || value > maximum) throw new EditorWorkflowValidationError("EDITOR_LAYOUT_INVALID", `${name} is outside the bounded range`); return value; }
@@ -757,9 +768,15 @@ export function parseEditorWorkflow(value: unknown): EditorWorkflowIR {
const id = text(row.id, 'outliner.row.id', 65536);
if (rowIds.has(id)) throw new EditorWorkflowValidationError('EDITOR_LAYOUT_INVALID', 'Duplicate native Outliner row');
rowIds.add(id);
const kind = row.kind === undefined ? undefined : text(row.kind, 'outliner.row.kind', 64);
const restrict = row.restrict == null ? undefined : restrictState(row.restrict, 'outliner.row.restrict');
if (row.restrictionEditable !== undefined && typeof row.restrictionEditable !== 'boolean') {
throw new EditorWorkflowValidationError('EDITOR_LAYOUT_INVALID', 'Invalid native Outliner restriction editability');
}
return { id, label: row.label, depth: Number(row.depth), selected: row.selected as boolean,
active: row.active as boolean, expanded: row.expanded as boolean, hasChildren: row.hasChildren as boolean,
objectId: row.objectId === null ? null : text(row.objectId, 'outliner.row.objectId'),
kind, restrict, restrictionEditable: row.restrictionEditable as boolean | undefined,
remapId: row.remapId == null ? null : text(row.remapId, 'outliner.row.remapId', 65536) };
});
let remapIds: NativeOutlinerRemapID[] | undefined;
@@ -805,7 +822,9 @@ export function parseEditorWorkflow(value: unknown): EditorWorkflowIR {
throw new EditorWorkflowValidationError('EDITOR_LAYOUT_INVALID', 'Native Outliner display mode is not in its menu');
}
}
space.outliner = { rows, truncated: tree.truncated, syncSelection: tree.syncSelection, displayMode, displayModes, filter, remapIds };
const restrictColumns = tree.restrictColumns === undefined ? undefined :
restrictState(tree.restrictColumns, 'outliner.restrictColumns');
space.outliner = { rows, truncated: tree.truncated, syncSelection: tree.syncSelection, displayMode, displayModes, filter, restrictColumns, remapIds };
}
if (areaValue.space.spreadsheet !== undefined) {
const spreadsheet = areaValue.space.spreadsheet;