Fix #64: Render copilot conversations including Markdown tables in SWT web browser widget#330
Fix #64: Render copilot conversations including Markdown tables in SWT web browser widget#330travkin79 wants to merge 9 commits into
Conversation
728eb45 to
6e4f73e
Compare
485efc7 to
8734279
Compare
|
@travkin79 This is a big change. But from the screenshot, the modern ui rendering result looks charming. @iloveeclipse What do you think of this? I somehow towards the web tech but need to make sure this works fine in different platform, I'm not worry for Mac and Windows, but for Linux, I'm not sure. |
|
I haven't tried this patch on my RHEL 9.6 yet (I'm busy with other tasks), so just few questions:
... May be more. In general, if that is going to be added, a fallback would be nice because each platform has its own quirks with browser and/or OS (Linux & Mac: webkit but different UI toolkits, Windows: Edge or IE for ancient systems). But that would mean to keep double implementation & tests for some time. |
|
Hi @jdneo and @iloveeclipse, Thank you for your feedback. @jdneo, I'm glad you like the new look. @iloveeclipse, I'm currently testing all the features, there are many of them in the chat view. I will also check the things you mentioned. One thing making the migration a little easier is: we're only changing the conversation rendering (user and copilot turns), all SWT widgets for the user input shown below the conversation and also the tool bar remain SWT widgets and they work as before. The buttons rendered in the conversation are the ones that change and need proper attention while testing. At the moment I'm testing on Windows 11 and there are still some minor issues I'm fixing step by step. I could also test on MacOS Tahoe (Intel) and on RHEL 9.6. I think, testing all the migrated features is the main effort here. We could add the new preference for switching between old and new rendering to the copilot preferences UI in case we want to maintain both rendering implementations for a while. |
Yes we can have a setting to progressively roll out this feature. I haven't deeply looked into the code, just having a general design question regard the implementation: For the frontend implementation, how is the current state management looks like? Is it complex? I'm thinking if it is necessary to introduce things like React and Redux. |
The state management is kept very simple, only on Java side. Adding JavaScript frameworks like React, Redux, Vue.js, Svelte, etc. is just not necessary. I tried making the implementation as simple as possible, simplifying debugging and code maintenance. My goal was to keep as much existing code unchanged as possible and leaving the domain knowledge in Java. The state management is kept completely in Java code (mainly in |
8734279 to
7f7d1ae
Compare
…nversations - Introduce SWT-browser-based widget for rendering conversations in copilot chat view - Introduce common interface for the existing StyledText-based conversation rendering and the new browser-based conversation rendering - Introduce commonmark Markdown parser and HTML renderer with extensions to properly render GitHub-Flavoured Markdown tables (and task item lists), i.e. fix issue microsoft#64 - Introduce preference for switching between StyledText-based SWT rendering and browser-based HTML rendering Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Wrap the chatViewSideEffect disposal in ensureRealm() to guarantee it runs on the correct data binding Realm thread, preventing potential InvalidThreadAccessException when unbinding from a non-UI thread. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace preference-based theme detection with the proper IThemeEngine service API. The previous approach read the theme ID from preferences which could be stale or unavailable. The new approach queries the active theme directly via IThemeEngine.getActiveTheme(). We're using reflection in order not to introduce a dependency to the SWT themes bundle and to avoid discouraged access warnings. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Update subagent card factory test for header
Cover UiUtils.isDarkTheme() with mocked PlatformUI/Platform statics: WITH e4 CSS theming (dark id, light id, mixed-case id, and a null active theme falling back to the preference) and WITHOUT theming (theme bundle absent, theme service null, and a reflective loadClass failure) — all of which must degrade to the persisted themeid preference and finally to light without throwing. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Add 'Compare Chat View Rendering Alternatives' Copilot menu entry - Opens both rendering alternatives in one dialog, side by side, for visual comparison Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Both the browser-based (HTML) and the seasoned StyledText renderers ship behind the useBrowserBasedChatRenderer preference, so both need probe coverage. Select the renderer per launch instead of hardcoding it. - ProbeRunner: read -Dprobe.renderer (browser | styledtext) and set USE_BROWSER_BASED_CHAT_RENDERER accordingly. Default styledtext matches the production default, so plain runs still exercise the SWT widget tree. - chat-send-receive-001.json: restored to the strong StyledText widget-tree assertions (user-turn, copilot-turn, model-info-label) for the default renderer. - chat-send-receive-browser-001.json (new): browser-renderer variant that asserts the Browser widget exists, then uses sleep + screenshot because the HTML DOM is opaque to SWTBot widget locators. - REFERENCE.md: document the -Dprobe.renderer property and the two-probe workflow for covering both renderers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
7f7d1ae to
4f22cc9
Compare
This PR fixes rendering Markdown tables (GitHub-flavoured Markdown syntax) by introducing a new browser-based rendering approach based on an Eclipse-internal SWT web browser and HTML code created by converting Markdown to HTML using commonmark.
The new rendering approach is encapsulated in a
BrowserConversationWidget. It does only cover conversations in the chat view. The other SWT widgets in the chat view stay unchanged, i.e. the input field, send button, toolbar, etc. For better comparison, the existing copilot conversation rendering is kept working. A new preference allows switching between both approaches. The currently used rendering approach was extracted toStyledTextConversationWidget. Both classes implement the new common interfaceIConversationWidget. After extensive review and testing, I'd suggest to eventually removeStyledTextConversationWidgetand the corresponding new preference for switching between theStyledText-based rendering and the new browser-based rendering.The
BrowserConversationWidgetrenders HTMLDIVcode blocks representing existing SWT widgets like user / copilot turns, copilot replies, thinking, tool calls, tool confirmation UI, etc. Instead of re-rendering the whole conversation of long copilot turn HTML blocks, theBrowserConversationWidgetonly inserts new or modifies existing HTML code blocks / attributes to efficiently update the rendered HTML, e.g. while copilot is streaming a reply or thinking text. The look in theBrowserConversationWidgetis made very similar to the existingStyleText-based chat view implementation, i.e. it uses the same colors (but in separate CSS files since the e4 CSS files could not be re-used directly), same interaction features and behavior, e.g. automatically collapses a thinking block as soon as thinking finishes, etc. The JavaScript code in the HTML rendering template is kept very simple, the domain knowledge is kept in Java code.Switching between both rendering approaches can be done using a new Copilot preference:

Interaction between
BrowserConversationWidgetand the JavaScript code in the web browser:This PR includes a few additional fixes. I extracted them into separate commits in order to make reviews easier.
For convenience while testing (in a separate git branch), I also added a new target definition file and launch configs for running the Eclipse IDE with all bundles necessary for testing the two rendering approaches with and without themes support.
target-2025-09.targetas active target platform, firstlaunch/Copilot4e with Themes.launchlaunch/Copilot4e without Themes.launchlaunch/Copilot4e (compare chat view rendering approaches).launchfor side-by-side comparison (otherwise, i.e. without thecom.microsoft.copilot.eclipse.ui.testbundle, the corresponding menu entry is not available, details below)I added a Copilot menu entry for opening the two rendering alternatives side by side for visual comparison (only available in

com.microsoft.copilot.eclipse.ui.testbundle).Most elements visible in a conversation widget (user turns, copilot turns, tool calls, thinking, sub-agent calls, etc. in various statuses) are rendered here with both rendering approaches side by side using some artificial data. You can switch between dark and light theme, too. This way, you can easily check if the conversation details are rendered in the browser-based widget as you would expect them to be rendered.
Performance
I didn't compare the rendering performance of both approaches, but I implemented the browser-based rendering in such a way that only tiny DOM manipulations are needed during conversation widget content updates (e.g. adding single words while copilot is in thinking state). While testing with exemplary requests to copilot I didn't see any observable slow-downs.