ci: enforce code formatting checks for backend and frontend (#1536)

This commit is contained in:
greatmengqi
2026-03-29 15:34:38 +08:00
committed by GitHub
parent 06a623f9c8
commit 084dc7e748
105 changed files with 8253 additions and 7369 deletions
+1 -4
View File
@@ -9,10 +9,7 @@ function getBaseOrigin() {
export function getBackendBaseURL() {
if (env.NEXT_PUBLIC_BACKEND_BASE_URL) {
return new URL(
env.NEXT_PUBLIC_BACKEND_BASE_URL,
getBaseOrigin(),
)
return new URL(env.NEXT_PUBLIC_BACKEND_BASE_URL, getBaseOrigin())
.toString()
.replace(/\/+$/, "");
} else {
+3 -2
View File
@@ -281,14 +281,15 @@ export const enUS: Translations = {
output: "Output",
total: "Total",
},
// Shortcuts
shortcuts: {
searchActions: "Search actions...",
noResults: "No results found.",
actions: "Actions",
keyboardShortcuts: "Keyboard Shortcuts",
keyboardShortcutsDescription: "Navigate DeerFlow faster with keyboard shortcuts.",
keyboardShortcutsDescription:
"Navigate DeerFlow faster with keyboard shortcuts.",
openCommandPalette: "Open Command Palette",
toggleSidebar: "Toggle Sidebar",
},
+11 -11
View File
@@ -218,7 +218,7 @@ export interface Translations {
output: string;
total: string;
};
// Shortcuts
shortcuts: {
searchActions: string;
@@ -254,16 +254,16 @@ export interface Translations {
factDeleteConfirmTitle: string;
factDeleteConfirmDescription: string;
factDeleteSuccess: string;
noFacts: string;
summaryReadOnly: string;
memoryFullyEmpty: string;
factPreviewLabel: string;
searchPlaceholder: string;
filterAll: string;
filterFacts: string;
filterSummaries: string;
noMatches: string;
markdown: {
noFacts: string;
summaryReadOnly: string;
memoryFullyEmpty: string;
factPreviewLabel: string;
searchPlaceholder: string;
filterAll: string;
filterFacts: string;
filterSummaries: string;
noMatches: string;
markdown: {
overview: string;
userContext: string;
work: string;
+3 -2
View File
@@ -268,7 +268,7 @@ export const zhCN: Translations = {
output: "输出",
total: "总计",
},
// Shortcuts
shortcuts: {
searchActions: "搜索操作...",
@@ -308,7 +308,8 @@ export const zhCN: Translations = {
"这条事实会立即从记忆中删除。此操作无法撤销。",
factDeleteSuccess: "事实已删除",
noFacts: "还没有保存的事实。",
summaryReadOnly: "摘要分区当前仍为只读。现在你可以清空全部记忆或删除单条事实。",
summaryReadOnly:
"摘要分区当前仍为只读。现在你可以清空全部记忆或删除单条事实。",
memoryFullyEmpty: "还没有保存任何记忆。",
factPreviewLabel: "即将删除的事实",
searchPlaceholder: "搜索记忆",
+6 -8
View File
@@ -8,14 +8,12 @@ export async function loadMCPConfig() {
}
export async function updateMCPConfig(config: MCPConfig) {
const response = await fetch(`${getBackendBaseURL()}/api/mcp/config`,
{
method: "PUT",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(config),
const response = await fetch(`${getBackendBaseURL()}/api/mcp/config`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
);
body: JSON.stringify(config),
});
return response.json();
}
+3 -1
View File
@@ -10,7 +10,9 @@ async function readMemoryResponse(
const errorData = (await response.json().catch(() => ({}))) as {
detail?: string;
};
throw new Error(errorData.detail ?? `${fallbackMessage}: ${response.statusText}`);
throw new Error(
errorData.detail ?? `${fallbackMessage}: ${response.statusText}`,
);
}
return response.json() as Promise<UserMemory>;
+1 -3
View File
@@ -10,9 +10,7 @@ export interface TokenUsage {
* Extract usage_metadata from an AI message if present.
* The field is added by the backend (PR #1218) but not typed in the SDK.
*/
function getUsageMetadata(
message: Message,
): TokenUsage | null {
function getUsageMetadata(message: Message): TokenUsage | null {
if (message.type !== "ai") {
return null;
}
+13 -4
View File
@@ -127,7 +127,10 @@ export function groupMessages<T>(
export function extractTextFromMessage(message: Message) {
if (typeof message.content === "string") {
return splitInlineReasoningFromAIMessage(message)?.content ?? message.content.trim();
return (
splitInlineReasoningFromAIMessage(message)?.content ??
message.content.trim()
);
}
if (Array.isArray(message.content)) {
return message.content
@@ -167,7 +170,10 @@ function splitInlineReasoningFromAIMessage(message: Message) {
export function extractContentFromMessage(message: Message) {
if (typeof message.content === "string") {
return splitInlineReasoningFromAIMessage(message)?.content ?? message.content.trim();
return (
splitInlineReasoningFromAIMessage(message)?.content ??
message.content.trim()
);
}
if (Array.isArray(message.content)) {
return message.content
@@ -233,8 +239,11 @@ export function extractURLFromImageURLContent(
export function hasContent(message: Message) {
if (typeof message.content === "string") {
return (
splitInlineReasoningFromAIMessage(message)?.content ?? message.content.trim()
).length > 0;
(
splitInlineReasoningFromAIMessage(message)?.content ??
message.content.trim()
).length > 0
);
}
if (Array.isArray(message.content)) {
return message.content.length > 0;
+1 -3
View File
@@ -105,9 +105,7 @@ export function formatThreadAsJSON(
}
function sanitizeFilename(name: string): string {
return (
name.replace(/[^\p{L}\p{N}_\- ]/gu, "").trim() || "conversation"
);
return name.replace(/[^\p{L}\p{N}_\- ]/gu, "").trim() || "conversation";
}
export function downloadAsFile(
+2 -1
View File
@@ -429,7 +429,8 @@ export function useThreads(
// Preserve prior semantics: if a non-positive limit is explicitly provided,
// delegate to a single search call with the original parameters.
if (maxResults !== undefined && maxResults <= 0) {
const response = await apiClient.threads.search<AgentThreadState>(params);
const response =
await apiClient.threads.search<AgentThreadState>(params);
return response as AgentThread[];
}
+1 -3
View File
@@ -33,9 +33,7 @@ async function readErrorDetail(
response: Response,
fallback: string,
): Promise<string> {
const error = await response
.json()
.catch(() => ({ detail: fallback }));
const error = await response.json().catch(() => ({ detail: fallback }));
return error.detail ?? fallback;
}