# Plan 31-01: Bug Fixes

**Phase:** 31 — Bug Fixes
**Goal:** Plugin version number is displayed correctly; meaningless "ai" UI element is removed.
**Depends on:** Nothing
**Requirements:** NAV-02, NAV-03

## Tasks

### Task 1: Add paperforge_version to canonical index envelope

**File:** `paperforge/worker/asset_index.py`
**Function:** `build_envelope()`
**Change:** Add `paperforge_version` field to the envelope dict.

```python
from paperforge import __version__

def build_envelope(items: list[dict]) -> dict:
    return {
        "schema_version": CURRENT_SCHEMA_VERSION,
        "generated_at": datetime.now(timezone(timedelta(hours=8))).isoformat(),
        "paper_count": len(items),
        "paperforge_version": __version__,       # <-- NEW
        "items": items,
    }
```

**Verification:**
1. Run `python -c "from paperforge.worker.asset_index import build_envelope; e = build_envelope([]); print(e.get('paperforge_version'))"` — must print a valid semver string like `1.8.0`.
2. Run `paperforge sync --index --verbose` or trigger index rebuild — check generated `formal-library.json` contains `"paperforge_version": "1.8.0"`.
3. Plugin dashboard header shows `v1.8.0` (not `v—`).

### Task 2: Remove "ai" UI element from plugin dashboard

**Approach:** Code audit to identify the exact element, then surgical removal.

**Audit plan:**
1. Open plugin in Obsidian with Research_LitControl library (or any vault with papers).
2. Search rendered HTML for any element containing "ai" that appears as a standalone row/line/section.
3. Grep plugin source for likely candidates:
   - `grep -n 'ai_ready\|AI Ready\|ai_' paperforge/plugin/main.js`
   - `grep -n 'ai_ready\|AI Ready\|ai_' paperforge/plugin/_styles.css`
4. Identify which element the user considers meaningless.
5. Remove the rendering code for that element.

**Likely candidates:**
- `_renderLifecycleStepper`: `{ key: 'ai_ready', label: 'AI Ready' }` — if this stage always appears empty/no-op, remove it.
- `_renderBarChart`: `{ key: 'ai_ready', label: 'AI Ready', cls: 'stage-ai-ready' }` — same logic.
- Any other rendering artifact.

**Verification:**
1. Dashboard no longer shows the identified "ai" row in any mode.
2. `git grep -i 'ai.row\|ai_ready'` in `paperforge/plugin/` returns no rendering references (or the references are justified).
3. No JavaScript errors in console.

## Success Criteria

1. Plugin header shows actual PaperForge version (e.g., "v1.8.0").
2. Dashboard excludes the meaningless "ai" row across all render modes.
3. Python→JS version bridge established via envelope (NAV-02 fixed for future phases).
4. Zero regressions in existing dashboard functionality.

## Rollback

If either change breaks the dashboard:
```bash
git checkout -- paperforge/worker/asset_index.py paperforge/plugin/main.js paperforge/plugin/_styles.css
```
