Keep ChatGPT fast by keeping only the last N messages in the DOM. 100% local, privacy-first Firefox extension.
- Automatic Trimming: Keeps only the last N messages visible (default: 10, range: 1-100)
- Memory Optimization: Reduces memory usage by 25-50% on long conversations (100+ messages)
- Performance: Maintains 60fps scrolling with <16ms DOM operation batching
- Intelligent Preservation: Optionally preserves system and tool messages beyond normal limit
- Scroll Pause: Automatically pauses trimming when reviewing older messages
- Privacy-First: Zero network requests, all processing happens locally
- Reversible: Page refresh restores full conversation history
- Quick Toggle: Enable/disable via popup without losing settings
Coming soon to addons.mozilla.org
-
Clone this repository:
git clone https://github.com/11me/light-session.git cd light-session -
Install dependencies:
npm install
-
Build the extension:
npm run build
-
Load in Firefox:
- Open Firefox
- Navigate to
about:debugging#/runtime/this-firefox - Click "Load Temporary Add-on"
- Select
extension/manifest.json
- Open a long ChatGPT conversation (or create one)
- Click the LightSession icon in Firefox toolbar
- Extension is enabled by default - trimming happens automatically
- Adjust the slider to change how many messages to keep (1-100)
- Extension Enabled: Toggle trimming on/off
- Keep last N messages: Adjust message retention limit (1-100)
- Preserve system/tool messages: Keep system/tool messages beyond normal limit
- Pause when scrolled up: Stop trimming while reviewing history
- Debug mode: Enable console logging for troubleshooting
- Refresh: Reload page to restore full conversation history
- All controls are keyboard accessible (Tab/Shift+Tab to navigate)
- Enter/Space to toggle checkboxes and buttons
- Arrow keys to adjust slider
LightSession uses a non-destructive trimming approach:
- Detection: Uses multi-tier selector strategy to find message nodes (resilient to UI changes)
- Classification: Identifies message roles (user, assistant, system, tool)
- Calculation: Determines which messages to keep based on settings
- Batching: Removes excess nodes in idle time (<16ms chunks for 60fps)
- Markers: Replaces removed nodes with comment markers for debugging
Important: Trimming only affects the DOM (what's displayed). The actual conversation data remains on OpenAI's servers. Refreshing the page restores everything.
- Zero Network Requests: No data leaves your browser
- Local Storage Only: Settings stored in
browser.storage.local - No Telemetry: No analytics, tracking, or reporting
- Minimal Permissions: Only requires
storagepermission - Domain Restricted: Only runs on
chat.openai.comandchatgpt.com - Open Source: All code is auditable
See PRIVACY.md for detailed privacy policy.
- Node.js ≥18.0
- npm ≥9.0
- Firefox ≥115
# Install dependencies
npm install
# Build (one-time)
npm run build
# Watch mode (rebuilds on file changes)
npm run watch
# Lint code
npm run lint
# Format code
npm run format
# Run in Firefox Developer Edition
npm run dev
# Run in Firefox stable
npm run dev:stable
# Package for distribution
npm run package
# Clean build artifacts
npm run cleanextension/
├── src/
│ ├── content/ # Content scripts (run in ChatGPT pages)
│ ├── background/ # Background script (settings management)
│ ├── popup/ # Popup UI (HTML/CSS/JS)
│ └── shared/ # Shared types, constants, utilities
├── dist/ # Compiled output (TypeScript → JavaScript)
├── icons/ # Extension icons
└── manifest.json # Firefox extension manifest
specs/ # Feature specifications and design docs
tests/ # Manual test procedures
- State Machine: Trimmer uses IDLE → OBSERVING → PENDING_TRIM → TRIMMING states
- Multi-Tier Selectors: A (data attributes) → B (test IDs) → C (structural + heuristics)
- Debounced Observer: MutationObserver batches DOM changes (75ms debounce)
- Idle Callback: Removes nodes during browser idle time (requestIdleCallback)
- Fail-Safe: Minimum 6 message threshold, aborts on uncertainty
- Browser: Firefox ≥115 (Manifest V3 with background.scripts)
- OS: Windows, macOS, Linux
- ChatGPT: Optimized for current UI (as of 2025), resilient to minor changes
- Firefox Only: Chrome/Edge not supported (different WebExtensions API)
- UI Dependency: Major ChatGPT UI redesigns may require selector updates
- No Server-Side: Cannot reduce actual conversation size on OpenAI servers
- Manual Testing: No automated test suite (manual testing with Firefox DevTools)
- Check if extension is enabled (popup toggle should be ON/green)
- Verify you're on ChatGPT (chat.openai.com or chatgpt.com)
- Ensure conversation has >6 messages (fail-safe threshold)
- Check if streaming is in progress (trimming pauses during generation)
- Enable debug mode in popup and check Firefox console (F12)
- Check Firefox console for storage errors
- Verify
storagepermission in manifest - Try disabling/re-enabling extension
- Lower the "Keep last N messages" slider value
- Enable "Preserve system/tool messages" (may reduce removable nodes)
- Check Firefox DevTools → Performance tab for profiling
Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Make your changes
- Run linter (
npm run lint) - Format code (
npm run format) - Build successfully (
npm run build) - Test manually in Firefox (
npm run dev) - Commit changes (
git commit -m "feat: add X") - Push to branch (
git push origin feature/my-feature) - Open a Pull Request
ISC License - see LICENSE for details
Created as part of the Specify workflow for feature specification and implementation.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Disclaimer: This is an unofficial extension not affiliated with OpenAI. Use at your own risk.