marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
7.95k stars 278 forks source link

[wip] improvement: autocomplete functions #2883

Open Light2Dark opened 5 days ago

Light2Dark commented 5 days ago

📝 Summary

Fixes #2877

🔍 Description of Changes

There are still some odd / inconsistent behaviours, so this fix isn't foolproof.

📋 Checklist

📜 Reviewers

@akshayka OR @mscolnick

vercel[bot] commented 5 days ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 19, 2024 0:34am
marimo-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 19, 2024 0:34am
Light2Dark commented 5 days ago

I see there is an issue with some code_completion requests not resolving. It ends up that the autocomplete feels flaky.

frontend/src/core/codemirror/completion/Autocompleter.ts

export const AUTOCOMPLETER = new DeferredRequestRegistry<
  Omit<CodeCompletionRequest, "id">,
  CompletionResultMessage | null
>(
  "autocomplete-result",
  async (requestId, req) => {
    await sendCodeCompletionRequest({
      id: requestId,
      ...req,
    });
  },
  // We don't care about previous requests
  // so we just resolve them with an empty response.
  // { resolveExistingRequests: () => null }, // for example, commenting this out improves it. Existing reqs are handled
);

Playing around with this code, I can see the autocomplete not working 100% of the time. Still looking into why.

fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
fig.upda