# The Mirror — Kalei's Notebook Feature

## Scientific Foundation

The Mirror is Kalei's most direct application of attention and neuroscience research.

**Selective Attention as the Core Mechanism:** Yantis (2008) showed that selective attention operates through modulatory signals that amplify relevant information and suppress irrelevant inputs. The Mirror externalizes this process — Kalei's AI acts as an attentional amplifier, highlighting cognitive patterns the user's own system has habituated to and stopped noticing. The highlighted fragments aren't new information; they're existing patterns made visible through redirected attention.

**Attention Is Trainable:** Stevens & Bavelier (2012) demonstrated that attentional control improves with practice and transfers across domains. Regular Mirror use trains the user to notice their own cognitive distortions — first with AI assistance, eventually independently. The Spectrum's "self-correction rate" metric (Phase 2) directly measures this training effect.

**Attention vs. Consciousness:** Koch & Tsuchiya's distinction between attention and consciousness is operationally important. The Mirror works at the attention level: it doesn't require the user to be consciously aware of their patterns (consciousness) — it simply redirects attention toward them. The conscious recognition follows naturally.

**Habit Formation Through Consistent Practice:** Wood & Neal (2007) showed that habits form through context-response associations. Regular Mirror sessions — anchored to consistent contexts (time of day, emotional state) — train the habit of reflective self-examination until it becomes automatic.

---

## The Concept

The Kaleidoscope (Turn) is structured: one fragment in, patterns out. It works when you **know** what's bothering you.

But most of the time, people don't. They're carrying a vague heaviness — a bad day, an argument replaying in their head, a worry they can't articulate. They don't need a tool yet. They need a space to **think out loud** first.

**The Mirror** is that space.

It's a freeform notebook with a chat-like interface where you write whatever's on your mind — stream of consciousness, venting, processing. As you write, Kalei's AI reads along quietly and does two things:

1. **Highlights fragments** — gently underlines or marks phrases that carry negative cognitive patterns (catastrophizing, black-and-white thinking, personalization, fortune-telling, etc.)
2. **Offers to Turn them** — tapping a highlighted fragment opens a mini-reframe inline, without leaving the flow of writing

You're not journaling into a void. You're writing into a mirror that reflects back what you can't see yourself.

---

## Why "The Mirror"

A kaleidoscope is built from mirrors. The mirrors are what create the symmetry — what take a random fragment and reveal the pattern. Without the mirrors, it's just broken glass.

The Mirror feature is the reflective surface of Kalei. The Kaleidoscope (Turn) is the active tool. The Mirror is the quiet awareness that makes the tool work.

**Metaphor alignment:**
- You write freely → you're pouring fragments onto the table
- Kalei highlights patterns → the mirror reflects back what you couldn't see
- You tap to reframe → you choose which fragments to Turn
- The session becomes a Reflection → saved to your Gallery with its own pattern

---

## How It Works — User Flow

### Entry Point

The Mirror lives as the **fifth element** in the app's navigation, or as a secondary action within the Turn tab. Two options:

**Option A — Dedicated tab (recommended):**

| Icon | Label | Function |
|------|-------|----------|
| ◇ | **Turn** | Quick structured reframe |
| ✦ | **Mirror** | Freeform notebook with AI awareness |
| ◎ | **Lens** | Manifestation Engine |
| ▦ | **Gallery** | History of patterns and reflections |
| ● | **You** | Profile and settings |

**Option B — Nested under Turn:**
Turn tab has two modes: "Quick Turn" (current structured input) and "Open Mirror" (freeform). Toggle at top.

**Recommendation:** Option A. The Mirror is different enough in intent and behavior that it deserves its own space. Users will develop separate habits — quick Turns for specific thoughts, Mirror sessions for processing.

### The Writing Experience

**Visual:** Chat-style interface. The user's messages appear as bubbles or blocks on one side. Clean, minimal, dark background consistent with Kalei's aesthetic. No AI responses appear unprompted — the AI is **listening**, not talking.

**Prompt on empty state:**
> "Start writing. Say whatever's on your mind. I'll listen."
> *Kalei will gently highlight patterns it notices. You decide what to do with them.*

**User writes freely.** They can send multiple messages in sequence, like texting a friend or writing in a stream. No character limits. No structure required. Just write.

