Edgee 1308 add claude code status bar showing live compression stats#54
Open
NicolasGirardot wants to merge 3 commits intomainfrom
Open
Conversation
… stats Install an Edgee status line into Claude Code's settings on launch that displays real-time tool compression percentage by polling the public session API. Composes with any existing statusLine config via a wrapper script and restores the original settings on exit. Closes EDGEE-1308 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…posing Update the API call to use GET /v1/sessions/:sessionId/summary (the new lightweight endpoint backed by the materialized view). Also prepend "| " to the Edgee status line when composing with an existing statusLine. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
KokaKiwi
reviewed
Apr 10, 2026
Comment on lines
+7
to
+82
| const EDGEE_SCRIPT: &str = r#"#!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Read stdin (Claude Code passes session JSON) | ||
| INPUT=$(cat) | ||
|
|
||
| # Env vars set by "edgee launch claude" | ||
| SESSION_ID="${EDGEE_SESSION_ID:-}" | ||
| API_URL="${EDGEE_CONSOLE_API_URL:-https://api.edgee.app}" | ||
|
|
||
| if [ -z "$SESSION_ID" ]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| # ── cache ──────────────────────────────────────────────────────────── | ||
| CACHE_DIR="${HOME}/.config/edgee/cache" | ||
| mkdir -p "$CACHE_DIR" | ||
| CACHE_FILE="${CACHE_DIR}/statusline-${SESSION_ID}.json" | ||
| CACHE_MAX_AGE=8 | ||
|
|
||
| USE_CACHE=false | ||
| if [ -f "$CACHE_FILE" ]; then | ||
| if [ "$(uname)" = "Darwin" ]; then | ||
| FILE_AGE=$(( $(date +%s) - $(stat -f %m "$CACHE_FILE") )) | ||
| else | ||
| FILE_AGE=$(( $(date +%s) - $(stat -c %Y "$CACHE_FILE") )) | ||
| fi | ||
| [ "$FILE_AGE" -lt "$CACHE_MAX_AGE" ] && USE_CACHE=true | ||
| fi | ||
|
|
||
| if [ "$USE_CACHE" = true ]; then | ||
| STATS=$(cat "$CACHE_FILE") | ||
| else | ||
| STATS=$(curl -sf --max-time 5 \ | ||
| "${API_URL}/v1/sessions/${SESSION_ID}/summary" 2>/dev/null) || STATS="" | ||
| if [ -n "$STATS" ]; then | ||
| echo "$STATS" > "$CACHE_FILE" | ||
| elif [ -f "$CACHE_FILE" ]; then | ||
| STATS=$(cat "$CACHE_FILE") | ||
| fi | ||
| fi | ||
|
|
||
| # ── render ─────────────────────────────────────────────────────────── | ||
| SEP="" | ||
| [ -n "${EDGEE_HAS_EXISTING_STATUSLINE:-}" ] && SEP="| " | ||
|
|
||
| if [ -z "$STATS" ] || ! command -v jq &>/dev/null; then | ||
| echo -e "${SEP}\033[38;5;128m三 Edgee\033[0m" | ||
| exit 0 | ||
| fi | ||
|
|
||
| BEFORE=$(echo "$STATS" | jq -r '.total_uncompressed_tools_tokens // 0') | ||
| AFTER=$(echo "$STATS" | jq -r '.total_compressed_tools_tokens // 0') | ||
| REQUESTS=$(echo "$STATS" | jq -r '.total_requests // 0') | ||
|
|
||
| PURPLE='\033[38;5;128m' | ||
| BOLD_PURPLE='\033[1;38;5;128m' | ||
| DIM='\033[2m' | ||
| RESET='\033[0m' | ||
|
|
||
| if [ "$BEFORE" -gt 0 ] && [ "$AFTER" -lt "$BEFORE" ]; then | ||
| PCT=$(( (BEFORE - AFTER) * 100 / BEFORE )) | ||
| FILLED=$(( PCT * 10 / 100 )) | ||
| BAR="" | ||
| for ((i=0; i<FILLED; i++)); do BAR+="█"; done | ||
| for ((i=FILLED; i<10; i++)); do BAR+="░"; done | ||
|
|
||
| echo -e "${SEP}${PURPLE}三 Edgee${RESET} ${PURPLE}${BAR}${RESET} ${BOLD_PURPLE}${PCT}%${RESET} tool compression ${DIM}${REQUESTS} reqs${RESET}" | ||
| else | ||
| if [ "$REQUESTS" -gt 0 ]; then | ||
| echo -e "${SEP}${PURPLE}三 Edgee${RESET} ${DIM}${REQUESTS} reqs${RESET}" | ||
| else | ||
| echo -e "${SEP}${PURPLE}三 Edgee${RESET}" | ||
| fi | ||
| fi | ||
| "#; |
Member
There was a problem hiding this comment.
Maybe extract that into a .sh file and use include_str! here
Member
Author
There was a problem hiding this comment.
Done in 755d533 — extracted to statusline.sh and loaded via include_str!. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description of Changes
Adds a Claude Code status bar that displays live compression stats from the Edgee session, and wires it up to the new lightweight
/v1/sessions/:sessionId/summaryendpoint.|as a separator/summaryendpoint (backed by the materialized view) for low-overhead pollingRelated Issues
EDGEE-1308