-
Notifications
You must be signed in to change notification settings - Fork 522
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
fix(ai-help): send correct context when editing question #10511
Conversation
We defaulted to the 0 when traversing the tree for context. This breaks editing question.
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.
Can you add unit tests for the stateToMessagePath()
function?
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.
LGTM, and tested locally, just two nits:
- Making the third parameter of
stateToMessagePath()
an options object. - Updating the PR description (I already added screenshots) to reflect the latest insights of what the problem and solution was (it wasn't only defaulting to 0, was it?).
@@ -110,27 +110,32 @@ export interface MessageTreeState { | |||
|
|||
export function stateToMessagePath( | |||
state: MessageTreeState, | |||
path: number[] | |||
path: number[], | |||
traverseWithDefault: boolean = false |
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.
Sorry, one last nit is that it would be better to make this an options object:
traverseWithDefault: boolean = false | |
{ traverseWithDefault = false }: { traverseWithDefault: boolean } |
Like this, it is more clear where we're calling it what the true
stands for.
Summary
Traverse the message tree in a correct way when gathering context.
Problem
We sent the wrong context when editing the first question (namely including the question/answer of the original version of the question), because we defaulted to 0 when traversing the message tree for context.
Solution
Add a
traverseWithDefault
flag to only default to 0 when initializing.Screenshots