Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/core/treeStructure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,23 @@ export class AACPage {
this._pendingMutations.push({ type: 'addButton', button });
}

/**
* Internal load-path button push: adds a button to the page WITHOUT recording a mutation.
* Used by processors during loadIntoTree so the loaded baseline isn't treated as user changes.
* Not part of the public API — consumers should always use addButton.
*/
_loadButton(button: AACButton): void {
this.buttons.push(button);
}

/**
* Discard all recorded mutations on this page.
* Useful as an escape hatch after loadIntoTree if the consumer wants a clean baseline.
*/
clearMutations(): void {
this._pendingMutations = [];
}

/**
* Get the list of pending mutations for this page (read-only)
*/
Expand Down
3 changes: 2 additions & 1 deletion src/processors/applePanelsProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ class ApplePanelsProcessor extends BaseProcessor {
fontWeight: btn.DisplayImageWeight === 'bold' ? 'bold' : 'normal',
},
});
page.addButton(button);
// Load path: do not record as a user mutation
page._loadButton(button);

if (btn.Rect) {
const rect = this.parseRect(btn.Rect);
Expand Down
3 changes: 2 additions & 1 deletion src/processors/astericsGridProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,8 @@ class AstericsGridProcessor extends BaseProcessor {
colorConfig,
activeColorSchemeDefinition
);
page.addButton(button);
// Load path: do not record as a user mutation
page._loadButton(button);

const buttonX = element.x || 0;
const buttonY = element.y || 0;
Expand Down
6 changes: 4 additions & 2 deletions src/processors/dotProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ class DotProcessor extends BaseProcessor {
tree.addPage(page);

// Add a self button so single-node graphs yield one button
page.addButton(
// Load path: do not record as a user mutation
page._loadButton(
new AACButton({
id: `${node.id}_self`,
label: node.label,
Expand All @@ -191,7 +192,8 @@ class DotProcessor extends BaseProcessor {

targetPageId: edge.to,
});
fromPage.addButton(button);
// Load path: do not record as a user mutation
fromPage._loadButton(button);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/processors/gridsetProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1749,8 +1749,8 @@ class GridsetProcessor extends BaseProcessor {
},
});

// Add button to page
page.addButton(button);
// Add button to page (load path: do not record as a user mutation)
page._loadButton(button);

// Place button in grid layout (handle colspan/rowspan)
for (let r = cellY; r < cellY + rowSpan && r < maxRows; r++) {
Expand Down
3 changes: 2 additions & 1 deletion src/processors/opmlProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class OpmlProcessor extends BaseProcessor {
message: '',
targetPageId: childText.replace(/[^a-zA-Z0-9]/g, '_'),
});
page.addButton(button);
// Load path: do not record as a user mutation
page._loadButton(button);

const { page: childPage, childPages: grandChildren } = this.processOutline(
child,
Expand Down
3 changes: 2 additions & 1 deletion src/processors/snapProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,8 @@ class SnapProcessor extends BaseProcessor {
// Add to the intended parent page
const parentPage = tree.getPage(parentUniqueId);
if (parentPage) {
parentPage.addButton(button);
// Load path: do not record as a user mutation
parentPage._loadButton(button);

// Add button to grid layout if position data is available
const gridPositionStr = String(btnRow.GridPosition || '');
Expand Down
6 changes: 3 additions & 3 deletions src/processors/touchchatProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ class TouchChatProcessor extends BaseProcessor {
button.x = absoluteX;
button.y = absoluteY;

// Add button to page
page.addButton(button);
// Add button to page (load path: do not record as a user mutation)
page._loadButton(button);

// Place button in grid (handle span)
for (let r = absoluteY; r < absoluteY + safeSpanY && r < 10; r++) {
Expand Down Expand Up @@ -518,7 +518,7 @@ class TouchChatProcessor extends BaseProcessor {
const page = Object.values(tree.pages).find(
(p) => p.id === (numericToRid.get(btnRow.id) || String(btnRow.id))
);
if (page) page.addButton(button);
if (page) page._loadButton(button); // load path: do not record as a user mutation
});
} catch (_e) {
// console.log('No direct page buttons found:', e);
Expand Down
Loading