# How the i-have-adhd Plugin Handles the Stop ADHD Mode Command Across Different UIs

> Discover how the i-have-adhd plugin's stop ADHD mode command works seamlessly across UIs and API contexts. Learn about its unified approach and natural language processing.

- Repository: [Ayoub Ghriss/i-have-adhd](https://github.com/ayghri/i-have-adhd)
- Tags: how-to-guide
- Published: 2026-08-19

---

**The i-have-adhd extension implements a unified stop ADHD mode mechanism that works in both UI-driven environments and headless API contexts by detecting specific commands and natural-language phrases, then returning appropriate responses based on the presence of a UI.**

The ayghri/i-have-adhd plugin provides ADHD-friendly formatting rules for AI conversations. When users need to disable these accommodations, the plugin offers multiple ways to trigger the stop ADHD mode command, adapting its behavior to whether it's running in a graphical interface or a stateless API environment.

## Command Aliases and Explicit Syntax

The plugin registers the `/i-have-adhd` slash command to give users direct control over the feature state.

### Using the Slash Command

Users can explicitly manage the mode through command arguments:

- `/i-have-adhd off` or `/i-have-adhd stop` → disables the mode
- `/i-have-adhd on` → enables the mode
- `/i-have-adhd` (bare command) → toggles the current state

In [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts), the handler normalizes the input using `args.trim().toLowerCase()` and forwards the request to `setEnabled(false, ctx)` when the argument matches `"off"` or `"stop"`【/cache/repos/github.com/ayghri/i-have-adhd/main/extensions/i-have-adhd.ts#L72-L87】. This normalization ensures the command works regardless of capitalization or extra whitespace.

## Natural-Language Detection for Conversational Interfaces

Beyond explicit commands, the plugin recognizes conversational phrases to disable the mode.

### The STOP_PHRASES Set

The extension defines a `Set` called `STOP_PHRASES` containing `"stop adhd mode"` and `"normal mode"` at lines 27-28 of the main extension file【/cache/repos/github.com/ayghri/i-have-adhd/main/extensions/i-have-adhd.ts#L27-L28】.

Every incoming user message triggers the `pi.on("input")` hook. This hook lower-cases the text and performs two checks:

1. If the message matches the built-in skill alias `"/skill:i-have-adhd"`, it enables the mode
2. If the mode is currently **enabled** and the normalized text exists in `STOP_PHRASES`, the plugin calls `setEnabled(false, ctx)`【/cache/repos/github.com/ayghri/i-have-adhd/main/extensions/i-have-adhd.ts#L99-L105】

This allows users to exit ADHD mode naturally without memorizing specific syntax.

## Differentiated Response Handling for UI vs. Headless Environments

After disabling the mode, the plugin branches based on the execution context through the `ctx.hasUI` property.

### UI-Enabled Contexts (ctx.hasUI)

When a graphical interface is present, the handler returns `{ action: "handled" }` to swallow the user's stop phrase. This prevents the UI from forwarding the command text to the underlying model. Simultaneously, it displays a toast notification via `ctx.ui.notify` showing **"ADHD mode disabled."**【/cache/repos/github.com/ayghri/i-have-adhd/main/extensions/i-have-adhd.ts#L106-L113】.

### API and Headless Contexts

For environments without a UI (such as direct API calls), the plugin returns a transformation object that forces the model to reply with the exact confirmation string defined in the `DISABLE_CONFIRMATION` constant: `"ADHD mode disabled."`【/cache/repos/github.com/ayghri/i-have-adhd/main/extensions/i-have-adhd.ts#L124-L131】. This guarantees clients receive clear acknowledgement even without visual interface elements.

## State Persistence Across Sessions

The plugin ensures that triggering the stop ADHD mode command survives session reloads. It stores the current state using the `STATE_ENTRY_TYPE` constant defined as `"i-have-adhd-state"`. On subsequent session events including `session_start` and `session_tree`, the extension retrieves this custom session entry and restores the saved value【/cache/repos/github.com/ayghri/i-have-adhd/main/extensions/i-have-adhd.ts#L144-L152】.

## Implementation Examples

**Explicit command in UI console:**

```text
/i-have-adhd off

```

The UI displays a toast notification and intercepts the command before it reaches the model.

**Natural language in chat (UI):**

```text
Stop ADHD mode

```

The interface detects the phrase, disables the mode, and suppresses the message from being sent to the AI.

**Natural phrase via API:**

```json
{
  "text": "stop adhd mode"
}

```

Response payload:

```json
{
  "text": "ADHD mode disabled."
}

```

**Re-enabling the mode:**

```text
/i-have-adhd on

```

## Summary

- The stop ADHD mode command is implemented in [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts) with support for both explicit slash commands and natural-language phrases
- The `STOP_PHRASES` Set contains `"stop adhd mode"` and `"normal mode"` for conversational detection
- UI environments receive `{ action: "handled" }` and visual notifications via `ctx.ui.notify`
- Headless contexts return forced transformation objects containing the `DISABLE_CONFIRMATION` string
- State persists across sessions through the `STATE_ENTRY_TYPE` custom entry mechanism
- The `hooks/always-on.mjs` file ensures this logic loads for every session while [`skills/i-have-adhd/SKILL.md`](https://github.com/ayghri/i-have-adhd/blob/main/skills/i-have-adhd/SKILL.md) contains the rule set being toggled

## Frequently Asked Questions

### What file contains the stop ADHD mode logic?

The core implementation resides in [`extensions/i-have-adhd.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/i-have-adhd.ts). This file handles command parsing, natural-language detection through the `STOP_PHRASES` Set, environment-specific responses, and state persistence. Additional support comes from [`extensions/context-compat.ts`](https://github.com/ayghri/i-have-adhd/blob/main/extensions/context-compat.ts) for context synchronization and `hooks/always-on.mjs` for guaranteed loading.

### How does the plugin distinguish between UI and API environments?

The plugin checks the `ctx.hasUI` boolean property after calling `setEnabled(false, ctx)`. When **true**, it returns `{ action: "handled" }` and triggers `ctx.ui.notify`. When **false**, it returns a transformation object containing the `DISABLE_CONFIRMATION` message, ensuring API clients receive text feedback without graphical elements.

### Can I use natural language to stop ADHD mode?

Yes. The plugin recognizes `"stop adhd mode"` and `"normal mode"` through the `pi.on("input")` event hook. These phrases are stored in the `STOP_PHRASES` Set and checked against every incoming message when the mode is currently enabled, allowing conversational deactivation without slash commands.

### Does the disabled state persist across chat sessions?

Yes. The plugin stores the boolean state using the `STATE_ENTRY_TYPE` constant (`"i-have-adhd-state"`) as a custom session entry. During `session_start` and `session_tree` events, the extension restores this value, ensuring that triggering the stop command in one session maintains the disabled status in subsequent reloads.