Repository navigation
Conversation
LeanBitLab
left a comment
There was a problem hiding this comment.
Thanks, showing the X on the key that started the request makes sense. One bug before we can merge:
The X can end up on the wrong key
nextLoadingKey is a global that is set in handleTranslate / handleCustomAIKey before translateAsync / customAsync, but it is only cleared in showLoadingAnimation. In several cases the loading animation never starts, so the value stays set:
performAsyncOperationreturns early without showing the animation: no text, no model selected (offline), no API key (standard),showLoadingAnimationitself returns early when the strip is not attached or not visible (SuggestionStripView.kt, theisAttachedToWindow/ visibility check), e.g. when the toolbar is hidden.
Example: tap translate in an empty field ("No text" toast, nextLoadingKey = TRANSLATE stays), then tap proofread in a field with text: the X appears on the translate key instead of proofread, and the proofread key keeps its normal icon although tapping it cancels.
Suggested fix: don't keep the key in a global between the two calls. For example, pass the key along with the request (ProofreadHelper already posts showLoadingAnimation(), it could post showLoadingAnimation(key)), or at least clear nextLoadingKey in hideLoadingAnimation() and on every early return in performAsyncOperation in both flavors.
Smaller points
- While any AI request runs, tapping a different AI key now cancels the running request instead of starting its own (e.g. translate during a proofread). That is fine with me, but please mention it in the description.
- If the toolbar is rebuilt while a request runs,
loadingKeyIconsholds the old buttons, so the restore inhideLoadingAnimation()goes to views that are no longer shown. Harmless, but finding the buttons by tag again on restore (like the old code) would avoid it. - Please use imports instead of the fully qualified
helium314.keyboard.latin.suggestions.nextLoadingKey/ToolbarKeynames inInputLogic.
LeanBitLab
left a comment
There was a problem hiding this comment.
Marking as changes requested: please fix the stale nextLoadingKey described in my review comment above (the X can end up on the wrong key after a request that never started).
While an AI request runs, only the proofread key turned into an X, also when the request came from the translate key or a custom AI key. Now the key that started the request shows the X and gets its own icon back afterwards. The key is passed along with the request (ProofreadHelper -> showLoadingAnimation), so a request that doesn't start (no text, no model, no API key, toolbar not shown) leaves nothing behind. Buttons are looked up again on restore, in case the toolbar was rebuilt meanwhile. A tap on the translate key or a custom AI key while any AI request runs cancels it, like the proofread key already did, with a short message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VuiaMhLXwhErf9shhrr1uD
4121ed9 to
fc3ea63
Compare
|
Thanks, good catch! Fixed in the updated branch (one commit, force-pushed, now on current main with #888):
It still merges cleanly together with #889, and the unit tests pass in both flavors. |
While an AI request runs, only the proofread key turned into an X, also when the request came from the translate key or a custom AI key.
This fits well with #889: as custom key requests keep running when the keyboard hides, there should be a clear way to stop one.
🤖 Generated with Claude Code