Skip to content
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

[Obs AI Assistant] Fix error when opening an old conversation #197745

Merged

Conversation

viduni94
Copy link
Contributor

@viduni94 viduni94 commented Oct 24, 2024

Closes #176299

Summary

Problem

When a chat is started from contextual insights, initialMessages are being populated from the temp conversation created from the error. Because the initialMessages are present, when an old conversation is clicked, the conversation ID of that conversation and the initalMessages from the temp chat are passed to the conversation. This throws an error, as there is a condition which restricts both of these being passed to useConversation which is used by the ChatBody.

  • Only one of these should be passed (not both)

Solution

With the current implementation, even though not passing initialMessages allows the user to open previous conversations successfully, it doesn't allow the user to start a new chat because as long as initial messages are set, they will be loaded when the New Chat button is clicked instead of showing a blank conversation. Clearing initial messages requires re-architecting how the Chat uses the conversation.

Therefore, as the solution, when a chat is opened from contextual insights, the ConversationList will be hidden. The user can interact with the AI Assistant on the opened chat with initial messages from contextual insights.

@viduni94 viduni94 added the Team:Obs AI Assistant Observability AI Assistant label Oct 24, 2024
@viduni94 viduni94 self-assigned this Oct 24, 2024
@viduni94 viduni94 force-pushed the fix-error-when-opening-old-conversations branch 3 times, most recently from 6c47645 to c6750a5 Compare October 29, 2024 20:46
@viduni94 viduni94 marked this pull request as ready for review October 29, 2024 21:18
@viduni94 viduni94 requested review from a team as code owners October 29, 2024 21:18
@viduni94 viduni94 force-pushed the fix-error-when-opening-old-conversations branch from 472203c to 40ce4ee Compare October 29, 2024 21:18
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant)

@botelastic botelastic bot added the ci:project-deploy-observability Create an Observability project label Oct 29, 2024
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@viduni94 viduni94 added release_note:fix v8.17.0 backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Oct 29, 2024
@viduni94 viduni94 force-pushed the fix-error-when-opening-old-conversations branch from 40ce4ee to 48e5e4c Compare October 29, 2024 21:22
@viduni94 viduni94 requested a review from sorenlouv October 29, 2024 23:36
@viduni94
Copy link
Contributor Author

Hi @sorenlouv
I completed the implementation we discussed earlier today about hiding the previous conversations when navigated from contextual insights.
Hope you could review this and let me know if any changes are needed.

Thanks a lot.

@viduni94 viduni94 force-pushed the fix-error-when-opening-old-conversations branch from 0da77dd to 98e0e2f Compare October 31, 2024 13:43
@viduni94 viduni94 added backport:version Backport to applied version labels and removed backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Oct 31, 2024
@viduni94 viduni94 force-pushed the fix-error-when-opening-old-conversations branch from 98e0e2f to e343c9f Compare October 31, 2024 15:03
@viduni94 viduni94 force-pushed the fix-error-when-opening-old-conversations branch from e343c9f to 9190939 Compare October 31, 2024 17:01
@elasticmachine
Copy link
Contributor

elasticmachine commented Oct 31, 2024

💚 Build Succeeded

  • Buildkite Build
  • Commit: 9190939
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-197745-919093914429

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/ai-assistant 63 64 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
observabilityAIAssistant 19.1KB 19.1KB +24.0B
observabilityAIAssistantApp 239.0KB 239.1KB +102.0B
searchAssistant 161.9KB 161.9KB +30.0B
total +156.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
observabilityAIAssistant 47.0KB 47.1KB +49.0B
Unknown metric groups

API count

id before after diff
@kbn/ai-assistant 63 64 +1

History

cc @viduni94

@viduni94 viduni94 merged commit 287c1ec into elastic:main Oct 31, 2024
24 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11618424531

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 31, 2024
…c#197745)

Closes elastic#176299

## Summary

### Problem

When a chat is started from contextual insights, `initialMessages` are
being populated from the temp conversation created from the error.
Because the `initialMessages` are present, when an old conversation is
clicked, the conversation ID of that conversation and the
`initalMessages` from the temp chat are passed to the conversation. This
throws an error, as there is a condition which restricts both of these
being passed to `useConversation` which is used by the `ChatBody`.
- Only one of these should be passed (not both)

### Solution
With the current implementation, even though not passing
`initialMessages` allows the user to open previous conversations
successfully, it doesn't allow the user to start a new chat because as
long as initial messages are set, they will be loaded when the New Chat
button is clicked instead of showing a blank conversation. Clearing
initial messages requires re-architecting how the Chat uses the
conversation.

Therefore, as the solution, when a chat is opened from contextual
insights, the ConversationList will be hidden. The user can interact
with the AI Assistant on the opened chat with initial messages from
contextual insights.

