-
Notifications
You must be signed in to change notification settings - Fork 8
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
Display AI panel in code mode #2076
base: main
Are you sure you want to change the base?
Conversation
This fixed the "You attempted to get the value of a helper after the helper was destroyed, which is not allowed" error in "Commands tests: a command sent via SendAiAssistantMessageCommand without autoExecute flag is not automatically executed by the bot"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it in the staging preview, and it works great!
@@ -250,6 +251,9 @@ export default class Room extends Component<Signature> { | |||
messageElemements: new WeakMap(), | |||
messageScrollers: new Map(), | |||
messageVisibilityObserver: new IntersectionObserver((entries) => { | |||
if (isDestroyed(this)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was getting the You attempted to get the value of a helper after the helper was destroyed, which is not allowed"
error in the Commands tests: a command sent via SendAiAssistantMessageCommand without autoExecute flag is not automatically executed by the bot
test.
My guess is that when the AI panel is opened in interactive mode and a switch to code mode happens, the room gets rerendered (due to operator mode state change) and the intersection observer wants to work on the previous room rendering but it can't since it was destroyed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a better approach: 47c35a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this locally, looks good. Nice workaround for the color theme issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the new dark theme looks great
This PR is the first step towards adding AI assistant functionality in code mode (previously it was present in interact mode only). There will be more work to make AI more helpful in the code mode context which will be covered in separate PRs (e.g. adding fields to card definitions, card auto attachment behaviour,...)
There are now 4 columns in case the AI panel is open:
Since there can now be multiple, differently themed Monaco code editors shown on the same page, we have run into a well known issue (microsoft/monaco-editor#338) where monaco editor does not support differently themed editors on the same page:
The reason is that the monaco editor is storing its CSS in a global
<style>
tag and every new instance rendered will override that CSS with the the newly rendered instance's theme.Here is an example of the style tag:
monaco-style-tag.txt
I tried to manipulate this tag's contents by namespacing these selectors (by rewriting them) and have 2 style tags that have all these selectors namespaced for bright and dark monaco theme but the solution seemed too hacky, it resulted in editor flashing, and the repaints needed after manipulating style tags probably caused performance degradations.
Workaround with CSS
filter
One of the suggestions in microsoft/monaco-editor#338 was to use a
filter
to achieve a dark theme to simplify the solution so I went with that. So this means using this piece of code on the white themed editor to achieve the dark themed editor:Potential drawbacks
1️⃣ The dark theme is changed
Old theme (vs-dark theme):
New theme (standard vs theme + css filter):
We can of course tweak the colors by changing the
hue-rotate
param but I thought this value looks pretty good.2️⃣ The dark theme could be unpredictable/inflexible for future requirements
Since the dark theme is a function of the white theme, we can't easily define individual colors in dark theme (can only tweak the css filter).