refactor: remove redundant comments and docstrings (#6527)

* refactor: remove redundant comments and docstrings

* fix(signal): annotate async context manager as a generator
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-30 13:07:03 +08:00
1 parent cb3ba45317
commit a4d2430140
922 files changed
+406 -7738

No files matched your search

-2
View File
@@ -29,12 +29,10 @@
padding-inline: calc(var(--math-tag-width) + 1em);
}
/* Math-heavy prose uses a tighter reading rhythm than ordinary chat. */
.markdown-content:has(.math-fit) {
--cjk-line-height: 1.65;
}
/* Keep list formulas close to their explanations. */
.markdown-content li .math-fit {
margin-block: 0.3em 0.35em;
}
-1
View File
@@ -23,7 +23,6 @@ export function useFilePreviewLoader() {
const itemClassName = `${floatingItemClassName} ${floatingItemFocusClassName} cursor-default data-[disabled]:pointer-events-none data-[disabled]:opacity-50`;
/** Copy-only context menu, shared by file references and preview tabs. */
export function FileActions({
path, children, metadata, className,
}: {
@@ -333,7 +333,6 @@ export function fileIconForPath(path: string): LucideIcon {
return FILE_ICONS[fileKindForPath(path)];
}
/** The same file silhouette and stroke in replies, tabs, and attachment tiles. */
export function FileReferenceIcon({ kind, className }: { kind: FileReferenceKind; className?: string }) {
const Icon = FILE_ICONS[kind];
return <Icon aria-hidden strokeWidth={1.75} className={cn("h-[1em] w-[1em] shrink-0", className)} />;
-2
View File
@@ -69,7 +69,6 @@ export function ImageLightbox({
return () => window.removeEventListener("keydown", onKey);
}, [go, onIndexChange, open, total]);
// Neighbours we want the browser to decode eagerly.
const preload = useMemo(() => {
if (index === null || total <= 1) return [] as UIImage[];
const prev = images[(index - 1 + total) % total];
@@ -151,7 +150,6 @@ export function ImageLightbox({
<X className="h-4 w-4" aria-hidden />
</DialogPrimitive.Close>
{/* Invisible preload — browser decodes adjacent images so prev/next swap is instant. */}
<div aria-hidden className="hidden">
{preload.map((img, i) => (
<img key={`${img.url}-${i}`} src={img.url} alt="" />
-1
View File
@@ -77,7 +77,6 @@ export function preloadMarkdownText(): Promise<void> {
return loadMarkdownRenderer().then(() => undefined);
}
/** Lazy boundary for the heavier GFM, math, and code renderer. */
export function MarkdownText({
children,
className,
@@ -521,10 +521,6 @@ function codeFenceFromPreChild(value: ReactNode): { code: string; language?: str
};
}
/**
* Heavy markdown stack (GFM, math, KaTeX, syntax highlighting) kept in a
* separate chunk so the app shell can paint sooner on refresh.
*/
export default function MarkdownTextRenderer({
children,
className,
@@ -562,7 +558,6 @@ export default function MarkdownTextRenderer({
/>
);
}
/** Plain fenced ``` blocks (no language) & wide one-liners: block monospace, not inline pill. */
const widePlainBlock = raw.includes("\n") || raw.length > 120;
if (widePlainBlock) {
return (
-11
View File
@@ -46,13 +46,11 @@ import type {
interface MessageBubbleProps {
message: UIMessage;
/** Give temporary-chat user turns the dashed private-mode treatment. */
temporary?: boolean;
cliApps?: CliAppInfo[];
mcpPresets?: McpPresetInfo[];
slashCommands?: SlashCommand[];
onOpenFilePreview?: (path: string) => void;
/** Context-menu trigger positioned against this message's visual block. */
contextMenu?: ReactNode;
}
@@ -116,7 +114,6 @@ function messageCopyContent(message: UIMessage, t: (key: string) => string) {
: message.content;
}
/** The same copy behavior in the desktop menu and the mobile reply footer. */
export function MessageCopyButton({ message, className }: { message: UIMessage; className?: string }) {
const { t } = useTranslation();
const content = messageCopyContent(message, t);
@@ -151,7 +148,6 @@ interface MessageBlockMenuActionsProps {
sheet?: boolean;
}
/** Actions and metadata shown after opening a visual message block's context panel. */
export function MessageBlockMenuActions({
message,
isTurnStreaming = false,
@@ -405,7 +401,6 @@ function IncomingSessionMessage({
);
}
/** Render user turns as compact bubbles and assistant turns as document-like prose. */
export function MessageBubble({
message,
temporary = false,
@@ -706,7 +701,6 @@ function MessageMedia({
);
}
/** Quiet pre-token state that occupies a stable line in the answer column. */
function ThinkingState() {
const { t } = useTranslation();
return (
@@ -748,11 +742,6 @@ interface TraceGroupProps {
message: UIMessage;
}
/**
* Collapsible group of tool-call / progress breadcrumbs. Defaults to
* collapsed because tool traces are supporting evidence, not the answer.
* A single click expands the exact calls when the user wants details.
*/
function TraceGroup({ message }: TraceGroupProps) {
const { t } = useTranslation();
const lines = message.traces ?? [message.content];
+1 -1
View File
@@ -50,7 +50,7 @@ export function StarPrompt({ ready }: { ready: boolean }) {
previousFocus.current = document.activeElement instanceof HTMLElement
? document.activeElement : null;
setOpen(true);
}).catch(() => { /* Optional invitations stay hidden when storage is unavailable. */ });
}).catch(() => {});
});
return () => { cancelled = true; unsubscribe(); };
}, [client, ready]);
-1
View File
@@ -3,7 +3,6 @@ import createElement from "react-syntax-highlighter/dist/esm/create-element";
type RowsProps = Parameters<NonNullable<SyntaxHighlighterProps["renderer"]>>[0];
/** Keep inline tokens in one wrapping flow beside the line-number gutter. */
export function WrappedCodeRows({ rows, ...props }: RowsProps) {
return rows.map((row, index) => {
const [lineNumber, ...content] = row.children!;
@@ -8,7 +8,6 @@ import { HostSwitcherView } from "./HostSwitcherView";
export { HostNavigationContext, type HostPicker } from "./host-navigation";
export { RemoteHostMenu } from "./HostSwitcherView";
/** Connect the sidebar's presentation to the active host and client. */
export function HostSwitcher({ collapsed = false, portalContainer }: { collapsed?: boolean; portalContainer?: HTMLElement | null }) {
const picker = useContext(HostNavigationContext);
const { client } = useClient();
@@ -5,7 +5,6 @@ import { remoteAction } from "@/lib/remote-instances";
import { useRemoteConnections } from "./remote-context";
import { PairRouteSettingsView } from "./PairRouteSettingsView";
/** An explicit escape hatch for a VPN/bound-interface route, not a new SSH form. */
export function PairRouteSettings({ id, onSaved, showHint = true }: { id: string; onSaved?: () => void; showHint?: boolean }) {
const { t } = useTranslation();
const { client } = useClient();
@@ -34,7 +34,6 @@ export function QuickPairSetup({ returned, active = true, onSSH, onClose }: { re
useEffect(() => {
if (!pending) { setBusyVisible(false); return; }
// Fast local preparation should not flash a loading label or move the dialog.
const timer = window.setTimeout(() => setBusyVisible(true), 200);
return () => window.clearTimeout(timer);
}, [pending]);
@@ -167,7 +167,6 @@ export function QuickPairSetupView({
</div>;
}
/** Decorative overview, not a live connection-status indicator. */
function RemoteConnectionIllustration() {
return <svg viewBox="0 0 208 88" width="184" height="78" aria-hidden="true" focusable="false" className="mx-auto mb-4 shrink-0 text-foreground/70" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
<path d="M78 51 C111 65 114 28 146 36" className="text-muted-foreground/50" strokeWidth="2.5" />
@@ -26,7 +26,6 @@ const emptyProfile = (): Omit<RemoteProfile, "id" | "connected"> => ({
config_path: "~/.nanobot/config.json", runtime_user: "",
});
/** The page is a server directory. Add/edit/first-use verification share one dialog. */
export function RemoteConnectionsPage({ mainNavigationExpanded = false, hostChromeInset = false, onBackToChat }: {
mainNavigationExpanded?: boolean;
hostChromeInset?: boolean;
@@ -9,7 +9,6 @@ type SSHHostPickerProps = Pick<SSHHostPickerViewProps,
configFile: string;
};
/** One address field for both manual entry and existing SSH aliases. */
export function SSHHostPicker({ configFile, suggestions = true, ...props }: SSHHostPickerProps) {
const { t } = useTranslation();
const { client } = useClient();
@@ -47,7 +46,6 @@ export function SSHHostPicker({ configFile, suggestions = true, ...props }: SSHH
const unsubscribe = client.onStatus((status) => {
if (status === "open" && !started) {
started = true;
// Custom paths update quietly after typing; no separate "read config" flow.
timer = setTimeout(() => { void load(file); }, file ? 300 : 0);
}
});
@@ -1,4 +1,3 @@
/* Remote dialogs share typography and action sizing without changing app-wide controls. */
.remote-dialog {
min-inline-size: 0;
max-block-size: min(85dvh, calc(100dvh - 2rem));
@@ -46,7 +45,6 @@
grid-template-columns: auto minmax(0, 1fr);
}
/* Keep secondary actions readable when translations need a second line. */
.remote-pair-alternatives {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
@@ -74,7 +74,6 @@ export function ReadingSettings({ preferences, onChange }: {
/>
<TooltipProvider>
<Tooltip open={hintOpen} onOpenChange={(open) => {
// Keep guidance visible while typing, including pointer/touch focus.
if (open || document.activeElement !== inputRef.current) setHintOpen(open);
}}>
<TooltipTrigger asChild>
@@ -8,7 +8,6 @@
.appearance-theme-check { opacity: 0; }
.appearance-theme-option input:checked + .appearance-theme-card .appearance-theme-check { opacity: 1; }
.appearance-theme-label { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 8px 4px 2px; min-height: 36px; }
/* Nested surfaces follow the outer curve minus their actual inset, including the border. */
.appearance-theme-miniature { --mini-paper: #fff; --mini-sidebar: #f1f0ec; --mini-line: #dad9d5; display: flex; height: 84px; overflow: hidden; border-radius: calc(var(--radius-panel) - var(--appearance-theme-inset) - 1px); background: var(--mini-paper); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.04); }
.appearance-theme-miniature[data-mode="dark"] { --mini-paper: #303030; --mini-sidebar: #383838; --mini-line: #656565; }
.appearance-theme-miniature[data-mode="system"] { --mini-paper: linear-gradient(110deg, #fff calc(50% - 0.5px), #303030 calc(50% + 0.5px)); --mini-sidebar: #f1f0ec; --mini-line: #969590; }
@@ -285,7 +285,6 @@ function FoldedAgentActivity({
const [now, setNow] = useState(() => Date.now());
const wasTurnStreamingRef = useRef(isTurnStreaming);
const wasTurnStreaming = wasTurnStreamingRef.current;
/** Auto follows execution; expanded keeps details open unless manually collapsed. */
const outerExpanded = expanded ?? (
userToggledOuter
? outerOpenLocal
@@ -82,8 +82,6 @@ function resolveCopy(
case "model_request_failed":
return resolveModelRequestFailureCopy(error, t);
default: {
// Exhaustiveness guard: if a new StreamError kind is added, TS will
// complain here until we add a corresponding i18n branch.
const _exhaustive: never = error;
return { title: String(_exhaustive), body: "" };
}
@@ -5,7 +5,6 @@ import { cn } from "@/lib/utils";
export function ControlChevron({ className }: { className?: string }) {
return (
<ChevronDown
// Keep the horizontal viewBox around the artwork, including its stroke.
viewBox="5 0 14 24"
width={14}
height={24}
@@ -1,6 +1,5 @@
import { useLayoutEffect, useRef, useState } from "react";
/** Animate a line-limited preview without swapping or duplicating its text. */
export function ExpandableText({
children, expanded, lines, className, id,
}: {
@@ -2,7 +2,6 @@ import type { ReactNode } from "react";
import { cn } from "@/lib/utils";
/** L→R sheen on the glyphs themselves; inactive labels stay solid muted text. */
export function StreamingLabelSheen({
children,
active,
@@ -728,12 +728,8 @@ export function PaneWorkbench({
>
{renderPane(pane, {
active,
// A single conversation owns its header, alongside its preview tabs.
// Multiple conversation panes still share the workbench toolbar.
headerPortalTarget: chrome && displayedPanes.length > 1 ? headerPortalTarget : undefined,
composerPortalTarget: chrome ? composerPortalTarget : undefined,
// A single chat includes the shared composer in its visual frame.
// Split chats keep navigation centered within their own pane.
navigationFrame: displayedPanes.length === 1 ? navigationFrame : undefined,
headerActions,
})}