Skip to content

feat(autocomplete): personalise suggestions via accepted-completion history#76

Merged
senamakel merged 8 commits into
tinyhumansai:mainfrom
oxoxDev:feat/autocomplete-personalization
Mar 30, 2026
Merged

feat(autocomplete): personalise suggestions via accepted-completion history#76
senamakel merged 8 commits into
tinyhumansai:mainfrom
oxoxDev:feat/autocomplete-personalization

Conversation

@oxoxDev
Copy link
Copy Markdown
Contributor

@oxoxDev oxoxDev commented Mar 30, 2026

Summary

  • Adds a persistent history of accepted autocomplete completions stored in the local KV store
  • Feeds recent accepted completions back as dynamic style examples during inference, creating a personalisation feedback loop
  • Exposes two new RPC methods (autocomplete_history, autocomplete_clear_history) with full controller schema registration
  • Adds a "Personalization History" section to the autocomplete settings panel with list view and clear button
  • No new dependencies, no schema migrations — built entirely on existing MemoryClient KV infrastructure

Problem

  • Autocomplete starts cold every session with no memory of what the user previously accepted (issue Improve Autocomplete and Screenshot Features #71)
  • The inline_complete() call already supports style_examples for in-context learning but they were only static (user-configured) — no automatic personalisation existed
  • Users had no visibility into what completions were accepted or how the system was learning

Solution

  • New history.rs module persists each accepted completion (context, suggestion, app_name, timestamp_ms) under KV namespace "autocomplete" with zero-padded timestamp keys for correct ordering, auto-trimmed to 50 entries
  • On every Tab-accept or RPC-accept, a fire-and-forget tokio::spawn saves the completion — zero latency impact on the acceptance path
  • Before each inference cycle in refresh(), the 6 most recent accepted completions are loaded from KV and merged with user's static style examples (capped at 8 total), then passed to inline_complete() — the model sees what this user liked before
  • Design tradeoff: MemoryClient::new_local() is called inline per operation (not stored on AutocompleteEngine) to avoid changing the Lazy singleton constructor — matches the established pattern in memory/ops.rs

Testing

  • cargo check --manifest-path Cargo.toml --bin openhuman
  • Pre-push hooks passed: prettier --check, eslint, tsc --noEmit, cargo fmt --check
  • yarn -s compile
  • cargo check --manifest-path app/src-tauri/Cargo.toml
  • Manual: accept 3-5 completions via Tab → entries appear in Settings → Autocomplete → Personalization History
  • Manual: observe suggestion quality shift after ~6 accepts
  • Manual: click "Clear History" → list empties, suggestions revert to cold-start

Impact

  • Desktop only (macOS) — autocomplete is platform-gated; no mobile/web/CLI runtime impact
  • Performance: KV reads are local SQLite, expected <5ms per inference cycle; saves are async fire-and-forget
  • Storage: max 50 KV entries in ~/.openhuman/workspace SQLite — negligible disk footprint
  • Security: all data stays local, no network calls, no PII sent externally

Breaking Changes

  • None

Related

🤖 Generated with Claude Code

oxoxDev and others added 8 commits March 30, 2026 18:55
Introduces history.rs — a thin persistence layer over the existing local
KV store (MemoryClient::new_local()) that stores every accepted completion
and surfaces them as formatted style examples for in-context learning.

Public API:
- save_accepted_completion(context, suggestion, app_name)
- load_recent_examples(n) → Vec<String>
- list_history(limit) → Vec<AcceptedCompletion>
- clear_history() → usize

Storage: KV namespace "autocomplete", keys "accepted:{ts_ms:018}",
auto-trimmed to 50 entries on each save.

Refs: tinyhumansai#71

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds `mod history` and re-exports the public types/functions so they
are accessible from sibling modules (core.rs, ops.rs, schemas.rs).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mples

Three additions to the autocomplete engine:

1. After RPC accept (accept method): fire-and-forget tokio::spawn to
   save the accepted completion context + suggestion to KV history.

2. After Tab-key accept (try_accept_via_tab): same fire-and-forget save.

3. Before inline_complete() in refresh(): load the 6 most recent
   accepted completions from history, merge with user's static
   style_examples (capped at 8 total), and pass as dynamic examples —
   giving the model in-context personalisation from prior acceptances.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds two new async handler functions and their param/result structs:

- autocomplete_history(limit?) → AutocompleteHistoryResult
- autocomplete_clear_history() → AutocompleteClearHistoryResult

Both delegate to the history module and return via RpcOutcome, following
the established pattern of existing autocomplete ops handlers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds ControllerSchema definitions and handler wiring for the two new
RPC methods: openhuman.autocomplete_history and
openhuman.autocomplete_clear_history.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds AcceptedCompletion, AutocompleteHistoryResult, and
AutocompleteClearHistoryResult interfaces plus two exported async
functions (openhumanAutocompleteHistory, openhumanAutocompleteClearHistory)
following the existing callCoreRpc pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a new UI section between Settings and Test in the autocomplete
settings panel showing accepted completion history:

- Scrollable list of entries with timestamp, app name, context tail,
  and accepted suggestion
- Clear History button (red-toned, disabled when empty)
- Summary line with entry count
- Auto-loads on mount alongside existing settings load

Uses local component state only (no Redux) — history is fetched via
the new openhumanAutocompleteHistory RPC stub.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Auto-formatted by pre-push hooks — import ordering, line wrapping,
and brace style adjustments. No logic changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@oxoxDev oxoxDev marked this pull request as ready for review March 30, 2026 16:49
@senamakel senamakel merged commit f975cba into tinyhumansai:main Mar 30, 2026
2 of 5 checks passed
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.

2 participants