-
Notifications
You must be signed in to change notification settings - Fork 12k
server : (webui) revamp the input area, plus many small UI improvements #13365
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
22 commits
Select commit
Hold shift + click to select a range
f4af3f3
rework the input area
ngxson 7d59402
process selected file
ngxson 4476129
change all icons to heroicons
ngxson c8641ef
fix thought process collapse
ngxson 7c87fc4
move conversation more menu to sidebar
ngxson eb0d66d
sun icon --> moon icon
ngxson f994a30
rm default system message
ngxson 9d076e4
stricter upload file check, only allow image if server has mtmd
ngxson d813da8
build it
ngxson 3ff0710
add renaming
ngxson 2a814a7
better autoscroll
ngxson 993b4dd
build
ngxson 47e7314
add conversation group
ngxson 2d2b8de
fix scroll
ngxson 9a24d3f
extra context first, then user input in the end
ngxson b0be033
fix <hr> tag
ngxson ae5a807
clean up a bit
ngxson 2a3cd10
build
ngxson a64f881
add mb-3 for <pre>
ngxson 163bdca
throttle adjustTextareaHeight to make it less laggy
ngxson 3da9380
(nits) missing padding in sidebar
ngxson e7e28bd
rm stray console log
ngxson 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
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
92 changes: 92 additions & 0 deletions
92
tools/server/webui/src/components/ChatInputExtraContextItem.tsx
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { DocumentTextIcon, XMarkIcon } from '@heroicons/react/24/outline'; | ||
import { MessageExtra } from '../utils/types'; | ||
import { useState } from 'react'; | ||
import { classNames } from '../utils/misc'; | ||
|
||
export default function ChatInputExtraContextItem({ | ||
items, | ||
removeItem, | ||
clickToShow, | ||
}: { | ||
items?: MessageExtra[]; | ||
removeItem?: (index: number) => void; | ||
clickToShow?: boolean; | ||
}) { | ||
const [show, setShow] = useState(-1); | ||
const showingItem = show >= 0 ? items?.[show] : undefined; | ||
|
||
if (!items) return null; | ||
|
||
return ( | ||
<div className="flex flex-row gap-4 overflow-x-auto py-2 px-1 mb-1"> | ||
{items.map((item, i) => ( | ||
<div | ||
className="indicator" | ||
key={i} | ||
onClick={() => clickToShow && setShow(i)} | ||
> | ||
{removeItem && ( | ||
<div className="indicator-item indicator-top"> | ||
<button | ||
className="btn btn-neutral btn-sm w-4 h-4 p-0 rounded-full" | ||
onClick={() => removeItem(i)} | ||
> | ||
<XMarkIcon className="h-3 w-3" /> | ||
</button> | ||
</div> | ||
)} | ||
|
||
<div | ||
className={classNames({ | ||
'flex flex-row rounded-md shadow-sm items-center m-0 p-0': true, | ||
'cursor-pointer hover:shadow-md': !!clickToShow, | ||
})} | ||
> | ||
{item.type === 'imageFile' ? ( | ||
<> | ||
<img | ||
src={item.base64Url} | ||
alt={item.name} | ||
className="w-14 h-14 object-cover rounded-md" | ||
/> | ||
</> | ||
) : ( | ||
<> | ||
<div className="w-14 h-14 flex items-center justify-center"> | ||
<DocumentTextIcon className="h-8 w-14 text-base-content/50" /> | ||
</div> | ||
|
||
<div className="text-xs pr-4"> | ||
<b>{item.name ?? 'Extra content'}</b> | ||
</div> | ||
</> | ||
)} | ||
</div> | ||
</div> | ||
))} | ||
|
||
{showingItem && ( | ||
<dialog className="modal modal-open"> | ||
<div className="modal-box"> | ||
<div className="flex justify-between items-center mb-4"> | ||
<b>{showingItem.name ?? 'Extra content'}</b> | ||
<button className="btn btn-ghost btn-sm"> | ||
<XMarkIcon className="h-5 w-5" onClick={() => setShow(-1)} /> | ||
</button> | ||
</div> | ||
{showingItem.type === 'imageFile' ? ( | ||
<img src={showingItem.base64Url} alt={showingItem.name} /> | ||
) : ( | ||
<div className="overflow-x-auto"> | ||
<pre className="whitespace-pre-wrap break-words text-sm"> | ||
{showingItem.content} | ||
</pre> | ||
</div> | ||
)} | ||
</div> | ||
<div className="modal-backdrop" onClick={() => setShow(-1)}></div> | ||
</dialog> | ||
)} | ||
</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.
Uh oh!
There was an error while loading. Please reload this page.
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.
small note @ochafik , we should never reflect user input via the error message, as it usually comes with security risks. In this case, it's not a security risk, but it's a bit inconvenient to display the error in the UI
If you want to print the input for debugging, consider using LOG_DBG