Five-slice navigable map of the entire codebase under
docs/architecture-map/. Each slice is a self-contained
breadcrumbed sub-tree:
01-frontend (16) Svelte/SvelteKit UI
02-tauri-runtime (26) src-tauri commands + lifecycle
03-audio-transcription (16) audio + transcription crates
04-llm-formatting-mcp (19) llm, ai-formatting, mcp, cloud
05-core-storage-hotkey-build core, storage, hotkey, workspace,
(26) CI, dev glue
Plus master README.md and data-flow-end-to-end.md tracing
audio bytes from microphone to FTS5 search to MCP read.
Generated by 5 parallel subagents on 2026/05/09 against
HEAD 3c47000. Each page has YAML frontmatter, file:line code
refs, sibling cross-links, plain-English summaries.
Aggregated debt surfaced (full lists in master README):
RB-08 macOS power assertion, schema head drift v14 vs v15,
VAD blocked on ort version conflict, streaming primitives
not wired into live.rs, no prompt versioning, MCP has no
auth, cloud-providers in-memory keystore, SettingsPage
2 484 LOC, commands/live.rs 1 737 LOC, dual theme system,
brand rename to Lumenote pending across the codebase.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
79 lines
4.3 KiB
Markdown
79 lines
4.3 KiB
Markdown
---
|
|
name: HITL feedback
|
|
type: architecture-map-page
|
|
slice: 02-tauri-runtime
|
|
last_verified: 2026/05/09
|
|
---
|
|
|
|
# `commands::feedback`
|
|
|
|
> **Where you are:** [Architecture map](../../README.md) → [Tauri runtime](../README.md) → [Commands](README.md) → Feedback
|
|
|
|
**Plain English summary.** Phase 2: thumbs + correction capture on AI-generated output (microsteps from a task decomposition, task lines extracted from a transcript, or LLM cleanup). The captured rows feed a few-shot loop: subsequent prompts are conditioned on the user's preferred style by injecting the (input, preferred-output) pairs as exemplars.
|
|
|
|
## At a glance
|
|
|
|
- Path: `src-tauri/src/commands/feedback.rs`.
|
|
- LOC: 110.
|
|
- Tauri commands exposed:
|
|
- `record_feedback(state, input: RecordFeedbackInput) -> Result<i64, String>` — returns the new row id.
|
|
- `list_feedback_examples_cmd(state, target_type, limit, min_rating, profile_id) -> Result<Vec<FeedbackDto>, String>`.
|
|
- Events emitted: none.
|
|
- Depends on: `magnotia_storage::{record_feedback, list_feedback_examples, FeedbackRow, FeedbackTargetType, RecordFeedbackParams}`.
|
|
- Called from frontend at: dictation result panel (thumb up/down + correction-text on cleanup); Tasks page (thumb on extracted tasks and decomposed microsteps).
|
|
|
|
## What's in here
|
|
|
|
### `RecordFeedbackInput` (`src-tauri/src/commands/feedback.rs:15`)
|
|
|
|
Frontend-supplied shape:
|
|
|
|
- `targetType`: `"microstep" | "task_extraction" | "cleanup"`. Parsed via `FeedbackTargetType::parse`.
|
|
- `targetId`: optional surface-specific id (subtask id, task id, transcript id).
|
|
- `rating`: `-1` (thumbs down), `0` (correction, neutral), `+1` (thumbs up).
|
|
- `originalText`: the AI-generated text the user is rating.
|
|
- `correctedText`: the user's preferred text (when they corrected it).
|
|
- `contextJson`: freeform JSON used by the prompt builder later to reconstruct the (input, preferred-output) pair.
|
|
- `profileId`: scopes the row.
|
|
|
|
### `FeedbackDto` (`:38`)
|
|
|
|
camelCase mirror of `FeedbackRow`. Note `rating` widens to `i64` in the DTO (storage uses `i64`).
|
|
|
|
### `parse_target_type` (`:68`)
|
|
|
|
Wraps `FeedbackTargetType::parse(raw)`, returning `"unknown feedback target_type: <raw>"` on miss.
|
|
|
|
### `record_feedback` (`:73`)
|
|
|
|
`parse_target_type` then `db_record_feedback`. Returns the row id.
|
|
|
|
### `list_feedback_examples_cmd` (`:95`)
|
|
|
|
Clamps `limit` to `[1, 64]`, defaults 8. Clamps `min_rating` to `[-1, 1]`, default 0. Calls `db_list_feedback_examples`. Returns `FeedbackDto`s. Used by the `commands::tasks` few-shot exemplar pull and would be used by the equivalent in `commands::llm` if/when cleanup gets its own exemplar path.
|
|
|
|
## Data flow
|
|
|
|
```
|
|
dictation result thumbs-up -> invoke('record_feedback', { targetType: 'cleanup', rating: +1, originalText, correctedText, contextJson, profileId })
|
|
-> magnotia_storage::record_feedback -> row id
|
|
|
|
decomposition thumbs-down + correction -> record_feedback({ targetType: 'microstep', rating: 0, originalText, correctedText: "user's preferred wording", contextJson: {parent_text}, profileId })
|
|
|
|
next decompose call -> list_feedback_examples_cmd('microstep', 5, 0, profile_id)
|
|
-> [FeedbackDto, ...] -> few-shot exemplars
|
|
```
|
|
|
|
## Watch-outs
|
|
|
|
- **No `ensure_main_window` guard.** Tasks float and History viewer secondary windows can also fire feedback. Intentional. If you ever want to lock down feedback writes, this is where to add the guard.
|
|
- **`contextJson` is freeform.** Storage stores the raw string. `commands::tasks::to_llm_examples` parses it and skips rows that are malformed. Bad data therefore degrades gracefully but doesn't surface to the user. The `eprintln!` in `to_llm_examples` is the only visibility.
|
|
- **`min_rating` clamp is `[-1, 1]`.** Pass `1` to get only thumbs-up examples, `0` for thumbs-up + corrections, `-1` for everything. The default of `0` is what `commands::tasks` picks.
|
|
- **No deduplication.** A user thumbs-upping the same output twice creates two rows. The exemplar trim in `commands::tasks` does not dedupe by `originalText`. If two identical exemplars steal slots, that's just lost prompt budget.
|
|
|
|
## See also
|
|
|
|
- [Tasks](tasks.md) — the consumer of `list_feedback_examples_cmd`.
|
|
- [LLM](llm.md) — the cleanup path that produces the text that thumbs-up/down feedback rates.
|
|
- [Profiles](profiles.md) — `profileId` is the scoping key.
|