Skip to content

Edgee 1308 add claude code status bar showing live compression stats#54

Open
NicolasGirardot wants to merge 3 commits intomainfrom
edgee-1308-add-claude-code-status-bar-showing-live-compression-stats
Open

Edgee 1308 add claude code status bar showing live compression stats#54
NicolasGirardot wants to merge 3 commits intomainfrom
edgee-1308-add-claude-code-status-bar-showing-live-compression-stats

Conversation

@NicolasGirardot
Copy link
Copy Markdown
Member

@NicolasGirardot NicolasGirardot commented Apr 10, 2026

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

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/summary endpoint.

  • Status line shows live compression stats for the current Edgee session
  • When composing with an existing statusLine, the Edgee segment is prepended with | as a separator
  • Uses the new /summary endpoint (backed by the materialized view) for low-overhead polling

Related Issues

EDGEE-1308

NicolasGirardot and others added 2 commits April 10, 2026 15:41
… 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>
@NicolasGirardot NicolasGirardot requested a review from a team as a code owner April 10, 2026 14:55
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
"#;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe extract that into a .sh file and use include_str! here

Copy link
Copy Markdown
Member Author

@NicolasGirardot NicolasGirardot Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 755d533 — extracted to statusline.sh and loaded via include_str!. Thanks!

…de_str!

Addresses review feedback from @KokaKiwi on #54.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants