Support the C# plugin in the new web GUI#862
Open
HorvathDaniel15 wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds C# support to the new web GUI by routing language-dependent UI features (diagrams, references, highlighting, search filters) through the appropriate language plugin/service and enabling C# syntax highlighting in the editor components.
Changes:
- Extend
language-service/ UI flows to support the C# plugin (CS→CsharpService) and update multiple components to use the unified language service APIs instead of C++-specific ones. - Add C# search language options and MIME filters, plus include C# in metrics file-type filters.
- Add CodeMirror C# language support via
@replit/codemirror-lang-csharpand use it in the editor and CodeBites views.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| webgui-new/src/service/language-service.ts | Adds CS → CsharpService routing and connection options for the unified language service client. |
| webgui-new/src/global-context/app-context.tsx | Removes C++-specific client initialization and applies formatting/URL-state cleanup. |
| webgui-new/src/enums/search-enum.ts | Adds C# as a main language and C# MIME types. |
| webgui-new/src/components/metrics/metrics.tsx | Adds CS to metrics file-type filters and formatting updates. |
| webgui-new/src/components/info-tree/info-tree.tsx | Uses unified language service and adds cancellation handling during async loading. |
| webgui-new/src/components/header/header.tsx | Adds C# language query support for search and refactors formatting. |
| webgui-new/src/components/file-name/file-name.tsx | Switches file-reference menu from C++-specific service calls to unified language-service calls. |
| webgui-new/src/components/file-context-menu/file-context-menu.tsx | Switches file diagram type loading from C++ service to unified language service. |
| webgui-new/src/components/diagrams/diagrams.tsx | Switches diagram/ref resolution from C++ service to unified language service and updates client selection logic. |
| webgui-new/src/components/codemirror-editor/codemirror-editor.tsx | Adds C# syntax highlighting and updates reference-based highlighting to use unified language service. |
| webgui-new/src/components/codebites/codebites-node.tsx | Switches CodeBites fetching/navigation from C++ service to unified language service and adds per-language CodeMirror extension. |
| webgui-new/package.json | Adds @replit/codemirror-lang-csharp dependency. |
| webgui-new/package-lock.json | Locks @replit/codemirror-lang-csharp dependency. |
| plugins/csharp/service/src/csharpservice.cpp | Improves robustness when mapping file paths/ids (null checks + logging) for C# service responses. |
Files not reviewed (1)
- webgui-new/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)
webgui-new/src/components/diagrams/diagrams.tsx:220
- Same issue as the main diagram parsing:
generateLegendassumes the legend response contains an<svg>element. If the legend string is empty/invalid,diagramLegendSvgwill beundefinedand.style/replaceChildrenwill throw. Add a guard for missing<svg>and handle the error path gracefully.
const diagramLegend =
diagramInfo instanceof FileInfo
? await getFileDiagramLegend(parseInt(appCtx.diagramTypeId))
: diagramInfo instanceof AstNodeInfo
? await getDiagramLegend(parseInt(appCtx.diagramTypeId))
: "";
const parser = new DOMParser();
const parsedDiagramLegend = parser.parseFromString(
diagramLegend,
"text/xml",
);
const diagramLegendSvg = parsedDiagramLegend.getElementsByTagName("svg")[0];
diagramLegendSvg.style.height = "100%";
diagramLegendContainerRef.current.replaceChildren(diagramLegendSvg);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
6
to
+28
| let client: LanguageService.Client | undefined; | ||
| export const createClient = (workspace: string, fileType: string | undefined) => { | ||
| export const createClient = ( | ||
| workspace: string, | ||
| fileType: string | undefined, | ||
| ) => { | ||
| if (!config || !fileType) return; | ||
|
|
||
| const service = () => | ||
| { | ||
| switch(fileType) | ||
| { | ||
|
|
||
| const service = () => { | ||
| switch (fileType) { | ||
| case "CPP": | ||
| return "CppService"; | ||
| case "PY": | ||
| return "PythonService"; | ||
| case "CS": | ||
| return "CsharpService"; | ||
| default: | ||
| return undefined; | ||
| } | ||
| }; | ||
|
|
||
| const connection = thrift.createXHRConnection(config.webserver_host, config.webserver_port, { | ||
| transport: thrift.TBufferedTransport, | ||
| protocol: thrift.TJSONProtocol, | ||
| https: config.webserver_https, | ||
| path: `${config.webserver_path}/${workspace}/${service()}`, | ||
| }); | ||
| const serviceName = service(); | ||
| if (!serviceName) return; | ||
|
|
Comment on lines
48
to
+56
| useEffect(() => { | ||
| if (!fileInfo) return; | ||
| const init = async () => { | ||
| const initDiagramTypes = await getCppFileDiagramTypes(fileInfo.id as string); | ||
| createClient(appCtx.workspaceId, fileInfo?.type); | ||
| const initDiagramTypes = await getFileDiagramTypes(fileInfo.id as string); | ||
| setDiagramTypes(initDiagramTypes); | ||
| }; | ||
| init(); | ||
| }, [fileInfo]); | ||
| }, [appCtx.workspaceId, fileInfo]); |
Comment on lines
+144
to
+146
| const decorations = highlightRanges.map((pos) => | ||
| createHighlightDecoration(view, pos, highlightColor), | ||
| ) as never; |
Comment on lines
+167
to
+169
| const allReferences = await getReferences( | ||
| astNode.id as string, | ||
| refTypes.get("Usage") as number, |
Comment on lines
+61
to
+75
| const fileInfoForClient = | ||
| appCtx.diagramType === "file" | ||
| ? await getFileInfo(appCtx.diagramGenId) | ||
| : appCtx.diagramType === 'ast' | ||
| ? await getCppAstNodeInfo(appCtx.diagramGenId) | ||
| : undefined; | ||
| : appCtx.projectFileId | ||
| ? await getFileInfo(appCtx.projectFileId) | ||
| : undefined; | ||
|
|
||
| createClient(appCtx.workspaceId, fileInfoForClient?.type); | ||
|
|
||
| const initDiagramInfo = | ||
| appCtx.diagramType === "file" | ||
| ? fileInfoForClient | ||
| : appCtx.diagramType === "ast" | ||
| ? await getAstNodeInfo(appCtx.diagramGenId) | ||
| : undefined; |
Comment on lines
120
to
128
| const parser = new DOMParser(); | ||
| const parsedDiagram = parser.parseFromString(diagram, 'text/xml'); | ||
| const diagramSvg = parsedDiagram.getElementsByTagName('svg')[0]; | ||
| const parsedDiagram = parser.parseFromString(diagram, "text/xml"); | ||
| const diagramSvg = parsedDiagram.getElementsByTagName("svg")[0]; | ||
|
|
||
| diagramSvg.style.height = '100%'; | ||
| diagramSvg.style.cursor = 'pointer'; | ||
| diagramSvg.style.height = "100%"; | ||
| diagramSvg.style.cursor = "pointer"; | ||
|
|
||
| transformComponentRef?.current?.resetTransform(); | ||
| diagramContainerRef?.current?.replaceChildren(diagramSvg); |
Comment on lines
70
to
80
| return _db->query_one<model::File>( | ||
| FileQuery::path == return_.range.file); | ||
| }); | ||
| if (!file) | ||
| { | ||
| LOG(warning) << "[csharpservice] getAstNodeInfo: file not found for path: " << return_.range.file; | ||
| return; | ||
| } | ||
| std::stringstream ss; | ||
| ss << file; | ||
| ss << file->id; | ||
| return_.range.file = ss.str(); |
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

No description provided.