-
Notifications
You must be signed in to change notification settings - Fork 219
feat: display session ID and custom title in chat UI #129
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
Open
dbasclpy
wants to merge
2
commits into
matt1398:main
Choose a base branch
from
dbasclpy:feat/session-id-display
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 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
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 |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { CopyButton } from '@renderer/components/common/CopyButton'; | ||
| import { useStore } from '@renderer/store'; | ||
| import { Hash, Terminal } from 'lucide-react'; | ||
| import { useShallow } from 'zustand/react/shallow'; | ||
|
|
||
| interface SessionInfoBarProps { | ||
| readonly tabId?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Compact info strip showing the current session UUID with copy actions. | ||
| * Sits between SearchBar and ChatHistory in MiddlePanel so users can | ||
| * quickly grab the session ID or `claude --resume <id>` command. | ||
| */ | ||
| export const SessionInfoBar: React.FC<SessionInfoBarProps> = ({ tabId }) => { | ||
| const { sessionDetail } = useStore( | ||
| useShallow((s) => { | ||
| const td = tabId ? s.tabSessionData[tabId] : null; | ||
| return { sessionDetail: td?.sessionDetail ?? s.sessionDetail }; | ||
| }), | ||
| ); | ||
|
|
||
| if (!sessionDetail) return null; | ||
|
|
||
| const sessionId = sessionDetail.session.id; | ||
| const resumeCommand = `claude --resume ${sessionId}`; | ||
| const shortId = sessionId.slice(0, 8); | ||
|
|
||
| return ( | ||
| <div | ||
| className="flex shrink-0 items-center gap-2 border-b px-3" | ||
| style={{ | ||
| height: '28px', | ||
| borderColor: 'var(--color-border)', | ||
| backgroundColor: 'var(--color-surface-raised)', | ||
| }} | ||
| > | ||
| <Hash | ||
| className="size-3 shrink-0" | ||
| style={{ color: 'var(--color-text-muted)', opacity: 0.7 }} | ||
| /> | ||
| <span | ||
| className="select-all font-mono" | ||
| title={sessionId} | ||
| style={{ | ||
| fontSize: '10px', | ||
| color: 'var(--color-text-muted)', | ||
| opacity: 0.8, | ||
| }} | ||
| > | ||
| {shortId} | ||
| </span> | ||
| <CopyButton text={sessionId} inline /> | ||
| <div | ||
| className="mx-1 h-3 border-l" | ||
| style={{ borderColor: 'var(--color-border)' }} | ||
| /> | ||
| <button | ||
| onClick={() => { | ||
| navigator.clipboard.writeText(resumeCommand).catch(() => { | ||
| // Clipboard API may be unavailable in some environments | ||
| }); | ||
| }} | ||
| className="flex items-center gap-1 rounded px-1 py-0.5 transition-colors hover:opacity-80" | ||
| title={resumeCommand} | ||
| style={{ color: 'var(--color-text-muted)' }} | ||
| > | ||
| <Terminal className="size-3" /> | ||
| <span style={{ fontSize: '10px' }}>Resume</span> | ||
| </button> | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| ); | ||
| }; | ||
dbasclpy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
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.
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 type assertion to
Record<string, unknown>is necessary because theentryvariable was optimistically cast toChatHistoryEntrywhen parsed from JSON. However, acustom-titleentry is not a validChatHistoryEntry, leading to this type-unsound workaround.A more robust and type-safe approach would be to parse the JSON into a generic type (like
unknownorRecord<string, unknown>) and then use type guards to safely narrow it down to either acustom-titleentry or aChatHistoryEntry.While a full fix would involve changing code outside of this diff, I recommend refactoring this in the future to improve type safety and avoid these kinds of workarounds.
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.
Good catch. Added mtime+size cache matching the existing sessionPreviewCache pattern. Fixed in 481c382.