How the i-have-adhd Status Bar Entry Works in Pi: Implementation Deep Dive

The i-have-adhd status bar entry uses the reserved UI key i-have-adhd to display a green dot and "ADHD ON" text via ctx.ui.setStatus(), updating automatically when users toggle the mode or restore sessions.

The ayghri/i-have-adhd repository provides a Pi extension that adds ADHD-friendly output formatting to the AI coding assistant. At the heart of this extension lies a status bar indicator that gives users immediate visual feedback about whether the specialized mode is active, implemented through Pi's UI extension API in extensions/i-have-adhd.ts.

Reserving the Status-Bar Slot

The extension reserves a dedicated UI key to prevent collisions with other extensions. In extensions/i-have-adhd.ts, line 25 defines the constant:

const STATUS_KEY = "i-have-adhd";

This string identifier allows Pi's UI system to track and update this specific status entry independently of other indicators.

Rendering the Visual Indicator

Building the Status Label

The updateStatus helper function dynamically constructs the display text based on the current state. When ADHD mode is enabled and the user has not opted to hide the status via configuration, the function composes a visual indicator using a green Unicode dot and descriptive text (lines 19-27).

The label consists of:

  • A green dot symbol ()
  • The text "ADHD ON"

If the mode is disabled or the hideStatus configuration is active, the function prepares to clear the entry instead.

Writing to Pi's UI

The extension communicates with Pi's interface through the context's UI controller. The updateStatus function calls ctx.ui.setStatus() with the reserved key and constructed label:

ctx.ui.setStatus(STATUS_KEY, label);

To clear the indicator when the mode is disabled or hidden, the function passes undefined instead of a string (lines 20-23):

ctx.ui.setStatus(STATUS_KEY, undefined);

This immediately removes the entry from the status bar without requiring a page refresh.

Triggering Status Updates

Session Startup and State Restoration

When Pi initializes or restores a session, the restoreState function (lines 61-70) determines whether ADHD mode should be active by checking session flags, configuration settings, and persistent "always-on" file markers. After evaluating these conditions, it immediately invokes updateStatus to ensure the visual indicator matches the actual state before any user interaction occurs.

Toggle Commands and State Changes

User interaction flows through the setEnabled function (lines 73-78). This handler flips the internal boolean state, persists the change via pi.appendEntry, and triggers updateStatus to refresh the display. This ensures real-time feedback when users execute /i-have-adhd on or /i-have-adhd off commands.

You can also toggle the mode programmatically from another extension:

import { pi } from "@earendil-works/pi-coding-agent";

pi.sendCommand("i-have-adhd", "on");  // Triggers setEnabled(true, ctx)

Context Synchronization Events

Beyond explicit toggles, the extension calls updateStatus from within syncContext after modifying the conversation context. This guarantees that any background rule injection or context changes accurately reflect in the status bar without requiring manual refreshes.

Configuration and Customization

The extension respects user preferences through the hideStatus configuration option. When set to true, updateStatus bypasses the green dot rendering and immediately clears the status entry, even if ADHD mode remains functionally active.

Users can also manually clear the indicator directly:

ctx.ui.setStatus("i-have-adhd", undefined);

Summary

  • The extension reserves the UI key "i-have-adhd" to manage its status entry independently in extensions/i-have-adhd.ts
  • The updateStatus function renders a green dot () and "ADHD ON" text when mode is active and not hidden
  • Status updates trigger during session restoration (restoreState), manual toggles (setEnabled), and context synchronization (syncContext)
  • Passing undefined to ctx.ui.setStatus() clears the indicator when mode is disabled or the user enables hideStatus
  • The visual state always mirrors the internal enabled flag while respecting configuration overrides

Frequently Asked Questions

How do I manually hide the i-have-adhd status bar entry without disabling the mode?

Set the hideStatus configuration option to true in your extension settings. Alternatively, programmatically clear the status by calling ctx.ui.setStatus("i-have-adhd", undefined), which removes the visual indicator while preserving the underlying ADHD-friendly formatting rules in the conversation context.

What Pi command toggles the status bar indicator?

Use the slash commands /i-have-adhd on to enable the mode and display the green dot with "ADHD ON" text, or /i-have-adhd off to disable the mode and clear the status entry. These commands trigger the setEnabled function in extensions/i-have-adhd.ts which updates both the internal state and the visual indicator.

Why does the status bar show "ADHD ON" immediately when I restore a Pi session?

The restoreState function in extensions/i-have-adhd.ts (lines 61-70) evaluates your previous session state, configuration files, and persistent markers during initialization. If it detects that ADHD mode should be active, it immediately calls updateStatus to synchronize the visual indicator with the restored context state.

Can other extensions modify the i-have-adhd status bar entry?

Yes, any extension with access to the Pi UI context can interact with this status entry using the reserved key. For example, another extension could trigger the mode programmatically via pi.sendCommand("i-have-adhd", "on") or directly manipulate the display using ctx.ui.setStatus("i-have-adhd", customLabel), though this is generally discouraged to avoid conflicting state management.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →