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
+4 -1
View File
@@ -8,7 +8,10 @@ interface AppCountBarProps {
counts: Record<AppId, number>;
}
export const AppCountBar: React.FC<AppCountBarProps> = ({ totalLabel, counts }) => {
export const AppCountBar: React.FC<AppCountBarProps> = ({
totalLabel,
counts,
}) => {
return (
<div className="flex-shrink-0 py-4 glass rounded-xl border border-white/10 mb-4 px-6 flex items-center justify-between gap-4">
<Badge variant="outline" className="bg-background/50 h-7 px-3">
+9 -5
View File
@@ -12,7 +12,10 @@ interface AppToggleGroupProps {
onToggle: (app: AppId, enabled: boolean) => void;
}
export const AppToggleGroup: React.FC<AppToggleGroupProps> = ({ apps, onToggle }) => {
export const AppToggleGroup: React.FC<AppToggleGroupProps> = ({
apps,
onToggle,
}) => {
return (
<div className="flex items-center gap-1.5 flex-shrink-0">
{APP_IDS.map((app) => {
@@ -25,16 +28,17 @@ export const AppToggleGroup: React.FC<AppToggleGroupProps> = ({ apps, onToggle }
type="button"
onClick={() => onToggle(app, !enabled)}
className={`w-7 h-7 rounded-lg flex items-center justify-center transition-all ${
enabled
? activeClass
: "opacity-35 hover:opacity-70"
enabled ? activeClass : "opacity-35 hover:opacity-70"
}`}
>
{icon}
</button>
</TooltipTrigger>
<TooltipContent side="bottom">
<p>{label}{enabled ? " ✓" : ""}</p>
<p>
{label}
{enabled ? " ✓" : ""}
</p>
</TooltipContent>
</Tooltip>
);
+4 -1
View File
@@ -5,7 +5,10 @@ interface ListItemRowProps {
children: React.ReactNode;
}
export const ListItemRow: React.FC<ListItemRowProps> = ({ isLast, children }) => {
export const ListItemRow: React.FC<ListItemRowProps> = ({
isLast,
children,
}) => {
return (
<div
className={`group flex items-center gap-3 px-4 py-2.5 hover:bg-muted/50 transition-colors ${
+7 -2
View File
@@ -245,7 +245,9 @@ const UnifiedMcpListItem: React.FC<UnifiedMcpListItemProps> = ({
<ListItemRow isLast={isLast}>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-1.5">
<span className="font-medium text-sm text-foreground truncate">{name}</span>
<span className="font-medium text-sm text-foreground truncate">
{name}
</span>
{docsUrl && (
<button
type="button"
@@ -258,7 +260,10 @@ const UnifiedMcpListItem: React.FC<UnifiedMcpListItemProps> = ({
)}
</div>
{description && (
<p className="text-xs text-muted-foreground truncate" title={description}>
<p
className="text-xs text-muted-foreground truncate"
title={description}
>
{description}
</p>
)}
+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");
+11 -8
View File
@@ -63,11 +63,7 @@ const UnifiedSkillsPanel = React.forwardRef<
return counts;
}, [skills]);
const handleToggleApp = async (
id: string,
app: AppId,
enabled: boolean,
) => {
const handleToggleApp = async (id: string, app: AppId, enabled: boolean) => {
try {
await toggleAppMutation.mutateAsync({ id, app, enabled });
} catch (error) {
@@ -257,7 +253,9 @@ const InstalledSkillListItem: React.FC<InstalledSkillListItemProps> = ({
<ListItemRow isLast={isLast}>
<div className="flex-1 min-w-0">
<div className="flex items-center gap-1.5">
<span className="font-medium text-sm text-foreground truncate">{skill.name}</span>
<span className="font-medium text-sm text-foreground truncate">
{skill.name}
</span>
{skill.readmeUrl && (
<button
type="button"
@@ -267,10 +265,15 @@ const InstalledSkillListItem: React.FC<InstalledSkillListItemProps> = ({
<ExternalLink size={12} />
</button>
)}
<span className="text-xs text-muted-foreground/50 flex-shrink-0">{sourceLabel}</span>
<span className="text-xs text-muted-foreground/50 flex-shrink-0">
{sourceLabel}
</span>
</div>
{skill.description && (
<p className="text-xs text-muted-foreground truncate" title={skill.description}>
<p
className="text-xs text-muted-foreground truncate"
title={skill.description}
>
{skill.description}
</p>
)}
+1 -1
View File
@@ -36,7 +36,7 @@ const ScrollBar = React.forwardRef<
"h-full w-2.5 border-l border-l-transparent p-[1px]",
orientation === "horizontal" &&
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
className
className,
)}
{...props}
>
+1 -1
View File
@@ -20,7 +20,7 @@ const TooltipContent = React.forwardRef<
sideOffset={sideOffset}
className={cn(
"z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className
className,
)}
{...props}
/>