Skip to content

Add live symbol autocompletion, signature help tooltip, and bracket auto-close to web notebook - #261

Open
KarataevDmitry wants to merge 2 commits into
Mathics3:masterfrom
AI-Guiders:feat/notebook-intellisense
Open

KarataevDmitry wants to merge 2 commits into
Mathics3:masterfrom
AI-Guiders:feat/notebook-intellisense

Conversation

@KarataevDmitry

@KarataevDmitry KarataevDmitry commented Nov 26, 2026 •

Copy link
Copy Markdown

Summary

Adds live symbol autocompletion, call-signature tooltips, and auto-closing brackets to the mathics-django web notebook (textarea.request), bringing the web frontend up to parity with mathicsscript's CLI completion experience:

  1. Backend (/ajax/completions/ in mathics_django/web/views.py):
    • Uses public mathics.core.load_builtin.builtins_dict (builtins_by_module + loaded pymathics_builtins_by_module) and mathics.core.symbols.strip_context.
    • Extracts call signatures (<dt>'Func'[...]) and summary_text from builtin docstrings, caches system completions across requests (invalidating automatically if new pymathics modules are loaded), and merges session-specific Global`` user symbols (evaluation.definitions.user, distinguishing functions via downvalues/subvalues`).
  2. Frontend (mathics_django/web/media/js/intellisense.js):
    • Non-intrusive popup anchored to the caret on textarea.request cells (Tab/Enter to insert, Up/Down to navigate, Esc to dismiss, Ctrl+Space manual trigger).
    • Context-aware Signature Help tooltip when the cursor is inside Func[...].
    • Auto-closing brackets [...], {...}, (...) and automatic refresh of user-defined Global`` symbols after cell evaluation (Shift+Enter`).
  3. Tests (mathics_django/test_django.py):
    • Adds CompletionsEndpointTests verifying /ajax/completions/ and prefix filtering (4/4 tests passing via manage.py test).

@rocky

rocky commented Nov 27, 2026

Copy link
Copy Markdown
Member

Thanks for this.. I greatly appreciate it Again, right now I am not able to look at this in any detail or try it which I very much want to do.

Possibly in a day or two I will be able to look at it closer, but it may take a week to get to this, unless @mmatera or someone else can look at this.

@mmatera

mmatera commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Thank you for looking at this. As rocky, I am currently busy, but I can try to look at it over the weekend.

@KarataevDmitry

Copy link
Copy Markdown
Author

Such a warm reaction and reply — thank you both! :) @rocky @mmatera No rush at all, take your time. If anything is needed, I'm in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants