style: format code and apply clippy lint fixes (#941)

This commit is contained in:
Dex Miller
2026-02-06 16:02:57 +08:00
committed by GitHub
parent 92785a8078
commit 95bc0e38df
24 changed files with 135 additions and 127 deletions
+2 -2
View File
@@ -40,7 +40,7 @@ export function SessionItem({
"w-full text-left rounded-lg px-3 py-2.5 transition-all group",
isSelected
? "bg-primary/10 border border-primary/30"
: "hover:bg-muted/60 border border-transparent"
: "hover:bg-muted/60 border border-transparent",
)}
>
<div className="flex items-center gap-2 mb-1">
@@ -62,7 +62,7 @@ export function SessionItem({
<ChevronRight
className={cn(
"size-4 text-muted-foreground/50 shrink-0 transition-transform",
isSelected && "text-primary rotate-90"
isSelected && "text-primary rotate-90",
)}
/>
</div>
+15 -13
View File
@@ -56,7 +56,7 @@ export function SessionManagerPage() {
const messagesEndRef = useRef<HTMLDivElement | null>(null);
const messageRefs = useRef<Map<number, HTMLDivElement>>(new Map());
const [activeMessageIndex, setActiveMessageIndex] = useState<number | null>(
null
null,
);
const [tocDialogOpen, setTocDialogOpen] = useState(false);
const [isSearchOpen, setIsSearchOpen] = useState(false);
@@ -83,7 +83,7 @@ export function SessionManagerPage() {
}
const exists = selectedKey
? filteredSessions.some(
(session) => getSessionKey(session) === selectedKey
(session) => getSessionKey(session) === selectedKey,
)
: false;
if (!exists) {
@@ -95,7 +95,7 @@ export function SessionManagerPage() {
if (!selectedKey) return null;
return (
filteredSessions.find(
(session) => getSessionKey(session) === selectedKey
(session) => getSessionKey(session) === selectedKey,
) || null
);
}, [filteredSessions, selectedKey]);
@@ -103,7 +103,7 @@ export function SessionManagerPage() {
const { data: messages = [], isLoading: isLoadingMessages } =
useSessionMessagesQuery(
selectedSession?.providerId,
selectedSession?.sourcePath
selectedSession?.sourcePath,
);
// 提取用户消息用于目录
@@ -147,7 +147,7 @@ export function SessionManagerPage() {
} catch (error) {
toast.error(
extractErrorMessage(error) ||
t("common.error", { defaultValue: "Copy failed" })
t("common.error", { defaultValue: "Copy failed" }),
);
}
};
@@ -158,7 +158,7 @@ export function SessionManagerPage() {
if (!isMac()) {
await handleCopy(
selectedSession.resumeCommand,
t("sessionManager.resumeCommandCopied")
t("sessionManager.resumeCommandCopied"),
);
return;
}
@@ -240,14 +240,16 @@ export function SessionManagerPage() {
setIsSearchOpen(true);
setTimeout(
() => searchInputRef.current?.focus(),
0
0,
);
}}
>
<Search className="size-3.5" />
</Button>
</TooltipTrigger>
<TooltipContent>{t("sessionManager.searchSessions")}</TooltipContent>
<TooltipContent>
{t("sessionManager.searchSessions")}
</TooltipContent>
</Tooltip>
<Select
@@ -387,7 +389,7 @@ export function SessionManagerPage() {
<span className="shrink-0">
<ProviderIcon
icon={getProviderIconName(
selectedSession.providerId
selectedSession.providerId,
)}
name={selectedSession.providerId}
size={20}
@@ -410,7 +412,7 @@ export function SessionManagerPage() {
<span>
{formatTimestamp(
selectedSession.lastActiveAt ??
selectedSession.createdAt
selectedSession.createdAt,
)}
</span>
</div>
@@ -422,7 +424,7 @@ export function SessionManagerPage() {
onClick={() =>
void handleCopy(
selectedSession.projectDir!,
t("sessionManager.projectDirCopied")
t("sessionManager.projectDirCopied"),
)
}
className="flex items-center gap-1 hover:text-foreground transition-colors"
@@ -497,7 +499,7 @@ export function SessionManagerPage() {
onClick={() =>
void handleCopy(
selectedSession.resumeCommand!,
t("sessionManager.resumeCommandCopied")
t("sessionManager.resumeCommandCopied"),
)
}
>
@@ -559,7 +561,7 @@ export function SessionManagerPage() {
content,
t("sessionManager.messageCopied", {
defaultValue: "已复制消息内容",
})
}),
)
}
/>
@@ -37,7 +37,7 @@ export function SessionMessageItem({
: message.role.toLowerCase() === "assistant"
? "bg-blue-500/5 border-blue-500/20 mr-8"
: "bg-muted/40 border-border/60",
isActive && "ring-2 ring-primary ring-offset-2"
isActive && "ring-2 ring-primary ring-offset-2",
)}
>
<Tooltip>
+2 -2
View File
@@ -48,7 +48,7 @@ export function SessionTocSidebar({
className={cn(
"w-full text-left px-2 py-1.5 rounded text-xs transition-colors",
"hover:bg-muted/80 text-muted-foreground hover:text-foreground",
"flex items-start gap-2"
"flex items-start gap-2",
)}
>
<span className="shrink-0 w-4 h-4 rounded-full bg-primary/10 text-primary text-[10px] flex items-center justify-center font-medium">
@@ -118,7 +118,7 @@ export function SessionTocDialog({
"w-full text-left px-3 py-2.5 rounded-lg text-sm transition-all",
"hover:bg-primary/10 text-foreground",
"flex items-start gap-3",
"focus:outline-none focus:ring-2 focus:ring-primary focus:ring-inset"
"focus:outline-none focus:ring-2 focus:ring-primary focus:ring-inset",
)}
>
<span className="shrink-0 w-6 h-6 rounded-full bg-primary text-primary-foreground text-xs flex items-center justify-center font-semibold">
+3 -6
View File
@@ -19,7 +19,7 @@ export const formatTimestamp = (value?: number) => {
export const formatRelativeTime = (
value: number | undefined,
t: (key: string, options?: Record<string, unknown>) => string
t: (key: string, options?: Record<string, unknown>) => string,
) => {
if (!value) return "";
const now = Date.now();
@@ -37,7 +37,7 @@ export const formatRelativeTime = (
export const getProviderLabel = (
providerId: string,
t: (key: string) => string
t: (key: string) => string,
) => {
const key = `apps.${providerId}`;
const translated = t(key);
@@ -60,10 +60,7 @@ export const getRoleTone = (role: string) => {
return "text-muted-foreground";
};
export const getRoleLabel = (
role: string,
t: (key: string) => string
) => {
export const getRoleLabel = (role: string, t: (key: string) => string) => {
const normalized = role.toLowerCase();
if (normalized === "assistant") return "AI";
if (normalized === "user") return t("sessionManager.roleUser");