HiDeoo/starlight-i18n

`Starlight i18n` command throws and error in project with uncommitted documents

Closed this issue · 2 comments

Describe the bug

Hi HiDeoo, I installed your extension to test with existing Starlight project. I had some local, uncommitted files in the project and after running Starlight i18n command I've got the following error in notification bubble:

Failed to find the last commit for the file at 'c:\Users\user\src\astro\starlight\src\content\docs\page.mdx'.

It looks like unexpected behavior, since uncommitted files are not the only files that can be worked on.

When I removed uncommitted files from the project directory, error disappeared. I haven't done any more extensive testing other than that. If you won't be able to reproduce the error, let me know and I will try with fresh Starlight repo.

To Reproduce

  1. Open existing Starlight project
  2. Create Markdown page in src/content/docs/ and don't commit it to repository
  3. Run the Starlight i18n command in VS Code

Expected behavior

If plugin depends on commits, then, I believe, it should just omit the uncommitted files OR rely on local diff capabilities of VS Code.

How often does this bug happen?

Every time

System Info

  • VS Codium 1.87
  • Windows 11

Additional Context

Have a great day and thank you for your work 😇

Thanks for your report, really appreciate it.

The extension indeed relies on commit information to determine which files are missing, up-to-date, or outdated in the content directory.
My original idea for uncommitted files was indeed to not error out and only show them with a different UI in an unselectable state.
Unfortunately, this is not something that is currently possible with the QuickPick API used by the extension and simply ignoring them does not seem like a good idea to me so I decided to error out instead at the moment until I can properly signal them as uncommitted in the UI.

This is definitely something I want to improve in the future, but I don't think at the moment I can provide a good solution for this issue with the current limitations.
I'm going to close this issue for now, but happy to discuss it further or gather more feedback on this topic if more users are surprised by this behavior.

I see, thank you for the explanation then. You are definitely right that ignoring them entirely is not the best idea from the UX standpoint.

I don't have experience with VS Code extensions, but from what you say, one idea for a workaround could be to provide OPT-IN option in the extension settings to skip uncommitted files and avoid error (with e.g. short explanation/disclaimer to avoid confusion why files are not listed).

I'm thinking about this because my first reaction to error was to open another, committed file, and run command again. Just to see the same error message about irrelevant file to the others that could be translated.

That surprised me as rather obviously unexpected behavior, because it rendered the entire extension unusable even for valid files.

So, I will leave it there, as some food for thought. Maybe better ideas will come.

Cheers ✌