### The Highlighting — "Fragment Detection"

As the user writes (or after each message is sent), Kalei's AI analyzes the text for **cognitive distortion patterns** — the same patterns that cognitive behavioral therapy identifies as drivers of negative thinking:

| Distortion | Example | What Kalei detects |
|---|---|---|
| Catastrophizing | "This is going to ruin everything" | Absolutist prediction language |
| Black-and-white thinking | "I always fail at this" | Always/never, all-or-nothing |
| Mind reading | "They probably think I'm an idiot" | Assuming others' thoughts |
| Fortune telling | "This will never get better" | Predicting negative outcomes |
| Personalization | "It's all my fault" | Taking undue responsibility |
| Discounting positives | "That win was just luck" | Minimizing good things |
| Emotional reasoning | "I feel like a failure so I must be one" | Feelings presented as facts |
| Should statements | "I should be further along by now" | Rigid self-imposed rules |
| Labeling | "I'm such a loser" | Identity-level negative labels |
| Overgeneralization | "Nothing ever works out for me" | One event → universal pattern |

**How highlighting appears:**

- Detected phrases get a **subtle underline or soft glow** in a warm amber/gold color — the color of light catching a fragment
- The highlight is gentle, not aggressive. It shouldn't feel like a red pen correcting homework. It should feel like sunlight falling on a piece of glass — drawing attention naturally
- A small **◇ icon** (fragment symbol) appears at the end of the highlighted phrase, indicating this fragment can be Turned
- Highlights appear **after the user finishes a message** (not while typing — that would be intrusive and anxiety-inducing)

**Critical UX principle:** The highlighting must feel like **noticing**, not **judging**. The AI is a mirror, not a critic. The user should feel seen, not corrected. This distinction is scientifically grounded — Bandura (1977) showed that perceived criticism undermines self-efficacy, while neutral observation preserves it. The Mirror builds capability awareness, not self-judgment.

### Tapping a Fragment — Inline Reframing

When the user taps a highlighted fragment:

1. A **mini-card slides up** from below (half-sheet modal, not full screen — user can still see their writing above)
2. The card shows:
   - The original fragment, quoted
   - The cognitive pattern name in plain language (e.g., "This sounds like catastrophizing — predicting the worst outcome")
   - **1–2 reframed alternatives** — shorter and lighter than a full Turn, designed for quick insight
   - A "Full Turn" button if they want to take this fragment into the Kaleidoscope for deeper exploration
   - A "Dismiss" option — user can say "I see it, moving on" without reframing

**Example interaction:**

> **User writes:** "Had a terrible meeting today. My manager barely acknowledged my presentation. She probably thinks I'm not cut out for this role. I should just start looking for another job."

> **Kalei highlights:** "She probably thinks I'm not cut out for this role"

> **User taps the highlight. Card appears:**

> **◇ Fragment detected**
> *"She probably thinks I'm not cut out for this role"*
>
> This looks like **mind reading** — assuming someone else's thoughts without evidence.
>
> **A different angle:**
> There are many reasons a manager might seem distracted that have nothing to do with your performance. What you observed was her behavior. What she thinks is something you don't have access to yet — but you could ask.
>
> **[Full Turn ◇]** · **[Dismiss]**

### The AI's Role — Passive, Not Conversational

**This is critical.** The Mirror is NOT a chatbot. The AI does not:
- Respond to every message
- Ask follow-up questions unprompted
- Inject unsolicited advice
- Break the user's flow with interjections

The AI **only** does three things:
1. Highlights fragments (passively, after each message)
2. Provides reframes when the user taps a highlight (on demand)
3. Generates a session summary when the user ends the session (see below)

**Why not make it a chatbot?** Because the whole point is that the user is thinking out loud. Inserting AI responses between every message turns it into a conversation with a bot, which changes the psychology entirely. The user stops introspecting and starts performing. The Mirror should feel like writing in a journal that occasionally catches the light — not like talking to a therapist.

**Exception — The Nudge:** If the user has written 5+ messages with zero taps on any highlights and significant negative patterns are accumulating, Kalei can offer ONE gentle nudge at the end of the stream:

> "I noticed a few fragments in what you wrote. Want to look at them together?"
> **[Show me]** · **[Not now]**

