feat: tab completion for citation keys#110
Conversation
feat: v0 tab completion
|
Hi @wjiayis, thanks for the update. I’ve created a new issue to address the token expiration problem. Regarding the latency issue, do we have visibility into which part of the pipeline contributes most to the high latency? For example, a rough breakdown across:
I’ll take a look at this PR later this evening as well. |
|
@Junyi-99 I haven't gotten to the latency breakdown yet, but I've settled everything else and I'm gonna work on this next. Thanks for helping to review when convenient, I'll update my findings when I have them too! |
|
@wjiayis Got it, thanks for the update. Looking forward to your findings. |
Root CauseThere's a ~20s latency in the inline-suggestion loop, and >99% of the latency comes from waiting for LLM to start responding. This issues arises because I'm passing in a large (but realistic) bibliography (the bibliography of SolutionI think it's reasonable to expect that a regular user's max latency tolerance is ~2s. I'll implement the following 3 solutions to achieve that. Model Selection
Prompt CachingSince bibliography remains generally constant and takes up the bulk of the prompt, I'll use OpenAI's prompt caching - advertised to reduce latency by up to 80% and input token costs by up to 90%.
Prompt RefinementI'll remove info-sparse fields (eg cc: @Junyi-99 |
There was a problem hiding this comment.
Pull request overview
Implements a first version of citation-aware tab completion by detecting \cite{ in the editor, fetching suggested BibTeX keys from a new backend endpoint, and suppressing Overleaf’s default autocomplete/tab behavior to allow accepting inline suggestions.
Changes:
- Frontend: Adds a “citation suggestions” beta setting, detects
\cite{triggers, fetches citation keys, and intercepts Tab to accept inline suggestions. - Backend: Adds
GetCitationKeysRPC/HTTP endpoint, extracts and token-reduces.bibcontent, and queries an LLM for up to ~3 relevant citation keys. - Plumbing: Updates generated proto clients/servers and ignores
CLAUDE.md.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| webapp/_webapp/src/views/settings/sections/beta-feature-settings.tsx | Renames the completion toggle UI to “citation suggestions”. |
| webapp/_webapp/src/views/settings/index.tsx | Renders the beta features section in Settings. |
| webapp/_webapp/src/query/api.ts | Adds getCitationKeys() API wrapper for the new v2 endpoint. |
| webapp/_webapp/src/pkg/gen/apiclient/chat/v2/chat_pb.ts | Generated TS client types/service updated for GetCitationKeys. |
| webapp/_webapp/src/libs/inline-suggestion.ts | Adds \cite{ trigger handling and suppresses Overleaf autocomplete/tab behavior when suggestions are active. |
| proto/chat/v2/chat.proto | Adds GetCitationKeys RPC + request/response messages. |
| pkg/gen/api/chat/v2/chat_grpc.pb.go | Generated gRPC server/client updated with GetCitationKeys. |
| pkg/gen/api/chat/v2/chat.pb.gw.go | Generated grpc-gateway bindings for /_pd/api/v2/chats/citation-keys. |
| pkg/gen/api/chat/v2/chat.pb.go | Generated Go proto types updated with new messages and RPC. |
| internal/services/toolkit/client/get_citation_keys.go | Implements bibliography extraction and LLM prompt to suggest citation keys. |
| internal/api/chat/get_citation_keys.go | Implements the ChatServerV2 handler for GetCitationKeys. |
| .gitignore | Ignores CLAUDE.md. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
webapp/_webapp/src/views/settings/sections/beta-feature-settings.tsx
Outdated
Show resolved
Hide resolved
4ndrelim
left a comment
There was a problem hiding this comment.
Thanks for the hardwork jiayi! Just some minor comments on top of jun yi's. Once these are resolved, let's merge to staging, do a test on the staging env endpoint (together if you'd like, and i can run you through our deployment pipeline too) and if all is working as expected, we can immediately raise to main.
Junyi-99
left a comment
There was a problem hiding this comment.
LGTM! Thanks for your patience and for iterating on this!
4ndrelim
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the revision!
#33
In short, it'll
\cite{).bibfiles as raw text, and remove irrelevant fields to save tokensgpt-5.2for now) to get at most 3 citation keys