Skip to content

feat: auto-unload model after 30min inactivity + model picker on first launch#13

Open
Swallow74 wants to merge 6 commits into
kessler:mainfrom
Swallow74:main
Open

feat: auto-unload model after 30min inactivity + model picker on first launch#13
Swallow74 wants to merge 6 commits into
kessler:mainfrom
Swallow74:main

Conversation

@Swallow74

@Swallow74 Swallow74 commented May 13, 2026

Copy link
Copy Markdown

Summary

Two features for better model lifecycle management:

1. Auto-unload after inactivity

  • Unloads the Gemma 4 model from GPU memory after 30 minutes of inactivity
  • Automatically reloads the model when the user sends a message or reopens the chat
  • Frees ~500MB-1.5GB of VRAM when not in use

2. Model picker on first launch

  • Instead of immediately downloading the default model, the user sees a model picker
  • Choose between E2B (~500MB) and E4B (~1.5GB)
  • Selection is persisted in chrome.storage.local — only shown once
  • Subsequent opens auto-load as before

Files changed

File Change
offscreen/model-host.ts Added lastModelId — persists across unload/reload
entrypoints/offscreen/main.ts Added 30min inactivity timer + auto-reload in agent:run
content/chat-overlay.ts Added model picker UI (CSS + DOM + show/hide)
entrypoints/content.ts Check gemma_model_chosen flag, show picker or auto-load
shared/messages.ts Added unloaded to ModelStatusMessage status union

@Swallow74 Swallow74 changed the title feat: auto-unload model after 15min inactivity, reload on next interaction feat: auto-unload model after 15min inactivity + model picker on first launch May 13, 2026
…t launch

- Unloads model from GPU memory after 30 minutes of inactivity\n- Auto-reloads on next message or chat open\n- Shows model picker (E2B/E4B) on first launch instead of auto-loading default\n- Selection persisted in chrome.storage.local\n- Handles 'unloaded' status in content script UI
@Swallow74 Swallow74 changed the title feat: auto-unload model after 15min inactivity + model picker on first launch feat: auto-unload model after 30min inactivity + model picker on first launch May 13, 2026
@kessler

kessler commented May 29, 2026

Copy link
Copy Markdown
Owner

hi @Swallow74
First, thanks for this PR
Quick question, those downloaded model sizes, where did you get them from ?

@Swallow74

Copy link
Copy Markdown
Author

Thanks for checking!

I verified the sizes directly from the Hugging Face model repos. The app loads the q4f16 ONNX quantized format via Transformers.js, so I added up the actual onnx_data file sizes for that variant:

E2B (~3.4GB):

  • decoder_model_merged_q4f16.onnx_data → 1.52 GB
  • embed_tokens_q4f16.onnx_data → 1.59 GB
  • audio_encoder_q4f16.onnx_data → 171 MB
  • vision_encoder_q4f16.onnx_data → 99.2 MB
  • Total: ~3.38 GB → rounded to ~3.4 GB

E4B (~5.2GB):

  • decoder_model_merged_q4f16.onnx_data → 2.07 GB + 812 MB
  • embed_tokens_q4f16.onnx_data → 2.02 GB
  • audio_encoder_q4f16.onnx_data → 172 MB
  • vision_encoder_q4f16.onnx_data → ~100 MB
  • Total: ~5.17 GB → rounded to ~5.2 GB

I originally had the default ONNX sizes (~500MB and ~1.5GB), which seemed wrong the first time I actually downloaded a model, so I updated them to match the q4f16 files that Transformers.js pulls down.

Feel free to double-check at:

nandanadileep and others added 4 commits June 28, 2026 11:17
- Alt+G toggles the chat overlay open/closed from anywhere on the page
- Escape closes the overlay when it is visible
Alt+G toggles the chat overlay from anywhere on the page and Escape
closes it; both are rebindable from the settings panel and persisted to
browser.storage.local. Shortcuts are matched off KeyboardEvent.code (so
modifier combos are layout-stable) and handled in the capture phase so
they work even when the chat input is focused.
- Add auto fallback from webgpu to wasm device on load failure
- Copy ort-wasm-simd-threaded files needed for WASM backend
- Add device field to model status/switch/load messages
- Better error messages for WebGPU alignment failures
- Catch 'unaligned' error during agent run, not just model load
- Reload model with WASM backend and retry generation automatically
- Show warning message to user during fallback
- Remove premature error wrapping in generateRaw
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.

3 participants