Skip to content

feat(harper-ls): add configurable diagnostic delay#3282

Open
Dronakurl wants to merge 1 commit into
Automattic:masterfrom
Dronakurl:feature/diagnostics-in-normal-mode
Open

feat(harper-ls): add configurable diagnostic delay#3282
Dronakurl wants to merge 1 commit into
Automattic:masterfrom
Dronakurl:feature/diagnostics-in-normal-mode

Conversation

@Dronakurl

@Dronakurl Dronakurl commented May 1, 2026

Copy link
Copy Markdown
Contributor

feat(harper-ls): Add configurable diagnostic delay

This PR is now hand written. I took the code generated by vibe and stripped it down. In the end, I basically touched every line.

  • Problem: I happily use harper-ls within helix and I found it distracting that the diagnostics pop up immediately while typing.
  • Solution: I introduced a new config option for a delay in the diagnostics. While typing, no new diagnostics show up. Only if I stop typing for a (configurable) time, new diagnostics pop up.
  • Code actions: I removed the code that immediately triggered code actions for replacing words. It was too complicated. When adding a word to a dictionary, immediate change of the diagnostics is supported.
  • Technical remark:
    • The idea is to spawn a pending diagnostic task on each change of the file. If you type, the tasks are aborted and restarted. Only when after the specified time, no changes were made, the diagnostic task goes through
    • In order to spawn the diagnostic in a separate thread, I needed to make the Backend Clone by wrapping everything in Arc.
    • When the delay in seconds is not defined (defaults to 0), none of this is done to save resources for everyone who is not using the feature.

This PR was initially created by vibe coding agents and I changed the AI-written explanation here. Just if you wonder about the comments below.

@elijah-potter

Copy link
Copy Markdown
Collaborator

It looks like you've broken some VS Code tests. You might want to try extending their timeouts to account for the default delay. It might be an easy fix.

@Dronakurl Dronakurl marked this pull request as draft May 1, 2026 19:10
@Dronakurl Dronakurl force-pushed the feature/diagnostics-in-normal-mode branch 2 times, most recently from d148093 to f9b9a32 Compare May 2, 2026 00:24
@Dronakurl Dronakurl marked this pull request as ready for review May 2, 2026 11:00
@Dronakurl Dronakurl marked this pull request as draft May 11, 2026 18:46
@Dronakurl Dronakurl marked this pull request as ready for review May 11, 2026 19:43
@Dronakurl Dronakurl force-pushed the feature/diagnostics-in-normal-mode branch 2 times, most recently from 437bcf8 to 88ce2e2 Compare May 19, 2026 20:11
@elijah-potter

Copy link
Copy Markdown
Collaborator

@Dronakurl, have you read our agent policy?

@Dronakurl

Copy link
Copy Markdown
Contributor Author

Thank you for pointing that out to me.

I have read it now. :-)

So here is the brief, non LLM-generated description of the state of the PR:

  • This PR was generated by an LLM agent (I use mistral vibe).
  • Problem: I happily use harper-ls within helix and I found it distracting that the diagnostics pop up immediately while typing.
  • Solution:
    • I introduced a new config option for a delay in the diagnostics. While typing, no new diagnostics show up. Only if I stop typing for a (configurable) time, new diagnostics pop up.
    • Initially, there was a problem with code actions not being applied immediately, because the new delay interfered. That was solved, too.
  • Testing: I have used it for 2 weeks and did not see an issue. What I honestly did not test (apart from the workflow tests) is if there are any side effects on vs code, etc.

I am not an experienced rust programmer, to be honest, but I looked at the code myself and found it reasonable (unlike this other language feature, which should not have been marked "ready for review" in the first place).

Could you please have a brief look at the code and tell me the first thing you find problematic? (The first thing in the changed files is this "pr_drafts" folder, which should not be in there, so maybe the second thing. :-))
I think, I can work with that to revise the PR so that it is acceptable.

@Dronakurl Dronakurl marked this pull request as draft May 29, 2026 21:37
@Dronakurl Dronakurl force-pushed the feature/diagnostics-in-normal-mode branch 2 times, most recently from 9f3b7a4 to fde4cd4 Compare May 29, 2026 22:36
@Dronakurl Dronakurl closed this May 29, 2026
@Dronakurl Dronakurl force-pushed the feature/diagnostics-in-normal-mode branch from fde4cd4 to e2afb11 Compare May 29, 2026 22:51
@Dronakurl Dronakurl reopened this Jun 2, 2026
@Dronakurl

Dronakurl commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Updated the PR description, since it was only AI stuff, so now I would be grateful for a review on this PR. @elijah-potter

@Dronakurl Dronakurl marked this pull request as ready for review June 2, 2026 19:03
@Dronakurl Dronakurl force-pushed the feature/diagnostics-in-normal-mode branch 3 times, most recently from 219b66e to b3c67e3 Compare June 8, 2026 06:48
@Dronakurl Dronakurl force-pushed the feature/diagnostics-in-normal-mode branch 3 times, most recently from d6a966c to 3f19c51 Compare June 13, 2026 16:43
@Dronakurl Dronakurl force-pushed the feature/diagnostics-in-normal-mode branch from 3f19c51 to d1339af Compare June 24, 2026 19:54
Keep delayed diagnostics simple and bug-focused by debouncing didChange publishes, cleaning up pending task state, and removing the race-prone post-code-action refresh path.

before getting rid of the generation

now generation

pending_diagnostic_task

move publish_immediately

get rid of the test
@Dronakurl Dronakurl force-pushed the feature/diagnostics-in-normal-mode branch from d1339af to 849b909 Compare June 27, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants