Skip to content

feat: Task Objective widget with session discovery#263

Open
m-mcgowan wants to merge 3 commits intosirmalloc:mainfrom
m-mcgowan:feat/task-objective-widget
Open

feat: Task Objective widget with session discovery#263
m-mcgowan wants to merge 3 commits intosirmalloc:mainfrom
m-mcgowan:feat/task-objective-widget

Conversation

@m-mcgowan
Copy link
Copy Markdown

Summary

Adds a new task-objective widget that displays what Claude is currently working on in the status line, with emoji status indicators and a persistent elapsed timer.

  • 🔄 in_progress, ✅ complete, ❌ failed, 🛑 blocked, ⏸️ paused, 🔍 reviewing
  • Elapsed timer persists via sidecar file, freezes on terminal statuses (complete/failed)
  • Session ID discovery bridges the gap between Claude Code (which doesn't expose session_id to conversations) and the widget
  • Install flow auto-configures permissions, a PreToolUse hook for write approval, and CLAUDE.md instructions

New files

  • src/widgets/TaskObjective.ts — the widget
  • src/utils/session-discovery.ts — PID-based session ID bridge
  • src/utils/claude-md.ts — CLAUDE.md instruction management (tagged markers for idempotent update/removal)
  • docs/task-objective.md — architecture documentation

How it works

  1. ccstatusline walks the process tree to find the Claude CLI PID, writes session ID to ~/.cache/ccstatusline/sessions/<pid>
  2. Claude discovers its session ID via echo $PPID + reading the session file
  3. Claude writes {"task":"...","status":"..."} to ~/.cache/ccstatusline/tasks/claude-task-<session-id>
  4. The widget renders the task with status emoji and elapsed timer

Install flow additions

When the task-objective widget is in the config, installStatusLine():

  • Adds Bash(echo $PPID) and Read(//...sessions/*) permissions
  • Adds a PreToolUse hook on Write that auto-approves task file writes (needed because Claude Code's permission system doesn't reliably match Write paths outside the project)
  • Appends tagged instructions to ~/.claude/CLAUDE.md
  • Pre-creates the tasks directory

See docs/task-objective.md for full architecture details.

Test plan

  • Add task-objective widget to ccstatusline config
  • Run install, verify settings.json has permissions + hook + CLAUDE.md has instructions
  • Start a Claude Code session, verify task appears in status line
  • Change task, verify timer resets
  • Complete task, verify timer freezes and ✅ shows
  • Uninstall, verify hook and CLAUDE.md section removed
  • Concurrent sessions in same directory work independently

🤖 Generated with Claude Code

m-mcgowan and others added 2 commits March 24, 2026 13:11
Adds a new widget that displays the current Claude Code task objective
in the status line, with emoji status indicators and elapsed timer.

The widget reads from session-keyed task files written by Claude via
instructions injected into CLAUDE.md during install. A PreToolUse hook
auto-approves writes to task files without prompting.

Session ID discovery bridges the gap between Claude Code (which doesn't
expose session_id to conversations) and the widget (which needs it):
ccstatusline writes the session ID to a file keyed by the Claude CLI
PID, which Claude discovers via echo $PPID.

New files:
- src/widgets/TaskObjective.ts - the widget
- src/utils/session-discovery.ts - PID-based session ID bridge
- src/utils/claude-md.ts - CLAUDE.md instruction management
- docs/task-objective.md - architecture documentation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The elapsed timer now uses a sidecar file (.started) to persist the
start time across ccstatusline process restarts. The timer freezes
when the task reaches a terminal status (complete, failed).

Also updated CLAUDE.md instructions with status value table and
guidance on task description length.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests cover rendering, status indicators, elapsed timer with sidecar
persistence, freeze on completion, maxWidth truncation, plain text
fallback, preview mode, and editor display.

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.

1 participant