-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(ui): llm conversation about error #34750
Merged
Merged
Changes from 33 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
9dc816f
feat(ui): llm conversation about error
Skn0tt 75c239b
implement proper sse
Skn0tt 4708672
merge llm files
Skn0tt 9bc2c28
move into cookies
Skn0tt e08c0cf
move into utils
Skn0tt 5a796fd
also support in trace viewer
Skn0tt 9039c59
strip header
Skn0tt 2d11c29
more
Skn0tt 8e562bb
types
Skn0tt 6662cfc
sticky input
Skn0tt 1388043
give each error own button state
Skn0tt 6e910d9
toggle
Skn0tt a3f2984
more
Skn0tt e6b81d8
Merge branch 'main' into ai-error-conversation
Skn0tt a91775e
fix aborting
Skn0tt 3cbd591
key on walltime
Skn0tt c58566c
more
Skn0tt 30d3291
more
Skn0tt 3a8ba54
rewrite first
Skn0tt 956a66a
migrate second
Skn0tt 37d842c
remove experimental
Skn0tt 7967e6a
lint
Skn0tt 554ef49
add divider
Skn0tt 8af86e4
stable
Skn0tt a142e9e
Merge branch 'main' into ai-error-conversation
Skn0tt d6ece15
regen package-lock
Skn0tt 7d93780
another try
Skn0tt 6ac8641
another try
Skn0tt fa81f6f
fix package
Skn0tt 366fde1
lint
Skn0tt 11cd84f
make chat creation explicit
Skn0tt 98a2202
more refactoring
Skn0tt 5890b03
use smaller library
Skn0tt 6ac45df
remove unused import
Skn0tt 7aed043
update test
Skn0tt fe50345
fix deps checker
Skn0tt 6ee931c
apply feedback
Skn0tt 2005471
fix package-lock
Skn0tt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
.chat-container { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
color: #e0e0e0; | ||
} | ||
|
||
.chat-disclaimer { | ||
text-align: center; | ||
color: var(--vscode-editorBracketMatch-border); | ||
margin: 0px; | ||
} | ||
|
||
.chat-container hr { | ||
width: 100%; | ||
border: none; | ||
border-top: 1px solid var(--vscode-titleBar-inactiveBackground); | ||
} | ||
|
||
.messages-container { | ||
Skn0tt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
flex: 1; | ||
overflow-y: auto; | ||
padding: 16px; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
gap: 16px; | ||
} | ||
|
||
.message { | ||
gap: 12px; | ||
Skn0tt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
max-width: 85%; | ||
} | ||
|
||
.user-message { | ||
flex-direction: row-reverse; | ||
margin-left: auto; | ||
width: fit-content | ||
} | ||
|
||
.message-icon { | ||
width: 32px; | ||
height: 32px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background-color: var(--vscode-titleBar-inactiveBackground); | ||
flex-shrink: 0; | ||
} | ||
|
||
.message-content { | ||
background-color: var(--vscode-titleBar-inactiveBackground); | ||
Skn0tt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
color: var(--vscode-titleBar-activeForeground); | ||
padding: 2px 8px; | ||
} | ||
|
||
.message-content pre { | ||
text-wrap: auto; | ||
overflow-wrap: anywhere; | ||
} | ||
|
||
.user-message .message-content { | ||
background-color: var(--vscode-titleBar-activeBackground); | ||
} | ||
|
||
/* Input form styles */ | ||
.input-form { | ||
position: sticky; | ||
bottom: 0; | ||
display: flex; | ||
height: 64px; | ||
gap: 8px; | ||
padding: 10px; | ||
background-color: var(--vscode-sideBar-background); | ||
border-top: 1px solid var(--vscode-sideBarSectionHeader-border); | ||
} | ||
|
||
.message-input { | ||
flex: 1; | ||
padding: 8px 12px; | ||
border: 1px solid var(--vscode-settings-textInputBorder); | ||
background-color: var(--vscode-settings-textInputBackground); | ||
font-size: 14px; | ||
outline: none; | ||
transition: border-color 0.2s; | ||
} | ||
|
||
.message-input:focus { | ||
border-color: #0078d4; | ||
} | ||
|
||
.send-button { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 8px; | ||
background-color: var(--vscode-button-background); | ||
border: none; | ||
color: white; | ||
cursor: pointer; | ||
transition: background-color 0.2s; | ||
} | ||
|
||
.send-button:hover { | ||
background-color: var(--vscode-button-hoverBackground); | ||
} | ||
|
||
.send-button:disabled { | ||
background-color: var(--vscode-disabledForeground); | ||
cursor: not-allowed; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* Copyright (c) Microsoft Corporation. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { useCallback, useState } from 'react'; | ||
import Markdown from 'markdown-to-jsx'; | ||
import './aiConversation.css'; | ||
import { clsx } from '@web/uiUtils'; | ||
import { useLLMConversation } from './llm'; | ||
|
||
export function AIConversation({ conversationId }: { conversationId: string }) { | ||
const [history, conversation] = useLLMConversation(conversationId); | ||
const [input, setInput] = useState(''); | ||
|
||
const onSubmit = useCallback(() => { | ||
setInput(content => { | ||
conversation.send(content); | ||
return ''; | ||
}); | ||
}, [conversation]); | ||
|
||
return ( | ||
<div className='chat-container'> | ||
<p className='chat-disclaimer'>Chat based on {conversation.chat.api.name}. Check for mistakes.</p> | ||
<hr/> | ||
<div className='messages-container'> | ||
{history.filter(({ role }) => role !== 'developer').map((message, index) => ( | ||
<div | ||
key={'' + index} | ||
Skn0tt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
className={clsx('message', message.role === 'user' && 'user-message')} | ||
> | ||
{message.role === 'assistant' && ( | ||
<div className='message-icon'> | ||
<img src='playwright-logo.svg' /> | ||
</div> | ||
)} | ||
<div className='message-content'> | ||
<Markdown>{message.displayContent ?? message.content}</Markdown> | ||
Skn0tt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
</div> | ||
))} | ||
</div> | ||
|
||
<div className='input-form'> | ||
<textarea | ||
name='content' | ||
value={input} | ||
onChange={e => setInput(e.target.value)} | ||
onKeyDown={e => { | ||
if (e.key === 'Enter' && !e.shiftKey) { | ||
e.preventDefault(); | ||
onSubmit(); | ||
} | ||
}} | ||
placeholder='Ask a question...' | ||
className='message-input' | ||
/> | ||
{conversation.isSending() ? ( | ||
<button type='button' className='send-button' onClick={evt => { | ||
evt.preventDefault(); | ||
conversation.abortSending(); | ||
}}> | ||
Cancel | ||
</button> | ||
) : ( | ||
<button className='send-button' disabled={!input.trim()} onClick={onSubmit}> | ||
Send | ||
</button> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
This appears to not work with
PW_HMR
.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.
let me follow up on that