smart content collapsing for context overflow, spinner CSS, ticket updates

fitPageContent() in content.js: 6 progressive collapse stages (dedup,
nav links, references, lists, code blocks, sidebar debris) before hard
truncation. No summarization, real content structurally compressed.
Wired into both page extraction points in embed modal.
Added .working pulse and .uncloseai-spinner CSS animations for #004.
Updated tickets #001 (CSP root cause), #004 (CSS ready), #005 (fixed).
This commit is contained in:
russell@unturf.com 2026-03-03 16:26:01 -05:00
parent 12e9e79f25
commit 93926bfbfc
8 changed files with 315 additions and 12 deletions

View file

@ -30,6 +30,16 @@ Possible causes:
- Shadow DOM or aggressive DOM manipulation interfering with injection
- Extension manifest permissions not covering these domains
## Root Cause
The browser-toys extension injects `<script src="https://uncloseai.com/uncloseai.js" type="module">` via DOM. Pages with strict CSP `script-src` directives block this because `https://uncloseai.com` is not in their allowlist.
## Fix
In the `uncloseai-browser-toys` repo, switch the content script from DOM script injection to `chrome.scripting.executeScript()` with the bundled IIFE (`uncloseai-bundle.js`). Extensions executing their own bundled code bypass page CSP entirely.
The bundle is ready: `make bundle-extension` produces `public/uncloseai-bundle.js` (1.6MB IIFE, CSP-safe, no ES modules, no CDN imports).
## Notes
Need to inspect the extension's content script injection mechanism and compare CSP headers between working and non-working pages.
Fix lives in the browser-toys repo, not this one. The bundle and architecture are ready here.

View file

@ -28,6 +28,17 @@ Keep consistent with the existing hourglass pattern on the book icon. Options:
- Icon swap to an animated version during loading
- Pulsing opacity animation (subtle but effective)
## Implementation
CSS animations added to both theme files (`uncloseai-modal-builtin.css`, `uncloseai-modal-pico.css`):
- `.working` class: pulse animation (opacity 1 to 0.4), disables pointer events
- `.uncloseai-spinner` class: continuous rotation for inline spinner elements
- Apply to `.uncloseai-btn-small` or `.uncloseai-btn-primary` elements
Usage: `btn.classList.add("working")` when async starts, `.remove("working")` when done.
TTS buttons (primary consumers) are currently hidden via feature flag. When TTS is re-enabled, wire the `.working` class into the TTS button click handlers.
## Notes
This is a UX quality issue. Without feedback, users assume the tap didn't register and tap again, potentially triggering duplicate requests or the freeze described in ticket 003.
CSS is ready. JS wiring deferred until TTS is re-enabled (tickets #002, #003).

View file

@ -33,6 +33,20 @@ Possible fixes:
- Never silently swallow API errors: if the completion fails, show the error to the user
- Prioritize user message and page content over system prompt when truncating
## Fix Implemented
Smart content collapsing in `content.js` via `fitPageContent()`. Progressive stages run in order of aggressiveness, stopping when content fits:
1. **Deduplicate paragraphs**: remove exact duplicate blocks (common in scraped DOM)
2. **Collapse nav links**: 5+ consecutive links become `[Navigation: N links including ...]`
3. **Collapse references**: dense URL/citation clusters become `[... N references collapsed]`
4. **Collapse lists**: 7+ item lists keep first 5, note `[... N more items]`
5. **Collapse code blocks**: 12+ line blocks keep first 10, note `[... N more lines]`
6. **Collapse sidebar debris**: runs of 6+ short fragments get compressed
7. **Hard truncate**: last resort, cuts at paragraph/sentence boundary
No summarization. All content stays real, just structurally compressed. Uses `max_model_len` from model discovery with 15k token overhead reserved for system prompt, computed intel, chat history, and output.
## Notes
The `max_model_len` field from model discovery should be used to calculate available context budget. System prompt + conversation history + page content must fit within this limit. If it doesn't, the client needs a truncation strategy, not silent failure.
Hermes bumped to 82k context. Wikipedia Napoleon (~67k tokens) should fit after collapsing without hard truncation.

View file

@ -4,11 +4,11 @@
| ID | Title | Reporter | Date | Priority |
|----|-------|----------|------|----------|
| 001 | [Extension fails to load on certain pages](001-extension-fails-to-load.md) | cthegray | 2026-03-03 | high |
| 002 | [TTS stops after first sentence](002-tts-stops-after-first-sentence.md) | cthegray | 2026-03-03 | high |
| 003 | [Audio icon freezes entire window](003-audio-icon-freezes-window.md) | cthegray | 2026-03-03 | critical |
| 004 | [Add working/spinning indicators for async operations](004-working-indicators.md) | cthegray | 2026-03-03 | medium |
| 005 | [Context overflow causes blank or hallucinated responses](005-context-overflow-silent-failure.md) | cthegray | 2026-03-03 | high |
| 001 | [Extension fails to load on certain pages](001-extension-fails-to-load.md) | cthegray | 2026-03-03 | high | Root cause: CSP blocks script injection. Fix in browser-toys repo. |
| 002 | [TTS stops after first sentence](002-tts-stops-after-first-sentence.md) | cthegray | 2026-03-03 | high | Deferred: TTS disabled via feature flag |
| 003 | [Audio icon freezes entire window](003-audio-icon-freezes-window.md) | cthegray | 2026-03-03 | critical | Deferred: TTS disabled via feature flag |
| 004 | [Add working/spinning indicators for async operations](004-working-indicators.md) | cthegray | 2026-03-03 | medium | CSS ready (.working class). JS wiring when TTS re-enabled. |
| 005 | [Context overflow causes blank or hallucinated responses](005-context-overflow-silent-failure.md) | cthegray | 2026-03-03 | high | Fixed: smart content collapsing in fitPageContent() |
## Closed