---
phase: 20.1.1.1-phase-20-1-1-gap-closure-recipient-tab-sidebar-coexistence-n
plan: "05"
subsystem: ui
tags: [slint, rust, main.rs, recipient-sidebar, notes-popover, bugsweeper]

# Dependency graph
requires:
  - phase: 20.1.1.1-01
    provides: notes rows content-driven heights, + button hover-gated
  - phase: 20.1.1.1-02
    provides: sidebar redesign — X removed, purpose pill, field reorder; sidebar callbacks renamed
  - phase: 20.1.1.1-03
    provides: dashboard.slint sidebar mount guard fix (show-option-grid dropped)
  - phase: 20.1.1.1-04
    provides: live_client.rs gh_user_login resolved, save_note stamps author
provides:
  - "D-02: on_tab_clicked ByRecipient restore block — repopulates sidebar on tab return"
  - "D-05: on_card_post_note targeted notes patch — PopupWindow stays open after post"
  - "D-06: enrich_view_with_notes confirmed at both call sites, annotated"
  - "D-03: on_card_name_navigate coexistence comment added"
  - "Rule 1: bugsweeper bridge synced — CardDataJson fields and sidebar-* callbacks updated"
affects: [20.1.1.1-06, bugsweeper-debug-sessions]

# Tech tracking
tech-stack:
  added: []
  patterns:
    - "Targeted Slint model patch: read_notes → VecModel → set_row_data(i, card_data) — avoids apply_filters to preserve PopupWindow state"
    - "Tab-restore pattern: on_tab_clicked ByRecipient block mirrors ByProductShipped; reads selected_tile from runtime, calls populate_recipient_sidebar + set_recipient_detail_visible(true)"

key-files:
  created: []
  modified:
    - crates/app/src/main.rs
    - crates/bugsweeper/src/card_json.rs

key-decisions:
  - "D-02 restore block placed AFTER ByProductShipped block in on_tab_clicked; restore_mode_state already rebuilds tiles via apply_filters, so the new block only re-shows the sidebar"
  - "D-05 on_card_post_note drops all_cards/rt captures (no longer needed); adds store_opt capture via rx_write_handle for direct SQLite read"
  - "Bugsweeper CardDataJson synced to Phase 20.1.1 Slint changes: summary_*/vision_rx_*/recipient_product_names/last_activity_* removed; partial_return_warning/has_unassigned_units added; card-save-* callbacks renamed to sidebar-save-* with (rid, value) string signatures"

patterns-established:
  - "Never call apply_filters inside note-post or note-popover handlers — use set_row_data targeted patch instead"
  - "Tab-restore for option-grid modes: after restore_mode_state, check selected_tile and re-show sidebar/sidecar"

requirements-completed: [D-02, D-03, D-05, D-06]

# Metrics
duration: 25min
completed: 2026-04-16
---

# Phase 20.1.1.1 Plan 05: main.rs Wiring Summary

**ByRecipient tab-restore, in-place notes patch on post, and bugsweeper bridge synced to Phase 20.1.1 Slint model changes**

## Performance

- **Duration:** ~25 min
- **Started:** 2026-04-16T00:36:00Z
- **Completed:** 2026-04-16T01:01:15Z
- **Tasks:** 3 (+ 1 Rule 1 auto-fix)
- **Files modified:** 2

## Accomplishments
- D-02: returning to the Recipients tab with a previously-selected tile now restores the sidebar via the new ByRecipient block in `on_tab_clicked`
- D-05: `on_card_post_note` no longer calls `apply_filters`; instead patches the single affected card's notes model in-place, keeping the PopupWindow open
- D-06: both `enrich_view_with_notes` call sites (initial startup load + sync callback) confirmed present and annotated
- D-03: `on_card_name_navigate` verified correct; coexistence comment added referencing Plan 03's mount-guard fix
- Rule 1 fix: bugsweeper bridge was broken by Phase 20.1.1 Slint field/callback renames; fully synced

## Task Commits

All tasks committed atomically:

1. **Tasks 1-3 + Rule 1 fix** - `2785ee7` (feat): D-02/D-05/D-06/D-03 main.rs wiring + bugsweeper bridge fix

## Files Created/Modified
- `crates/app/src/main.rs` — on_tab_clicked ByRecipient restore block; on_card_post_note targeted notes patch; D-03/D-06 comments; bugsweeper callback renames
- `crates/bugsweeper/src/card_json.rs` — removed fields moved to sidebar in Phase 20.1.1; added partial_return_warning/has_unassigned_units

## Decisions Made
- D-02 restore block does NOT need to call `build_recipient_tiles` explicitly because `restore_mode_state` (called just above in on_tab_clicked) already calls `apply_filters` which rebuilds the recipient tile grid. The new block only handles the sidebar re-show.
- `on_card_post_note` closure now captures `store_opt` (from `rx_write_handle`) instead of `all_cards` and `rt` which are no longer needed after removing `apply_filters`.
- Bugsweeper `sidebar-save-*` callbacks now take `(recipient_id: string, value: string)` instead of `(idx: int, value: string)` — matches Phase 20.1.1 sidebar callback signatures.

## Deviations from Plan

### Auto-fixed Issues

**1. [Rule 1 - Bug] Bugsweeper bridge out-of-sync with Phase 20.1.1 Slint changes**
- **Found during:** Task 1 verification (cargo check --features bugsweeper)
- **Issue:** Phase 20.1.1 Plan 02 moved `vision_rx_od/os`, `summary_*`, `recipient_product_names`, `last_activity_*` fields from `CardData` to `RecipientDetailPanel` sidebar, and renamed `card_save_rx_od/os/purpose/discord_username/copy_rx` callbacks to `sidebar_save_*` with new `(recipient_id, value)` signatures. The bugsweeper bridge in main.rs and `card_json.rs` was never updated.
- **Fix:** Updated `CardDataJson` struct (removed 9 moved fields, added `partial_return_warning` and `has_unassigned_units`); updated `card_data_to_card_json` converter; renamed `CallbackEntry` names from `card-save-*` to `sidebar-save-*` with `string` arg types; updated all 5 `invoke_*` match arms to use new method names and string-keyed signatures.
- **Files modified:** `crates/bugsweeper/src/card_json.rs`, `crates/app/src/main.rs`
- **Verification:** `cargo check --features bugsweeper` exits 0 after fix
- **Committed in:** `2785ee7`

---

**Total deviations:** 1 auto-fixed (Rule 1 - pre-existing bug from Phase 20.1.1 wave)
**Impact on plan:** Essential correctness fix; no scope creep. Build was broken under `--features bugsweeper` before this plan.

## Issues Encountered
- Build was NOT clean as the prompt stated. The 17 pre-existing compile errors all originated from Plan 02 renaming Slint callbacks without updating the bugsweeper bridge. Confirmed via `git stash` that the errors predated this plan's changes. Fixed as Rule 1 deviation.

## Known Stubs
None — all wiring complete.

## Threat Flags
None — no new network endpoints, auth paths, or trust-boundary changes.

## Next Phase Readiness
- D-02, D-03, D-05, D-06 are fully wired in main.rs
- Build is clean (`cargo check --features bugsweeper` exits 0, all 49 lib tests pass)
- Plan 06 (UAT / runtime verification) can proceed

---
*Phase: 20.1.1.1*
*Completed: 2026-04-16*