(cherry picked from commit 287c1ec)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 31, 2024
…197745) (#198611)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Obs AI Assistant] Fix error when opening an old conversation
(#197745)](#197745)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Viduni
Wickramarachchi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-31T19:16:52Z","message":"[Obs
AI Assistant] Fix error when opening an old conversation
(#197745)\n\nCloses
https://github.com/elastic/kibana/issues/176299\r\n\r\n##
Summary\r\n\r\n### Problem\r\n\r\nWhen a chat is started from contextual
insights, `initialMessages` are\r\nbeing populated from the temp
conversation created from the error.\r\nBecause the `initialMessages`
are present, when an old conversation is\r\nclicked, the conversation ID
of that conversation and the\r\n`initalMessages` from the temp chat are
passed to the conversation. This\r\nthrows an error, as there is a
condition which restricts both of these\r\nbeing passed to
`useConversation` which is used by the `ChatBody`.\r\n- Only one of
these should be passed (not both)\r\n\r\n### Solution\r\nWith the
current implementation, even though not passing\r\n`initialMessages`
allows the user to open previous conversations\r\nsuccessfully, it
doesn't allow the user to start a new chat because as\r\nlong as initial
messages are set, they will be loaded when the New Chat\r\nbutton is
clicked instead of showing a blank conversation. Clearing\r\ninitial
messages requires re-architecting how the Chat uses
the\r\nconversation.\r\n\r\nTherefore, as the solution, when a chat is
opened from contextual\r\ninsights, the ConversationList will be hidden.
The user can interact\r\nwith the AI Assistant on the opened chat with
initial messages from\r\ncontextual
insights.","sha":"287c1ec62e8ae64e58ea3abf561ab626e7530d43","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","Team:Obs
AI
Assistant","ci:project-deploy-observability","backport:version","v8.17.0"],"title":"[Obs
AI Assistant] Fix error when opening an old
conversation","number":197745,"url":"https://github.com/elastic/kibana/pull/197745","mergeCommit":{"message":"[Obs
AI Assistant] Fix error when opening an old conversation
(#197745)\n\nCloses
https://github.com/elastic/kibana/issues/176299\r\n\r\n##
Summary\r\n\r\n### Problem\r\n\r\nWhen a chat is started from contextual
insights, `initialMessages` are\r\nbeing populated from the temp
conversation created from the error.\r\nBecause the `initialMessages`
are present, when an old conversation is\r\nclicked, the conversation ID
of that conversation and the\r\n`initalMessages` from the temp chat are
passed to the conversation. This\r\nthrows an error, as there is a
condition which restricts both of these\r\nbeing passed to
`useConversation` which is used by the `ChatBody`.\r\n- Only one of
these should be passed (not both)\r\n\r\n### Solution\r\nWith the
current implementation, even though not passing\r\n`initialMessages`
allows the user to open previous conversations\r\nsuccessfully, it
doesn't allow the user to start a new chat because as\r\nlong as initial
messages are set, they will be loaded when the New Chat\r\nbutton is
clicked instead of showing a blank conversation. Clearing\r\ninitial
messages requires re-architecting how the Chat uses
the\r\nconversation.\r\n\r\nTherefore, as the solution, when a chat is
opened from contextual\r\ninsights, the ConversationList will be hidden.
The user can interact\r\nwith the AI Assistant on the opened chat with
initial messages from\r\ncontextual
insights.","sha":"287c1ec62e8ae64e58ea3abf561ab626e7530d43"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197745","number":197745,"mergeCommit":{"message":"[Obs
AI Assistant] Fix error when opening an old conversation
(#197745)\n\nCloses
https://github.com/elastic/kibana/issues/176299\r\n\r\n##
Summary\r\n\r\n### Problem\r\n\r\nWhen a chat is started from contextual
insights, `initialMessages` are\r\nbeing populated from the temp
conversation created from the error.\r\nBecause the `initialMessages`
are present, when an old conversation is\r\nclicked, the conversation ID
of that conversation and the\r\n`initalMessages` from the temp chat are
passed to the conversation. This\r\nthrows an error, as there is a
condition which restricts both of these\r\nbeing passed to
`useConversation` which is used by the `ChatBody`.\r\n- Only one of
these should be passed (not both)\r\n\r\n### Solution\r\nWith the
current implementation, even though not passing\r\n`initialMessages`
allows the user to open previous conversations\r\nsuccessfully, it
doesn't allow the user to start a new chat because as\r\nlong as initial
messages are set, they will be loaded when the New Chat\r\nbutton is
clicked instead of showing a blank conversation. Clearing\r\ninitial
messages requires re-architecting how the Chat uses
the\r\nconversation.\r\n\r\nTherefore, as the solution, when a chat is
opened from contextual\r\ninsights, the ConversationList will be hidden.
The user can interact\r\nwith the AI Assistant on the opened chat with
initial messages from\r\ncontextual
insights.","sha":"287c1ec62e8ae64e58ea3abf561ab626e7530d43"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Viduni Wickramarachchi <[email protected]>
nreese pushed a commit to nreese/kibana that referenced this pull request Nov 1, 2024
…c#197745)

Closes elastic#176299

## Summary

### Problem

When a chat is started from contextual insights, `initialMessages` are
being populated from the temp conversation created from the error.
Because the `initialMessages` are present, when an old conversation is
clicked, the conversation ID of that conversation and the
`initalMessages` from the temp chat are passed to the conversation. This
throws an error, as there is a condition which restricts both of these
being passed to `useConversation` which is used by the `ChatBody`.
- Only one of these should be passed (not both)

### Solution
With the current implementation, even though not passing
`initialMessages` allows the user to open previous conversations
successfully, it doesn't allow the user to start a new chat because as
long as initial messages are set, they will be loaded when the New Chat
button is clicked instead of showing a blank conversation. Clearing
initial messages requires re-architecting how the Chat uses the
conversation.

Therefore, as the solution, when a chat is opened from contextual
insights, the ConversationList will be hidden. The user can interact
with the AI Assistant on the opened chat with initial messages from
contextual insights.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels ci:project-deploy-observability Create an Observability project release_note:fix Team:Obs AI Assistant Observability AI Assistant v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Obs AI Assistant] error when opening old conversation
5 participants