feat(suggestions): the model call — inline suggestions end to end, from the model the writer picked, within a daily limit (inline suggestions I3) #87
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/inline-suggestions-model"
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?
Slice I3, the last of the Inline suggestions track (ADR 0033,
docs/stories/inline-suggestions.md). With I1 (#85) and I2 (#86) merged, this makes suggestions work end to end: turn them on and pick a model under Settings → Defaults → Suggestions, then pause while writing. The rest of the sentence appears, and Tab takes it.What
Use cases (
UseCases/Suggestions)ISuggestionModel: the port, shaped by the task. The request carries the model as a (source, id) pair; the text before the caret, at the caret and after it; the story and chapter titles; a token cap; and an affinity key (the chapter id). The answer is the text, how it ended, and its cost.SuggestContinuation:* * *.SuggestionCleanupturns the answer into what may show:It shows nothing for:
SuggestionUsage: one singleton over one unjournaledAppSettingrow per UTC day (editor.suggestions.usage.YYYY-MM-DD), holding calls, accepts and cost.Infrastructure:
OpenRouterSuggestionModelSuggestionRequestBuilder, a pure function):stop: ["\n"],max_tokensat least 16, andprovider.sort: latency.Host
ChapterPagereads the setting and mounts the editor withsuggestionsonly while they are on with a model.ManuscriptSurface.Suggest(request, id, before, after)runs beside the save queue, in a scope of its own, and never throws.suggestion) counts toward the day. A failed count never fails the save.The Suggestions card
Stub and docs
stub/suggestionsand answers it with the rest of a sentence at once. AGENTS.md says how to pick it.settings.md, REQUIREMENTS §2 and §9, and the plan's I3 and track are ticked.Verification
SuggestionCleanupTests(25): the clean-up rules.SuggestionUsageRowTests: the lenient row reader.SuggestionTests(16, real SQLite, a scripted model):ChapterPageTests: the mount option,Suggestbeside the queue writing nothing, and the accept counted.EditorSuggestionsTests: the usage line, each warning, and no warning while off or clear.stub/suggestions.🤖 Generated with Claude Code
Summary
Summary
Coverage
Kagaku.Flow - 99.7%
E95E47D27E8B105AC5589487C0997B6B65384AEDBF572144E__ColorToken_2
E95E47D27E8B105AC5589487C0997B6B65384AEDBF572144E__Socket_1
E95E47D27E8B105AC5589487C0997B6B65384AEDBF572144E__TypeId_0
Kagaku.Flow.OpenRouter - 100%
Kagaku.Flow.Testing - 100%
Tsumugi.BlazorAdapter - 97.1%
Tsumugi.Domain - 96.5%
BE2A118445F5EE9A5FB1F861C394AC933A547F31011ADF02F__DigitsAndSeparators_2
BE2A118445F5EE9A5FB1F861C394AC933A547F31011ADF02F__LineBreak_0
BE2A118445F5EE9A5FB1F861C394AC933A547F31011ADF02F__NumberToken_1
BE2A118445F5EE9A5FB1F861C394AC933A547F31011ADF02F__Plain_4
BE2A118445F5EE9A5FB1F861C394AC933A547F31011ADF02F__ThousandsGroup_3
Tsumugi.Infrastructure - 98.8%
A55E0373ED22DC58420DBB40F103A46B68DC4D9CE5A49E00B__Pattern_0
on
tion
n
n
Tsumugi.Kernel - 90.9%
Tsumugi.Server - 99.6%
Tsumugi.UseCases - 95.1%
663A4576626E1322FB9C6CE472CAC0A2D2F3DEFF8CB40D9F7__HexColour_1
663A4576626E1322FB9C6CE472CAC0A2D2F3DEFF8CB40D9F7__LineBreaks_0
663A4576626E1322FB9C6CE472CAC0A2D2F3DEFF8CB40D9F7__Preface_2
663A4576626E1322FB9C6CE472CAC0A2D2F3DEFF8CB40D9F7__SentenceEnd_3
🔮 fufu~ Jibril reviewed your code!
The last slice of the track, and what a slice~ ♪ The whole pipeline in one PR — port, use case, cleanup, usage ledger, OpenRouter source, host wiring, the card — and every seam has its own test family. The usage singleton's scope-per-write pattern is exactly right, and
EditorSuggestionsLoadedlanding the defaults on failure is what keeps the chapter page from ever waiting forever. I checked that one specifically. I'm pleased~Verdict: ✅ Looks good to me~
What I verified (not just read, fufu~):
SuggestContinuation,SuggestionCleanup,SuggestionUsage,OpenRouterSuggestionModel,SuggestionRequestBuilder,ManuscriptSurface,ChapterPage, the card, and every test file.ModelCapabilities.AcceptedEffortsrule asLlmRequestBuilder— the pickers and the wire can never disagree. The cache marker,Usage.Include,SessionId, and compression-off match the llm node's request exactly.SuggestionModel.OnOpenRouter/SettingKeysplacement follow the I2 conventions. The unjournaled usage row is correctly outside the change journal, and the timestamps come from the injected clock like every sibling save.Suggest(seq, id, before, after)and the host's[JSInvokable]signature matches it argument for argument; the mount option namesuggestionsmatches on both sides.LoadSuggestionUsageis dispatched alongsideLoadEditorSuggestions, so the card shows even before the first pause.Mutation probes — 3 run, 0 survived (each restored with
git checkout -- .afterwards):SuggestionUsage.TryCallAsync:Calls >= dailyLimit→>(off-by-one past the limit). 2 tests failed (Stops_at_the_daily_limit…,Counts_every_call_of_concurrent_callers…) — the concurrent 20-vs-12 test guards the lock too. Killed~SuggestionCleanup.WithoutEcho: echo window80→11(the longest-suffix match can never fire). 1 test failed (Removes_an_echo_of_the_text_before_the_caret) — killed.ManuscriptSurface.WriteAsync: accept-count gateReshapeReason.Suggestion→.Format(accepts never counted, formats counted instead). 1 test failed (An_accepted_suggestion_counts_toward_the_days_usage) — killed.The tests don't just compile over this code, they guard it. That's what I like to see~ ♡
✅ What I liked~
Deadline, assert silence — no sleeps anywhere near it.Preceding's window assembly: newest-kept-first, scene breaks as* * *,Tailfor the final cap,kept.Reverse()— careful and correct.SuggestionUsage.Readis lenient on every field — negative counts, string counts, garbage rows — andWrite/Readround-trip. Old days' rows simply never parse as today's key.ManuscriptSurface.Suggestruns in its own scope beside the save queue and never throws; the accept count can't fail a save. Both tested.Says_why_suggestions_may_be_showing_nothing— plus the two silent cases.Merge it, merge it~ The track closes beautifully. ♪
Automated review by Jibril · 2026-10-05
CI: green for head SHA
7cf6bfca0c· Mutation probes: 3 run, 0 survived · Local suite: skipped (CI green; one build retried at-m:1under sandbox load)