Skip to content

Conversation

@chengluyu
Copy link
Collaborator

@chengluyu chengluyu commented Oct 28, 2025

Changes

Minor Changes

  • After the runtime has been updated, when we update the editor state, we now merge the changes of deleting output comments and the changes adding output comments.

Memo

2025-10-29

  • Fix the tests.
  • When a block is evaluated, flash its indicator.
  • Syntax errors can crash the block metadata extension and cannot recover unless refresh the page.
  • Update the test facilities if possible (don't be blocked by this).
  • Remove the highlight of blocks after the PR becomes ready to merge.

@vercel
Copy link

vercel bot commented Oct 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
recho-notebook Ready Ready Preview Comment Oct 29, 2025 5:19pm

@chengluyu chengluyu requested a review from Copilot October 28, 2025 18:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements automatic block update functionality that responds to user changes in the editor. The implementation introduces an interval tree data structure to efficiently track code blocks and their output ranges, adds visual indicators in the editor gutter to show block boundaries, and enhances the runtime to maintain block metadata including attributes and error states.

Key Changes:

  • Added IntervalTree data structure for efficient interval overlap queries
  • Implemented block metadata tracking system with automatic position updates
  • Added visual block indicators in the editor gutter

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 26 comments.

Show a summary per file
File Description
test/IntervalTree.spec.js Comprehensive test suite for the new IntervalTree data structure
lib/IntervalTree.ts AVL-balanced interval tree implementation for efficient range queries
runtime/index.js Enhanced runtime to track block metadata and use interval tree for change detection
editor/blockMetadata.ts Block metadata state management with automatic position mapping
editor/blockIndicator.ts Gutter marker implementation for visual block indicators
editor/index.js Integration of block metadata and indicator extensions
editor/index.css Styling for block indicators and debug markers
editor/decoration.js Updated decorations to include block attributes and debug markers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +168 to +169
console.log(blocks);

Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statement should be removed before merging to production.

Suggested change
console.log(blocks);

Copilot uses AI. Check for mistakes.
Comment on lines +308 to +312
console.group("rerun");
for (const node of nodes) {
console.log(`Node ${node.type} (${node.start}-${node.end})`);
}
console.groupEnd();
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console logging should be removed before merging to production.

Suggested change
console.group("rerun");
for (const node of nodes) {
console.log(`Node ${node.type} (${node.start}-${node.end})`);
}
console.groupEnd();
// Debug logging removed for production.

Copilot uses AI. Check for mistakes.
const set1 = builder1.finish();

// Build the range set for block attributes.
console.groupCollapsed("Decorations for block attributes");
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.groupCollapsed statement should be removed before merging to production.

Suggested change
console.groupCollapsed("Decorations for block attributes");

Copilot uses AI. Check for mistakes.
// Apply decorations to each line in the block range
const startLine = state.doc.lineAt(output.from);
const endLine = state.doc.lineAt(output.to);
console.log(`Make lines from ${startLine.number} to ${endLine.number} compact`);
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statement should be removed before merging to production.

Suggested change
console.log(`Make lines from ${startLine.number} to ${endLine.number} compact`);

Copilot uses AI. Check for mistakes.
}
}
const set2 = builder2.finish();
console.groupEnd();
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.groupEnd statement should be removed before merging to production.

Suggested change
console.groupEnd();

Copilot uses AI. Check for mistakes.
Comment on lines +271 to +272
console.log("Updated blocks:", blocks);

Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statement should be removed before merging to production.

Suggested change
console.log("Updated blocks:", blocks);

Copilot uses AI. Check for mistakes.

console.log("Updated blocks:", blocks);

console.groupEnd();
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.groupEnd statement should be removed before merging to production.

Suggested change
console.groupEnd();

Copilot uses AI. Check for mistakes.
// Otherwise, we need to update the block attributes according to the
// metadata sent from the runtime. Most importantly, we need to translate
// the position of each block after the changes has been made.
console.group("Updating blocks from the effect");
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.group statement should be removed before merging to production.

Copilot uses AI. Check for mistakes.
to: tr.changes.mapPos(block.source.to, 1),
};
console.log(`output: ${block.output?.from} - ${block.output?.to}`);
console.log(`source: ${block.source.from} - ${block.source.to}`);
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statements should be removed before merging to production.

Suggested change
console.log(`source: ${block.source.from} - ${block.source.to}`);

Copilot uses AI. Check for mistakes.
console.log(`output: ${block.output?.from} - ${block.output?.to}`);
console.log(`source: ${block.source.from} - ${block.source.to}`);
}
console.groupEnd();
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.groupEnd statement should be removed before merging to production.

Suggested change
console.groupEnd();

Copilot uses AI. Check for mistakes.
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.

2 participants