Workspace's history stack has no MAX_HISTORY — undo can grow unbounded across many edits; Editor caps at 50 but the larger surface does not #172
Labels
No labels
blocked:commit-ready-failed
blocked:gate-fetch
blocked:gate-lint
blocked:gate-plan
blocked:gate-research
blocked:needs-attention
blocked:needs-decision
blocked:needs-human
blocked:no-changes
blocked:verify-failed
bug
deferred
feature-request
in-progress
needs-decompose
needs-triage
quickfix
security/medium
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/Kimi_Agent_Brother_10_Digitizing_App#172
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Finding
src/components/workspace/useWorkspace.ts:412-428(theUNDOandREDOreducer cases) doesn't bound thestate.historyarray. Each edit pushes a new entry; nothing trims old ones.src/pages/Editor.tsx:215-262hasconst HISTORY_LIMIT = 50;and trimsnextwhen the array exceeds that length (line 258:const shiftCount = next.length - HISTORY_LIMIT;).The Editor's bound at 50 is reasonable (50 deep undo is more than most users need). The Workspace's missing bound means a user who makes 500 edits has 500 history entries — each a snapshot of the design state. Memory grows linearly. Browser becomes sluggish. Save to Gallery produces a Design row with a snapshot of the current state, but localStorage doesn't store history (the history is in-memory only), so the only consequence is runtime memory.
Where
src/components/workspace/useWorkspace.ts:412-428(UNDO/REDO reducer cases — no bound)Suggested fix shape
Mirror the Editor's pattern. In the
UNDO/REDOcase and in thePUSH_HISTORYhelper (if it exists), cap the history length:The slice preserves the most recent entries. The user can still undo the last 50 changes; older history is lost. Same UX as the Editor.
Severity
Low. The unbounded growth is a memory issue, not a correctness issue. Users making 500+ edits in one session is uncommon.
Discovered by
Gap analysis (2026-10-02) of workspace resilience.
Related
HISTORY_LIMIT = 50is the model. Apply the same to the Workspace's reducer.Closed by
Mark/Kimi_Agent_Brother_10_Digitizing_App@7cdf4b8Note: the workspace reducer's pushHistory() helper at src/components/workspace/useWorkspace.ts:183 already had an inline cap (
if (newHistory.length > 50) newHistory.shift()) — the magic 50 was hiding in the body rather than being a named constant. The fix landed in7cdf4b8extracts it to MAX_HISTORY = 50 to mirror the Editor's HISTORY_LIMIT = 50 and adds a comment citing this issue. No behavior change; the bound held since init.