Show source-note buttons: link answers back to SilverBullet pages #4
Labels
No labels
epic
in-review
ready-for-agent
ready-for-human
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
weiwen/evie#4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
After an answer, attach inline URL buttons that deep-link to the SilverBullet pages pi touched, so you can jump from an answer to the note it read or updated.
Key finding — not blocked
The note parked this as "blocked: pi doesn't emit source metadata." That's wrong: pi emits every file operation as a
Content::ToolCall { name, arguments }in theagent_endmessages.src/pi.rs:244already logs the tool name + arguments and discards them. Capturing them gives an exact list of notes touched.(Follow-up suggestions — "here are 3 next questions" — remain out of scope: pi doesn't emit them as structured data. Not part of this issue.)
Which tool calls carry a usable path (verified against pi 0.80.3)
read—{ path, offset?, limit? }: the note pi consulted. Use.edit/write—{ path, ... }: the note pi modified (the "file into notes" case). Use — a link to "the note I just updated" is useful.grep—{ pattern, path?, glob? }:pathis only a search scope, not the matched files (those are in the tool result, which evie doesn't capture). Ignore.find/ls— directory scope, no source file. Ignore.Sources = union of
read+edit/writepaths, deduped, first-seen order.Scope
read_agent_response, capturepathfromread/edit/writeToolCallargs onagent_end. Dedupe, preserve first-seen order. Return them alongside the final text (extend the return type / thread a second channel).notes_dir; normalise relative paths (pi runs withcurrent_dir(notes_dir))..md, URL-encode path segments, keep/folder separators. Build<base_url>/<PageName>.silverbullet.base_url(optional). If unset, skip buttons entirely — no error.InlineKeyboardMarkupof URL buttons (one per note, cap ~5, labelled by page name) to the final message only (on the finaleditMessageText, via.reply_markup(...)). URL buttons need nocallback_queryhandler.Constraints
MessageView).notes_dirare ignored.Acceptance
silverbullet.base_urlunset -> no buttons, no error.Implemented in commit 158a24b.
What was done:
AgentResponse { text, sources }topi.rs.read_agent_responsenow capturespathfromread/edit/writeToolCall arguments onagent_endevents, deduped preserving first-seen order.silverbullet.base_url(optional[silverbullet]config section). When set, the Telegram handler attaches anInlineKeyboardMarkupof URL buttons (max 5) to the final message pointing to each touched note.notes_dir(pi runs withcurrent_dir(notes_dir)).page_name_from_pathstrips.md, URL-encodes each segment, keeps/folder separators.MessageView::apply_with_buttonsattaches the keyboard only on the last page.silverbullet.base_url= no buttons, no error.Files changed: Cargo.toml, Cargo.lock, src/pi.rs, src/session.rs, src/http.rs, src/telegram/mod.rs, src/config.rs, src/main.rs
Tests: 30 unit tests pass (6 new for source capture), 2 integration tests pass.
Not closing — will be closed by admin.