Skip to content

Chat knows which note is open (focus note) - #262

Open
samkeen wants to merge 3 commits into
chat/edits-adrfrom
chat/focus-note-2
Open

samkeen wants to merge 3 commits into
chat/edits-adrfrom
chat/focus-note-2

Conversation

@samkeen

@samkeen samkeen commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Reading a note with the chat pane open and asking "can you clean up this doc" got "I don't find that in your notes", because chat was sent only the question and the history. Step one of #255 (ADR-0023).

What changed

  • Engine. Vault::ask takes an optional focus note (chat::FocusRequest { note, max_passages }). Its passages are numbered first, retrieval at ASK_PASSAGES fills the rest minus repeats, the grounded prompt and the condense prompt name the note, and the answer prompt tells the model that work on the note (clean up, summarise, rewrite) is a task on its text, not a question to refuse. That last sentence is ported from PR #254's 821fd33, where it was reproduced against the real vault with gemma4. If the cap trimmed the note, the prompt says how many of its passages were included. With no focus the request is byte-identical to before (pinned by a test).
  • Cap, configurable and loud. B2_LLM_FOCUS_PASSAGES (1 to 64, default 8) and a "Focus passages" field in Settings → Chat, following the tool-call cap's three-state pattern.
  • CLI. b2 ask --note PATH and b2 chat --note PATH.
  • Desktop. The ask command passes the open note; the pane shows an "about: <title>" chip so what the model was told is visible.
  • Docs. quickstart.md (flag and env var), index-engine.md §6.

Judgment calls

  • A focused request carries up to 8 focus passages plus 10 retrieved, so 18 at most instead of 10. PR 6's eval should confirm the default model handles it.
  • #254 used a default of 24 focus passages; this branch uses 8 with the cap configurable.

Not verified

The real-app check: "clean up this doc" answering about the open note under make app with gemma4.

Fixes #253

🤖 Generated with Claude Code

samkeen and others added 3 commits November 8, 2026 12:41
"Clean up this doc" got "I don't find that in your notes" because ask
retrieved by the question text alone. Vault::ask now takes an optional
focus note. Its first FOCUS_PASSAGES (8) passages are numbered first,
retrieval at ASK_PASSAGES fills in behind them minus repeats, and the
grounded and condense prompts both say the user is viewing that path.
A note longer than the cap adds one line saying how many of its
passages were included. With no focus the request is unchanged, pinned
by a recording-provider test against the request spelled out field by
field.

- CLI: `b2 ask --note PATH` and `b2 chat --note PATH`; --json unchanged.
- Desktop: the ask command takes `focus`; the pane sends the open
  note's path and shows an "about: <title>" chip by the composer.
- Docs: quickstart documents --note; index-engine flow 4 and the
  constants table gain the focus step and FOCUS_PASSAGES.

Fixes #253

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A cap is configurable and loud, so the focus note's passage cap gets
the same treatment as the tool-call cap. Vault::ask now takes a
chat::FocusRequest { note, max_passages } instead of a bare path, and
FOCUS_PASSAGES stays as the default. A test proves a smaller cap takes
the same opening passages and the trim line follows it.

- b2-llm: LlmConfig::focus_passages, B2_LLM_FOCUS_PASSAGES (1 to 64,
  default 8), parse_focus_passages, with_focus_passages. ToolCallCap
  becomes CapSetting so both caps share one view, and ChatSetup carries
  focus_passages for Settings.
- CLI: ask and chat read the cap from LlmConfig (env only).
- Desktop: ChatPrefs::focus_passages with the three-state apply rule
  shared with the tool-call cap; ask passes the cap in force.
- UI: a "Focus passages" field beside "Tool calls per reply", judged by
  focusCapInput.
- quickstart documents B2_LLM_FOCUS_PASSAGES.

Part of #253

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…fuse

Ported from PR #254's 821fd33, which recorded the finding on the user's
vault: with every passage of the open note present, gemma4 still
answered "I don't find that in your notes" to "clean up this note",
because the grounded prompt frames everything as a question the
passages must answer. When the focus note has text, the grounded
prompt now adds one sentence saying a request to summarise, clean up,
rewrite, outline or shorten the note is a task to do with its text,
and to keep the no-evidence reply for questions the passages don't
cover. The condense prompt and the no-focus request are unchanged.

Part of #253

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant