-
Notifications
You must be signed in to change notification settings - Fork 65
Refine conv tags and log styles #430
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ | |
| } | ||
|
|
||
| ul { | ||
| list-style-position: inside !important; | ||
| list-style-position: outside !important; | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -13,8 +13,7 @@ | |
| Dropdown, | ||
| DropdownToggle, | ||
| DropdownMenu, | ||
| DropdownItem, | ||
| Input | ||
| DropdownItem | ||
| } from '@sveltestrap/sveltestrap'; | ||
| import { | ||
| conversationStore, | ||
|
|
@@ -56,6 +55,7 @@ | |
| import LoadingToComplete from '$lib/common/spinners/LoadingToComplete.svelte'; | ||
| import AudioSpeaker from '$lib/common/audio-player/AudioSpeaker.svelte'; | ||
| import CodeScript from '$lib/common/shared/CodeScript.svelte'; | ||
| import Label from '$lib/common/shared/Label.svelte'; | ||
| import { realtimeChat } from '$lib/services/realtime-chat-service'; | ||
| import { webSpeech } from '$lib/services/web-speech'; | ||
| import LocalStorageManager from '$lib/helpers/utils/storage-manager'; | ||
|
|
@@ -64,7 +64,7 @@ | |
| import { utcToLocal } from '$lib/helpers/datetime'; | ||
| import { replaceNewLine } from '$lib/helpers/http'; | ||
| import { isAudio, isExcel, isPdf } from '$lib/helpers/utils/file'; | ||
| import { ChatAction, ConversationTag, EditorType, FileSourceType, RichType, SenderAction, UserRole } from '$lib/helpers/enums'; | ||
| import { ChatAction, EditorType, FileSourceType, RichType, SenderAction, UserRole } from '$lib/helpers/enums'; | ||
| import ChatTextArea from './chat-util/chat-text-area.svelte'; | ||
| import RichContent from './rich-content/rich-content.svelte'; | ||
| import RcMessage from "./rich-content/rc-message.svelte"; | ||
|
|
@@ -131,12 +131,9 @@ | |
| /** @type {string[]} */ | ||
| let chatUtilOptions = []; | ||
| /** @type {string[]} */ | ||
| let selectedTags = []; | ||
| let convTags = []; | ||
| let newTagText = ''; | ||
|
|
||
| /** @type {import('$commonTypes').KeyValuePair[]} */ | ||
| let tagOptions = Object.entries(ConversationTag).map(([k, v]) => ( | ||
| { key: k, value: v } | ||
| )); | ||
|
|
||
| /** @type {any[]} */ | ||
| let scrollbars = []; | ||
|
|
@@ -239,7 +236,8 @@ | |
| conversation = await getConversation(params.conversationId, true); | ||
| dialogs = await getDialogs(params.conversationId, dialogCount); | ||
| conversationUser = conversation?.user; | ||
| selectedTags = conversation?.tags || []; | ||
| convTags = conversation?.tags || []; | ||
|
|
||
| latestStateLog = conversation?.states; | ||
| initUserSentMessages(dialogs); | ||
| initChatView(); | ||
|
|
@@ -1409,44 +1407,55 @@ | |
| function toggleTagModal() { | ||
| isOpenTagModal = !isOpenTagModal; | ||
| if (!isOpenTagModal) { | ||
| selectedTags = conversation?.tags || []; | ||
| newTagText = ''; | ||
| convTags = conversation?.tags || []; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param {any} e | ||
| * @param {string} value | ||
| */ | ||
| function changeTagSelection(e, value) { | ||
| const checked = e.target.checked; | ||
| if (checked) { | ||
| selectedTags = [...new Set([...selectedTags, value])]; | ||
| } else { | ||
| selectedTags = selectedTags.filter(x => x !== value); | ||
| /** @param {number | string} idx */ | ||
| function removeTag(idx) { | ||
| const tag = convTags?.[/** @type {number} */ (idx)]; | ||
| if (!tag) return; | ||
| convTags = convTags.filter(t => t !== tag); | ||
| } | ||
|
|
||
| function addTag() { | ||
| const tag = _.trim(newTagText); | ||
| if (!tag || convTags.includes(tag)) { | ||
| return; | ||
| } | ||
| convTags = [...convTags, tag]; | ||
| newTagText = ''; | ||
| } | ||
|
|
||
| function updateChatTags() { | ||
| const originalTags = conversation?.tags || []; | ||
| const toAddTags = convTags.filter(t => !originalTags.includes(t)); | ||
| const toDeleteTags = originalTags.filter((/** @type {string} */ t) => !convTags.includes(t)); | ||
|
|
||
| if (toAddTags.length === 0 && toDeleteTags.length === 0) { | ||
| isOpenTagModal = false; | ||
| return; | ||
| } | ||
|
|
||
| isLoading = true; | ||
| updateConversationTags( | ||
| params.conversationId, | ||
| { | ||
| toAddTags: selectedTags, | ||
| toDeleteTags: tagOptions.filter(x => !selectedTags.includes(x.value)).map(x => x.value) | ||
| }) | ||
| { toAddTags, toDeleteTags }) | ||
| .then(res => { | ||
| if (res) { | ||
| conversation.tags = [...convTags]; | ||
| isComplete = true; | ||
| successText = "Tags has been updated!"; | ||
| successText = "Tags have been updated!"; | ||
| setTimeout(() => { | ||
| isComplete = false; | ||
| successText = ""; | ||
| }, duration); | ||
| } else { | ||
| throw "Failed to update chat tags."; | ||
| throw "Failed to update tags."; | ||
| } | ||
| }).catch(() => { | ||
| selectedTags = conversation?.tags || []; | ||
| convTags = conversation?.tags || []; | ||
| isError = true; | ||
| errorText = "Failed to update tags!"; | ||
| setTimeout(() => { | ||
|
Comment on lines
+1436
to
1461
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Tag modal stale state updateChatTags() closes the Tags modal by setting isOpenTagModal=false directly, bypassing toggleTagModal()’s close-time reset of newTagText and convTags. As a result, typed-but-not-added tag text (and other transient state) can persist into subsequent modal openings and lead to unintended edits. Agent Prompt
|
||
|
|
@@ -1567,23 +1576,38 @@ | |
| closeable | ||
| toggleModal={() => toggleTagModal()} | ||
| confirmBtnText={'Confirm'} | ||
| cancelBtnText={'Cancel'} | ||
| cancelBtnText={''} | ||
| confirm={() => updateChatTags()} | ||
| cancel={() => toggleTagModal()} | ||
| close={() => toggleTagModal()} | ||
| > | ||
| <div class="conv-tags-container"> | ||
| {#each tagOptions as op} | ||
| <div class="conv-tag-unit"> | ||
| <Input | ||
| type="checkbox" | ||
| label={op.value} | ||
| checked={selectedTags.includes(op.value)} | ||
| on:change={e => changeTagSelection(e, op.value)} | ||
| /> | ||
| </div> | ||
| {#each convTags as tag, idx} | ||
| <Label | ||
| text={tag} | ||
| index={idx} | ||
| color="info" | ||
| ellipsis | ||
| onClose={removeTag} | ||
| /> | ||
| {/each} | ||
| </div> | ||
| <div class="conv-tag-add"> | ||
| <input | ||
| class="form-control form-control-sm" | ||
| type="text" | ||
| placeholder="Enter new tag..." | ||
| maxlength={50} | ||
| bind:value={newTagText} | ||
| on:keydown={e => { if (e.key === 'Enter') addTag(); }} | ||
| /> | ||
| <button | ||
| class="btn btn-primary btn-sm" | ||
| disabled={!_.trim(newTagText)} | ||
| on:click={() => addTag()} | ||
| > | ||
| <i class="bx bx-plus" /> | ||
| </button> | ||
| </div> | ||
| </DialogModal> | ||
|
|
||
| <DialogModal | ||
|
|
@@ -1763,7 +1787,7 @@ | |
| disabled={disableAction} | ||
| on:click={() => toggleTagModal()} | ||
| > | ||
| Add Tags | ||
| Tags | ||
| </DropdownItem> | ||
| {/if} | ||
| {#if agent?.id === LEARNER_AGENT_ID && mode === TRAINING_MODE} | ||
|
|
||
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.
1. Dash line content corrupted
🐞 Bug✓ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools