I've investigated the bug and implemented the new context sidebar feature.
1. Bug Explanation (Not Fixed)
The bug where the app has very small text on launch when installed via homebrew (and specifically triggered when tiled by Aerospace) is caused by the way the app forcibly overrides the OS's native display scaling.
In src/app.rs (and within App::new), the application calls ctx.set_pixels_per_point(config.ui_scale) where config.ui_scale defaults to 1.0. On a macOS Retina display, the OS naturally uses a scale factor of 2.0. However, by hardcoding the pixels-per-point to 1.0, egui is instructed to map exactly 1 physical pixel to 1 logical point. This completely ignores the Retina scale factor, making all text and UI elements appear exactly half their intended size.
This happens specifically with window managers like Aerospace because when the window manager aggressively tiles the window immediately on launch, it triggers a resize/scale event from the OS. eframe normally handles this by applying the correct scale factor, but since the code immediately overwrites it with 1.0, it discards the correct OS scale factor.
In newer egui versions, the correct approach is to use ctx.set_zoom_factor(config.ui_scale) instead, which multiplies the user's preferred zoom by the OS's native scale factor rather than completely overwriting it. Let me know when you are ready for me to fix this bug!
2. Context Sidebar Feature
I have successfully implemented the right-hand context sidebar similar to opencode. Here is what I added:
- A new
☰▶ toggle button on the top right next to the settings button.
- A toggleable right-hand panel that displays:
- Context Size: The raw character count of the context (system prompt + past messages + current input buffer).
- Token Estimate: Uses
tiktoken-rs (specifically the cl100k_base BPE used by modern models) to accurately count the tokens currently within the context. I utilized the cl100k_base_singleton which caches the tokenizer to ensure the UI stays at 60 FPS while typing without re-allocating memory for the model.
- Cost Estimate: A placeholder showing
$0.00 since the app connects to local models primarily.
- Last API Usage: If the last message included token usage metadata (Prompt/Completion/Total), it will display at the bottom of the sidebar.
I've already run the linter and verified everything compiles cleanly. Let me know if you would like any modifications to the new sidebar!