# Status Line Agent Display + Keybind Fix ## Goal 1. Display `[personal-assistant] Opus | 45% context` in Claude Code status line 2. Fix Super+Shift+C keybind (terminal closes immediately) ## Root Cause: Keybind Issue The `pa-mode` script creates a **detached** tmux session (`-d` flag) then attaches separately. This doesn't work well with `omarchy-launch-tui`. The working pattern uses `tmux -A` (attach-or-create in one step). ## Implementation ### Task 1: Create Status Line Script **Create:** `~/.claude/automation/statusline.sh` ```bash #!/usr/bin/env bash input=$(cat) AGENT="${CLAUDE_AGENT:-}" MODEL=$(echo "$input" | jq -r '.model.display_name // "?"') # Calculate context percentage CONTEXT_PCT="?" usage=$(echo "$input" | jq '.context_window.current_usage // empty') if [ -n "$usage" ]; then current=$(echo "$usage" | jq '.input_tokens + .cache_creation_input_tokens + .cache_read_input_tokens') size=$(echo "$input" | jq '.context_window.context_window_size') if [ "$size" -gt 0 ] 2>/dev/null; then CONTEXT_PCT=$((current * 100 / size)) fi fi if [ -n "$AGENT" ]; then echo "[$AGENT] $MODEL | ${CONTEXT_PCT}% context" else echo "$MODEL | ${CONTEXT_PCT}% context" fi ``` ### Task 2: Configure Status Line in Settings **Modify:** `~/.claude/settings.json` Add: ```json { "statusLine": { "type": "command", "command": "~/.claude/automation/statusline.sh" } } ``` ### Task 3: Fix pa-mode Script **Modify:** `~/.claude/automation/pa-mode` Key changes: 1. Export `CLAUDE_AGENT=personal-assistant` before launching 2. Use `tmux new-session -A` (attach-or-create) instead of `-d` + separate attach 3. Remove the separate `attach_session` flow New `create_or_attach_session()` function: ```bash create_or_attach_session() { local session_id session_id=$(get_session_id) local history_file="$HISTORY_DIR/${session_id}.jsonl" # If session doesn't exist, record it in index if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then local tmp_file tmp_file=$(mktemp) jq --arg id "$session_id" --arg started "$(date -Iseconds)" \ '.sessions += [{"id": $id, "started": $started, "ended": null, "summarized": false, "topics": []}]' \ "$INDEX_FILE" > "$tmp_file" && mv "$tmp_file" "$INDEX_FILE" fi # Export for status line, then attach-or-create export CLAUDE_AGENT=personal-assistant exec tmux new-session -A -s "$SESSION_NAME" -c "$HOME" \ "PA_SESSION_ID='$session_id' PA_HISTORY_FILE='$history_file' CLAUDE_AGENT=personal-assistant claude --dangerously-skip-permissions --agent personal-assistant" } ``` Note: Using `exec` replaces the shell process with tmux, keeping the terminal open. ### Task 4: Verify Hyprland Keybind **File:** `~/.config/hypr/bindings.conf` (line 34) Current (should work after pa-mode fix): ``` bindd = SUPER SHIFT, C, PA Agent Mode, exec, omarchy-launch-tui /home/will/.claude/automation/pa-mode ``` No changes needed if pa-mode fix works. If still broken, fallback to: ``` bindd = SUPER SHIFT, C, PA Agent Mode, exec, uwsm-app -- xdg-terminal-exec -e /home/will/.claude/automation/pa-mode ``` ## Files to Modify | File | Action | |------|--------| | `~/.claude/automation/statusline.sh` | Create | | `~/.claude/settings.json` | Add statusLine config | | `~/.claude/automation/pa-mode` | Fix session creation, add CLAUDE_AGENT export | | `~/.config/hypr/bindings.conf` | Maybe adjust if fix doesn't work | ## Testing 1. Run `pa-mode` from terminal - should open tmux with claude 2. Check status line shows `[personal-assistant] Opus | X% context` 3. Press Super+Shift+C - terminal should stay open with PA session 4. Detach (Ctrl+B, D), press Super+Shift+C again - should reattach ## Commits 1. `feat: add status line script with agent display` 2. `fix: pa-mode keybind issue - use tmux -A and exec`