Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple srcmd from node libs and AI #140

Merged
merged 1 commit into from
Jul 17, 2024
Merged

Decouple srcmd from node libs and AI #140

merged 1 commit into from
Jul 17, 2024

Conversation

benjreinhart
Copy link
Contributor

No description provided.

@benjreinhart benjreinhart requested a review from nichochar July 17, 2024 20:12
case 'markdown':
return encodeMarkdownCell(cell);
case 'placeholder':
return encodePlacebolderCell(cell);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nichochar there shouldn't be a coupling here to AI-specific things, so we can instead represent a placeholder cell as a cell and then render whatever the contents of the cell's text is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This also allows it to be used for other things in the future if needed.

// Make sure we copy cells so we don't mutate the session
const cellsWithPlaceholder: CellWithPlaceholderType[] = [...session.cells];

cellsWithPlaceholder.splice(insertIdx, 0, {
Copy link
Contributor Author

@benjreinhart benjreinhart Jul 17, 2024

Choose a reason for hiding this comment

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

Since CellWithPlaceholderType is a superset of the CellType, any existing calls or cell representations will succeed just fine, but here, in the one place we need to do something different, we can leverage this superset type and pass in the cell instead of relying on the encoder to know what to do for AI.

Copy link
Contributor

@nichochar nichochar left a comment

Choose a reason for hiding this comment

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

LGTM

@benjreinhart benjreinhart merged commit 5058836 into main Jul 17, 2024
1 check passed
@benjreinhart benjreinhart deleted the srcmd branch July 17, 2024 20:24
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