huggingface / llm-ls

LSP server leveraging LLMs for code completion (and more?)
Apache License 2.0
602 stars 49 forks source link

issue 45 fix - use SystemTime instead of instant for unauthenticated warning #100

Closed Ovich closed 3 months ago

Ovich commented 3 months ago

This PR addresses issue #45 .

As explained in the issue, the resulting system call for Instant::now() is not consistent across platforms. On Windows, Instant::now() can return a value smaller than MAX_WARNING_REPEAT (3600s), leading to a panic with the error "instant to be in bounds.".

To fix this, just like proposed in the issue, I replaced Instant::now() with SystemTime::now(), which provides consistent behavior across different operating systems. This change has been tested on both Windows and macOS, passing all unit tests.

SystemTime::now() uses the real-time system clock. Although it is not a monotonic time source, it is sufficient for this use case of notifying the user every hour when they are in a non-authenticated state.

Ovich commented 3 months ago

@McPatate

I've implemented a fix for issue #45, switching to SystemTime::now() for sending hourly notifications in non-authenticated states.

Please review the changes when you have a moment.

Regards

dvteixeira24 commented 2 months ago

Is this supposed to be in 0.5.3? i tried to build this myself to check why the 0.5.3 for windows on the release page returns 0.5.2 for --version and then time fails to build for me on windows

error[E0282]: type annotations needed for `Box<_>`
  --> C:\Users\daniel\.cargo\registry\src\index.crates.io-6f17d22bba15001f\time-0.3.28\src\format_description\parse\mod.rs:83:9
   |
83 |     let items = format_items
   |         ^^^^^
...
86 |     Ok(items.into())
   |              ---- type must be known at this point
   |
help: consider giving `items` an explicit type, where the placeholders `_` are specified
   |
83 |     let items: Box<_> = format_items
   |              ++++++++

but after cargo update -p time it builds successfully, --version displays 0.5.3

Actually trying to fix this https://github.com/huggingface/llm-vscode/issues/93