This is the only time the AI initiates. Once per session maximum.

---

## Session Wrap-Up — The Reflection

When the user signals they're done writing (closes the Mirror, presses a "Done" button, or after a period of inactivity), Kalei generates a **Reflection** — a brief session summary.

**The Reflection includes:**

1. **The Mosaic** — a high-level summary of what the user wrote about (themes, not specifics)
   > "Today's Mirror covered: work frustration, self-doubt about career, and a conflict with your manager."

2. **Fragments Found** — count of cognitive patterns detected
   > "4 fragments noticed. You explored 2 of them."

3. **Patterns Revealed** — the reframes the user chose to engage with
   > "You looked at mind reading and catastrophizing from new angles."

4. **A Generated Pattern** — a unique kaleidoscope visual for this session, saved to the Gallery alongside their Turn patterns. Mirror sessions get their own visual style — perhaps slightly different geometry (softer, more organic) to distinguish them from structured Turns

5. **An optional one-line insight** — the AI's single most important observation from the session
   > "You were hardest on yourself about things you haven't confirmed are true."

**The Reflection is saved to the Gallery** as a distinct type: a Mirror Reflection. Users can revisit their sessions, re-read what they wrote, see which fragments they explored, and track how their patterns evolve over time.

---

## Where the Mirror Fits in the User's Journey

The three core features now form a **progression**:

```
THE MIRROR          THE KALEIDOSCOPE         THE LENS
(Awareness)    →    (Perspective)       →    (Direction)

"What am I          "How else can I           "What am I
 feeling?"           see this?"                building toward?"

Freeform            Structured                Goal-focused
writing             reframing                 manifestation

Fragments           Fragments → Patterns      Patterns → Focus
detected            revealed                  applied
```

**The natural user flow:**

1. **Mirror** — User dumps their raw thoughts. AI highlights the fragments they can't see themselves
2. **Turn** — User takes the most charged fragment and gives it a full Turn in the Kaleidoscope, getting deep, multi-angle reframes
3. **Lens** — The insights from reframing inform the user's goals. What they thought was a setback becomes fuel for what they're building toward

Not every session follows this sequence. Some days you just need a quick Turn. Some days you just need to write in the Mirror. Some days you go straight to the Lens. But when a user does flow through all three, that's the **Kalei experience** at its deepest.

---

## Engagement & Retention Mechanics

### Mirror Streaks

Track separately from Turn streaks:
- "You've written in the Mirror 5 days in a row"
- Mirror sessions tend to be longer and more personal → higher engagement signal

**Science note:** Wood et al. (2021) found that context stability is the single biggest predictor of habit formation. Mirror streaks should track not just frequency but context consistency — "You've written in the Mirror at roughly the same time for 14 days" is a stronger habit signal than "14 sessions total across random times."

### Fragment Tracking Over Time

The Gallery can show **fragment patterns over time**:
- "This month, your most common fragment type was **should statements**"
- "You've reduced catastrophizing by 40% compared to last month"
- A visual "spectrum" chart showing which cognitive distortions appear most frequently

This turns the Mirror from a journal into a **self-awareness engine**. Users can literally see their thinking patterns change over time.

**Science note:** This longitudinal tracking implements Stevens & Bavelier's (2012) finding that attention training transfers and compounds. The fragment density decline over time is a measurable proxy for improved attentional self-awareness — the user is literally catching patterns earlier and more often because their attentional system has been retrained.

### Mirror Prompts

For days when the user opens the Mirror but doesn't know what to write:
- "What happened today that you're still thinking about?"
- "What would you say to a friend if they were feeling what you're feeling?"
- "What's one thing you're avoiding thinking about?"
- "Describe your mood in a sentence. Then ask yourself why."

These are optional, dismissible, and only shown on empty-state.

---

## Monetization Placement

| Feature | Free (Kalei) | Premium (Kalei Prism) |
|---|---|---|
| Mirror access | 2 sessions/week | Unlimited |
| Fragment highlighting | Basic (3 distortion types) | Full spectrum (all 10 types) |
| Inline reframes | 1 per session | Unlimited |
| Session Reflections | Summary only | Full Reflection with insight |
| Fragment tracking over time | ✗ | ✓ |
| Export Mirror sessions | ✗ | ✓ |

