Tighten session list status slot
This commit is contained in:
@@ -482,7 +482,7 @@ const ClawSessionList: FC = () => {
|
||||
return (
|
||||
<div
|
||||
key={`claw-session-${session.session_id}-${session.modified_at}`}
|
||||
className="aui-thread-list-item group relative flex h-9 items-center gap-2 rounded-lg transition-colors hover:bg-muted data-[active=true]:bg-muted"
|
||||
className="aui-thread-list-item group relative flex h-9 items-center rounded-lg transition-colors hover:bg-muted data-[active=true]:bg-muted"
|
||||
data-active={active}
|
||||
>
|
||||
{renamingSessionId === session.session_id ? (
|
||||
@@ -515,7 +515,7 @@ const ClawSessionList: FC = () => {
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
className="aui-thread-list-item-trigger flex h-full min-w-0 flex-1 items-center truncate px-3 text-start text-sm"
|
||||
className="aui-thread-list-item-trigger flex h-full min-w-0 flex-1 items-center overflow-hidden px-3 text-start text-sm"
|
||||
onClick={async () => {
|
||||
console.log("[session-list] click", {
|
||||
sessionId: session.session_id,
|
||||
@@ -525,33 +525,24 @@ const ClawSessionList: FC = () => {
|
||||
await openSession(session.session_id);
|
||||
}}
|
||||
>
|
||||
<span className="truncate">
|
||||
<span className="min-w-0 overflow-hidden text-clip whitespace-nowrap">
|
||||
{loading
|
||||
? "回放中..."
|
||||
: session.preview || session.session_id}
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
<SessionRunBadge
|
||||
<SessionActionSlot
|
||||
running={badge?.running === true}
|
||||
unread={badge?.unread === true}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
className="aui-thread-list-item-more mr-2 flex size-7 shrink-0 items-center justify-center rounded-md p-0 text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 data-[busy=true]:opacity-100 data-[open=true]:bg-accent data-[open=true]:opacity-100"
|
||||
data-busy={deletingSessionId === session.session_id}
|
||||
data-open={openMenuSessionId === session.session_id}
|
||||
aria-expanded={openMenuSessionId === session.session_id}
|
||||
aria-label="打开历史会话菜单"
|
||||
title="更多选项"
|
||||
onClick={() => {
|
||||
busy={deletingSessionId === session.session_id}
|
||||
open={openMenuSessionId === session.session_id}
|
||||
onOpenChange={() => {
|
||||
setOpenMenuSessionId((current) =>
|
||||
current === session.session_id ? null : session.session_id,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<MoreHorizontalIcon className="size-4" />
|
||||
</button>
|
||||
/>
|
||||
{openMenuSessionId === session.session_id ? (
|
||||
<div className="aui-thread-list-item-more-content absolute top-8 right-1 z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md">
|
||||
<button
|
||||
@@ -712,35 +703,50 @@ function useSessionRunBadges(
|
||||
return { bySessionId, markRead };
|
||||
}
|
||||
|
||||
function SessionRunBadge({
|
||||
function SessionActionSlot({
|
||||
running,
|
||||
unread,
|
||||
busy,
|
||||
open,
|
||||
onOpenChange,
|
||||
}: {
|
||||
running: boolean;
|
||||
unread: boolean;
|
||||
busy: boolean;
|
||||
open: boolean;
|
||||
onOpenChange: () => void;
|
||||
}) {
|
||||
if (running) {
|
||||
const hasBadge = running || unread;
|
||||
return (
|
||||
<div className="relative mr-2 flex size-7 shrink-0 items-center justify-center">
|
||||
<span
|
||||
className="flex size-5 shrink-0 items-center justify-center text-muted-foreground"
|
||||
title="运行中"
|
||||
aria-hidden={!hasBadge}
|
||||
className="pointer-events-none absolute inset-0 flex items-center justify-center text-muted-foreground transition-opacity group-hover:opacity-0 data-[hidden=true]:opacity-0 data-[open=true]:opacity-0"
|
||||
data-hidden={!hasBadge}
|
||||
data-open={open || busy}
|
||||
title={running ? "运行中" : unread ? "已完成,未查看" : undefined}
|
||||
>
|
||||
{running ? (
|
||||
<Loader2Icon className="size-3.5 animate-spin" />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (unread) {
|
||||
return (
|
||||
<span
|
||||
className="flex size-5 shrink-0 items-center justify-center"
|
||||
title="已完成,未查看"
|
||||
>
|
||||
) : unread ? (
|
||||
<span className="size-2 rounded-full bg-sky-300" />
|
||||
) : null}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
className="aui-thread-list-item-more absolute inset-0 flex items-center justify-center rounded-md p-0 text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 data-[busy=true]:opacity-100 data-[open=true]:bg-accent data-[open=true]:opacity-100"
|
||||
data-busy={busy}
|
||||
data-open={open}
|
||||
aria-expanded={open}
|
||||
aria-label="打开历史会话菜单"
|
||||
title="更多选项"
|
||||
onClick={onOpenChange}
|
||||
>
|
||||
<MoreHorizontalIcon className="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return <span aria-hidden="true" className="size-5 shrink-0" />;
|
||||
}
|
||||
|
||||
function dedupeSessions(payload: unknown[]) {
|
||||
const byId = new Map<string, ClawSession>();
|
||||
|
||||
Reference in New Issue
Block a user