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

feat: add vscode slice for message passing with extension #3080

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

heyzec
Copy link

@heyzec heyzec commented Jan 14, 2025

Description

FYP: Source Academy as Visual Studio Code Extension

This PR makes the frontend's behavior change conditionally when it detects itself to be running as an iframe in the VS Code extension. This is required so that it can send and receive the editor text contents, encapsulated as messages, to the VS Code extension.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

How to test

Checklist

  • I have tested this code

@heyzec heyzec requested a review from RichDom2185 January 14, 2025 08:56
Copy link
Member

@RichDom2185 RichDom2185 left a comment

Choose a reason for hiding this comment

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

Hi, thanks for working on this! Could you update the test snapshots?

@coveralls
Copy link

coveralls commented Jan 24, 2025

Pull Request Test Coverage Report for Build 13177704939

Details

  • 30 of 47 (63.83%) changed or added relevant lines in 9 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 31.226%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/commons/application/reducers/VscodeReducer.ts 5 6 83.33%
src/features/vscode/messages.ts 9 15 60.0%
src/commons/application/Application.tsx 8 18 44.44%
Totals Coverage Status
Change from base Build 13148678837: 0.03%
Covered Lines: 4860
Relevant Lines: 14680

💛 - Coveralls

Copy link
Member

@RichDom2185 RichDom2185 left a comment

Choose a reason for hiding this comment

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

Just some minor nits :)

src/commons/application/actions/VscodeActions.ts Outdated Show resolved Hide resolved
Comment on lines +188 to +192
// useEffect(() => {
// // TODO: Hardcoded to make use of the first editor tab. Refactoring is needed for this workspace to enable Folder mode.
// handleEditorValueChange(0, '');
// // eslint-disable-next-line react-hooks/exhaustive-deps
// }, []);
Copy link
Member

Choose a reason for hiding this comment

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

Will this break anything with assessments? Have you tested locally?

Copy link
Author

Choose a reason for hiding this comment

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

From my local testing, there's no unintended behavior. Assessments still loading as per normal.

handleEditorValueChange is ultimately called with the editor contents due to the useEffect here.

@@ -222,7 +223,11 @@ const Workspace: React.FC<WorkspaceProps> = props => {
</Resizable>
<div className="row content-parent" ref={contentContainerDiv}>
<div className="editor-divider" ref={editorDividerDiv} />
<Resizable {...editorResizableProps()}>{createWorkspaceInput(props)}</Resizable>
{isVscode ? (
<div style={{ width: '0px' }}>{createWorkspaceInput(props)}</div>
Copy link
Member

Choose a reason for hiding this comment

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

It must still be visible is it? We can't use visibility: hidden? If we can't, then in addition to width: 0, should we also use overflow: hidden?

Copy link
Author

Choose a reason for hiding this comment

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

While visibility: hidden wouldn't work, I think we can completely remove it now that messages are passed directly to the redux store rather than to the editor.

src/features/vscode/messages.ts Outdated Show resolved Hide resolved
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