Skip to content

Clarify js_repl binding reuse guidance#13803

Merged
fjord-oai merged 1 commit intomainfrom
fjord/js_repl_prompt
Mar 6, 2026
Merged

Clarify js_repl binding reuse guidance#13803
fjord-oai merged 1 commit intomainfrom
fjord/js_repl_prompt

Conversation

@fjord-oai
Copy link
Contributor

Summary

Clarify the js_repl prompt guidance around persistent bindings and redeclaration recovery.

This updates the generated js_repl instructions in core/src/project_doc.rs to prefer this order when a name is already bound:

  1. Reuse the existing binding
  2. Reassign a previously declared let
  3. Pick a new descriptive name
  4. Use { ... } only for short-lived scratch scope
  5. Reset the kernel only when a clean state is actually needed

The prompt now also explicitly warns against wrapping an entire cell in block scope when the goal is to reuse names across later cells.

Why

The previous wording still left too much room for low-value workarounds like whole-cell block wrapping. In downstream browser rollouts, that pattern was adding tokens and preventing useful state reuse across js_repl cells.

This change makes the preferred behavior more explicit without changing runtime semantics.

Scope

  • Prompt/documentation change only
  • No runtime behavior changes
  • Updates the matching string-backed project_doc tests

@fjord-oai fjord-oai merged commit d6c8186 into main Mar 6, 2026
71 of 75 checks passed
@fjord-oai fjord-oai deleted the fjord/js_repl_prompt branch March 6, 2026 23:19
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants