Skip to content

fix: skip tree rewriting when no visible trimming needed (#26)#31

Merged
11me merged 3 commits intomasterfrom
fix/trimmer-and-hardening
Mar 25, 2026
Merged

fix: skip tree rewriting when no visible trimming needed (#26)#31
11me merged 3 commits intomasterfrom
fix/trimmer-and-hardening

Conversation

@11me
Copy link
Copy Markdown
Owner

@11me 11me commented Mar 25, 2026

Summary

  • Fix issue Node-Message Distinction: Each thought in thinking mode counts as a message? #26: trimMapping() was destructively rewriting the conversation tree even when no visible messages needed trimming (limit >= visibleTotal). This stripped hidden nodes (system/tool/thinking) and rewired parent/children links, potentially breaking ChatGPT rendering for Extended Thinking conversations.
  • Added a guard in page-script.ts: when visibleKept === visibleTotal, return the original response unmodified
  • Hardening: popstate guard, scroller null-check, log format alignment, root node trimming fix

Test plan

  • 230 unit tests pass (4 new tests for the guard)
  • Lint + TypeScript clean
  • Codex review: APPROVE (2 rounds)
  • Browser smoke test: limit=1 trims correctly, limit=100 preserves original tree, limit=10 default works
  • Verified via CDP that original API response (426 nodes) passes through unmodified when no trimming needed

11me added 3 commits March 25, 2026 23:46
- Move popstate listener inside PATCH_FLAG guard to prevent duplicate registration
- Replace scroller non-null assertion with proper null check
- Remove redundant configReceived early return in page-script
- Align log prefix format to [LS:LEVEL] convention
- Don't force-preserve visible first node as root anchor when trimming
When trimMapping returns visibleKept === visibleTotal, return the
original response unmodified instead of rebuilding the tree.
This preserves hidden nodes (system/tool/thinking) that ChatGPT
may need for rendering Extended Thinking conversations.
@11me 11me merged commit 6bfdbef into master Mar 25, 2026
1 check passed
@11me 11me deleted the fix/trimmer-and-hardening branch April 7, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant