-
Notifications
You must be signed in to change notification settings - Fork 749
feat(amazonq): conversation persistence, view and search chat history #6893
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
Conversation
|
259581d to
e2f0a2d
Compare
|
/runIntegrationTests |
| if (e.key === 'Escape') { | ||
| this.closeList() | ||
| } else if (e.key === 'Enter') { | ||
| // todo: call onItemSelect on Enter |
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.
waiting for mynah-ui to provide TargetElementId, should be included in prod release tomorrow
| "js-yaml": "^4.1.0", | ||
| "jsonc-parser": "^3.2.0", | ||
| "lodash": "^4.17.21", | ||
| "lokijs": "^1.5.12", |
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.
why is this required? what alternatives were considered? are you confidence this package will be actively maintained?
is https://github.com/techfort/LokiJS/pulse the correct repo for it? no activity for 3 years.
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.
Yes thats the correct repo, and based on my research its stable and widely used. its a pretty lightweight library with 500k+ weekly downloads https://www.npmjs.com/package/lokijs
LokiJS includes helpful functionality out of the box like autoload, autosave, finding elements, and updating elements, and was easy to use. Alternatives considered were better-sqlite3 and sqlite3 but those are not web-compatible
| initialized: boolean = false | ||
|
|
||
| constructor() { | ||
| this.dbDirectory = path.join(fs.getUserHomeDir(), '.aws', 'amazonq', 'history') |
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.
It is never required to join() string literals. Not on Windows, nor anywhere else. "/" slashes work fine.
| this.dbDirectory = path.join(fs.getUserHomeDir(), '.aws', 'amazonq', 'history') | |
| this.dbDirectory = path.join(fs.getUserHomeDir(), '.aws/amazonq/history') |
| // Case 1: .code-workspace file (saved workspace) | ||
| const workspace = vscode.workspace.workspaceFile | ||
| if (workspace) { | ||
| crypto.createHash('md5').update(workspace.fsPath).digest('hex') |
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.
maybe just return at L62
| await this.ensureDirectory() | ||
| const filename = path.join(this.directory, dbname) | ||
|
|
||
| await fs.writeFile(filename, dbstring, 'utf8') |
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.
what happens if the history is corrupted or has partial writes, or multiple vscode instances try to save the file simultaneously? on Windows, this will have problems.
if you are ok with the current limitations, the limitations should be cleary called-out in the docstring for FileSystemAdapter (which currently has no docstring).
|
/runIntegrationTests |
| "@aws-sdk/smithy-client": "<3.731.0", | ||
| "@aws-sdk/util-arn-parser": "<3.731.0", | ||
| "@aws/mynah-ui": "^4.26.1", | ||
| "@aws/mynah-ui": "^4.27.0", |
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 will be done by #6901
161f730 to
e5b017b
Compare
|
/runIntegrationTests |
e5b017b to
a1ef003
Compare
|
Rebased with master |
| export enum ClientType { | ||
| VSCode = 'IDE-VSCode', | ||
| JetBrains = 'IDE_JetBrains', | ||
| CLI = 'CLI', |
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.
CLI does not use mynah-ui, does it? What is the plan to make CLI work with the history, given native mynah-ui types, like ChatItem, are stored in it?
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 was just added in here as a placeholder in case we ever had a shared history store in the future
| import path from 'path' | ||
|
|
||
| import { TabType } from '../../../amazonq/webview/ui/storages/tabsStorage' | ||
| import { ChatItem, ChatItemButton, DetailedListItem, DetailedListItemGroup, MynahIconsType } from '@aws/mynah-ui' |
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.
It looks like you store native mynah-ui types into history. It can be not straightforward to migrate this to language-servers while preserving history. There's protocol abstracting UI from chat server business logic, meaning types in chat language server are non-UI specific.
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.
we could create a new type in flare, in history we are storing an object for each message that has body, type, codeReference, and relatedContent. so as long as we keep those four properties we can be backwards compatible
Problem
Users lose all chats when they close VSCode, and there's no way to browse through chat history. Users also cant export their conversations to an easily shareable format.
Solution
Automatically persist conversations to JSON files in
~/.aws/amazonq/history, one for each workspace where Amazon Q chats occur. Add chat history and chat export buttons to top of Amazon Q toolbar. Clicking on the chat history button allows users to browse and search through chat history. Users click on an old conversation to open it back up (currently open conversations are in bold). Clicking on chat export button allows users to save chat transcript as a markdown or html.Note: persistence + history is only for Q Chat Tabs (not /dev, /doc, /transform, etc.)
feature/xbranches will not be squash-merged at release time.