fix: simplify context raw message rows
This commit is contained in:
@@ -16,7 +16,6 @@ import {
|
|||||||
deriveUserSnippet,
|
deriveUserSnippet,
|
||||||
formatAssistantTokens,
|
formatAssistantTokens,
|
||||||
formatMessagePreviewTime,
|
formatMessagePreviewTime,
|
||||||
truncateMessageId,
|
|
||||||
} from './rawMessagePreview';
|
} from './rawMessagePreview';
|
||||||
import type { TimeFormatPreference } from '@/stores/useUIStore';
|
import type { TimeFormatPreference } from '@/stores/useUIStore';
|
||||||
import { formatDateTimeForPreference } from '@/lib/timeFormat';
|
import { formatDateTimeForPreference } from '@/lib/timeFormat';
|
||||||
@@ -544,23 +543,15 @@ export const ContextPanelContent: React.FC = () => {
|
|||||||
const partsLabel = derivePartsLabel(message.parts);
|
const partsLabel = derivePartsLabel(message.parts);
|
||||||
const tokens = isAssistant ? extractTokenBreakdown({ info: message.info, parts: message.parts }) : null;
|
const tokens = isAssistant ? extractTokenBreakdown({ info: message.info, parts: message.parts }) : null;
|
||||||
const userSnippet = isUser ? deriveUserSnippet(message.parts) : '';
|
const userSnippet = isUser ? deriveUserSnippet(message.parts) : '';
|
||||||
const shortId = truncateMessageId(message.info.id);
|
|
||||||
const previewTime = formatMessagePreviewTime(messageCreatedAt, timeFormatPreference);
|
const previewTime = formatMessagePreviewTime(messageCreatedAt, timeFormatPreference);
|
||||||
// User rows merge the first two columns into a single inline
|
// Keep token/time columns stable; the message label owns all
|
||||||
// block: `**user:** <snippet>`. The bold prefix anchors the eye
|
// remaining space and truncates before it can push metrics.
|
||||||
// to the start of the block; the snippet flows inline until the
|
|
||||||
// truncation point chosen by CSS.
|
|
||||||
//
|
|
||||||
// Assistant rows keep two cells: parts label on the left, I/O
|
|
||||||
// tokens right-aligned in a fixed middle column. Other roles
|
|
||||||
// (tool/system) reuse the assistant layout with an empty tokens
|
|
||||||
// cell so columns still align across rows.
|
|
||||||
const assistantLeft = partsLabel || '\u2014';
|
const assistantLeft = partsLabel || '\u2014';
|
||||||
const assistantMiddle = tokens
|
const assistantMiddle = tokens
|
||||||
? formatAssistantTokens(tokens.input, tokens.output, formatNumber)
|
? formatAssistantTokens(tokens.input, tokens.output, formatNumber)
|
||||||
: '';
|
: '';
|
||||||
const otherLeft = role || 'unknown';
|
const otherLeft = role || 'unknown';
|
||||||
const otherMiddle = partsLabel;
|
const otherLabel = partsLabel ? `${otherLeft}: ${partsLabel}` : otherLeft;
|
||||||
|
|
||||||
const jsonValue = isExpanded
|
const jsonValue = isExpanded
|
||||||
? JSON.stringify({ info: message.info, parts: message.parts }, null, 2)
|
? JSON.stringify({ info: message.info, parts: message.parts }, null, 2)
|
||||||
@@ -582,21 +573,13 @@ export const ContextPanelContent: React.FC = () => {
|
|||||||
}));
|
}));
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/*
|
|
||||||
4-column grid: cols 1-2 = role+content area, col 3 = id,
|
|
||||||
col 4 = time. User rows fuse cols 1-2 into a single
|
|
||||||
inline `**user:** <snippet>` block via grid-column:
|
|
||||||
span 2; assistant/other rows keep them split (label |
|
|
||||||
value) so the I/O tokens line up vertically across rows.
|
|
||||||
*/}
|
|
||||||
<div
|
<div
|
||||||
className="grid items-center gap-x-2 whitespace-nowrap typography-micro"
|
className="grid items-center gap-x-2 whitespace-nowrap typography-micro"
|
||||||
style={{ gridTemplateColumns: 'auto minmax(0, 1fr) 5rem 4.5rem' }}
|
style={{ gridTemplateColumns: isAssistant ? 'minmax(0, 1fr) 7.5rem max-content' : 'minmax(0, 1fr) max-content' }}
|
||||||
>
|
>
|
||||||
{isUser ? (
|
{isUser ? (
|
||||||
<span
|
<span
|
||||||
className="min-w-0 truncate text-muted-foreground"
|
className="min-w-0 truncate text-muted-foreground"
|
||||||
style={{ gridColumn: 'span 2' }}
|
|
||||||
>
|
>
|
||||||
<span className="typography-ui-label text-foreground">user:</span>{' '}
|
<span className="typography-ui-label text-foreground">user:</span>{' '}
|
||||||
{userSnippet}
|
{userSnippet}
|
||||||
@@ -607,23 +590,18 @@ export const ContextPanelContent: React.FC = () => {
|
|||||||
className={
|
className={
|
||||||
isAssistant
|
isAssistant
|
||||||
? 'min-w-0 truncate text-muted-foreground'
|
? 'min-w-0 truncate text-muted-foreground'
|
||||||
: 'typography-ui-label text-foreground'
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{isAssistant ? assistantLeft : otherLeft}
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
className={
|
|
||||||
isAssistant
|
|
||||||
? 'text-right text-muted-foreground tabular-nums'
|
|
||||||
: 'min-w-0 truncate text-muted-foreground'
|
: 'min-w-0 truncate text-muted-foreground'
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{isAssistant ? assistantMiddle : otherMiddle}
|
{isAssistant ? assistantLeft : otherLabel}
|
||||||
</span>
|
</span>
|
||||||
|
{isAssistant && (
|
||||||
|
<span className="text-right text-muted-foreground tabular-nums">
|
||||||
|
{assistantMiddle}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<span className="text-right font-mono text-muted-foreground">{shortId}</span>
|
|
||||||
<span className="text-right text-muted-foreground">{previewTime}</span>
|
<span className="text-right text-muted-foreground">{previewTime}</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user