The free tier gives enough Mirror access to experience the value. The paywall hits at the point where the user wants **depth and consistency** — which is exactly when they're most likely to convert.

---

## Technical Implementation Notes

### AI Processing Pipeline

Each message the user sends in the Mirror triggers a lightweight AI analysis:

```
User message → Claude API call → Returns:
{
  "fragments": [
    {
      "text": "She probably thinks I'm not cut out for this role",
      "start_index": 89,
      "end_index": 143,
      "distortion_type": "mind_reading",
      "distortion_label": "Mind reading",
      "distortion_description": "Assuming someone else's thoughts without evidence",
      "confidence": 0.87
    }
  ]
}
```

**Confidence threshold:** Only highlight fragments with confidence > 0.75 to avoid false positives. A false positive (highlighting something that isn't actually distorted thinking) would erode trust quickly.

**Latency:** Analysis should complete within 1–2 seconds after message sent. Highlights appear with a subtle fade-in animation — fragments "catching the light."

### Reframe Generation (On Tap)

When user taps a highlighted fragment, a second API call generates the inline reframe:

```
Input: fragment text + surrounding context + distortion type
Output: {
  "distortion_explanation": "Plain language explanation",
  "reframe": "1-2 sentence alternative perspective",
  "full_turn_prompt": "Pre-filled prompt for Kaleidoscope if user wants deeper exploration"
}
```

### Data Storage

Mirror sessions stored in Supabase:

```sql
-- Mirror sessions table
CREATE TABLE mirror_sessions (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID REFERENCES users(id),
  started_at TIMESTAMPTZ DEFAULT NOW(),
  ended_at TIMESTAMPTZ,
  reflection_summary TEXT,
  reflection_insight TEXT,
  pattern_seed TEXT, -- for generating the visual pattern
  created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Mirror messages table
CREATE TABLE mirror_messages (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  session_id UUID REFERENCES mirror_sessions(id),
  content TEXT NOT NULL,
  sequence_order INTEGER,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Detected fragments within messages
CREATE TABLE mirror_fragments (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  message_id UUID REFERENCES mirror_messages(id),
  fragment_text TEXT NOT NULL,
  start_index INTEGER,
  end_index INTEGER,
  distortion_type VARCHAR(50),
  confidence FLOAT,
  was_tapped BOOLEAN DEFAULT FALSE,
  was_reframed BOOLEAN DEFAULT FALSE,
  reframe_text TEXT,
  created_at TIMESTAMPTZ DEFAULT NOW()
);
```

### Privacy & Sensitivity

Mirror content is the most personal data in the app. Requirements:

- **End-to-end encryption** for all Mirror content at rest
- **No Mirror content used for model training** — explicit policy
- **Local-first option** (future): Allow users to keep Mirror data on-device only
- **Easy deletion**: User can delete any session or all Mirror data
- **Content safety**: If AI detects crisis language (self-harm, suicidal ideation), surface crisis resources immediately — not as a highlight/reframe, but as a dedicated intervention with hotline numbers and a warm handoff message

---

## Updated App Structure

With the Mirror, Kalei now has three pillars that map to a complete mental model:

| Pillar | Feature | Metaphor | User need | Interaction style |
|--------|---------|----------|-----------|-------------------|
| **Awareness** | The Mirror | Reflective surface that shows you your fragments | "I need to process" | Freeform writing, passive AI |
| **Perspective** | The Kaleidoscope | The turn that reveals patterns in fragments | "I need to see this differently" | Structured input → output |
| **Direction** | The Lens | Focused vision toward what you're building | "I need to move forward" | Goal setting, affirmations, tracking |

**Together:** You become aware of your patterns (Mirror), you learn to see them differently (Kaleidoscope), and you channel that clarity into what you're building (Lens).

**Tagline still holds:** *Same pieces. New angle.*

**Elevator pitch (updated):**
> "Kalei is a kaleidoscope for your mind. Write freely in the Mirror and Kalei gently highlights the negative thinking patterns you can't see yourself. Take any thought into the Kaleidoscope and see it from entirely new angles. Then focus your clarity through the Lens toward the goals that matter to you. Same pieces. New angle. That's Kalei."

---

*The mirror doesn't tell you what to see. It shows you what's already there.*
