Skip to content

Commit e3e65a6

Browse files
committed
fix: build & format
1 parent 1a251ad commit e3e65a6

8 files changed

Lines changed: 111 additions & 97 deletions

File tree

webapp/_webapp/src/components/loading-indicator.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ export const LoadingIndicator = ({ text = "Thinking", estimatedSeconds = 0, erro
113113

114114
// Get status message based on phase
115115
const getStatusMessage = () => {
116-
if (isTimeout) return "Sorry — this request took too long to complete. We're working on improving reliability. You can try waiting a bit longer or refreshing the page. Thanks for your patience.";
116+
if (isTimeout)
117+
return "Sorry — this request took too long to complete. We're working on improving reliability. You can try waiting a bit longer or refreshing the page. Thanks for your patience.";
117118
if (phase === "orange") return "Synthesizing...";
118119
if (phase === "red") return "Just a moment...";
119120
if (errorMessage && errorMessage.length > 0) return errorMessage;

webapp/_webapp/src/components/message-entry-container/tools/jsonrpc.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const JsonRpc = ({ functionName, jsonRpcResult, preparing, animated }: Js
3939
>
4040
<svg
4141
className={cn("w-4 h-4 transition-transform duration-200", {
42-
"rotate-180": !isCollapsed
42+
"rotate-180": !isCollapsed,
4343
})}
4444
fill="none"
4545
stroke="currentColor"
@@ -49,24 +49,22 @@ export const JsonRpc = ({ functionName, jsonRpcResult, preparing, animated }: Js
4949
</svg>
5050
</button>
5151
</div>
52-
53-
<div className={cn("canselect overflow-hidden transition-all duration-300 ease-in-out", {
54-
"max-h-0 opacity-0": isCollapsed,
55-
"max-h-[1000px] opacity-100": !isCollapsed
56-
})}>
52+
53+
<div
54+
className={cn("canselect overflow-hidden transition-all duration-300 ease-in-out", {
55+
"max-h-0 opacity-0": isCollapsed,
56+
"max-h-[1000px] opacity-100": !isCollapsed,
57+
})}
58+
>
5759
{jsonRpcResult.result && (
5860
<div className="text-xs">
5961
<MarkdownComponent animated={animated}>
60-
{jsonRpcResult.result.content?.map((content) => content.text).join("\n") || ""}
61-
</MarkdownComponent>
62-
</div>
63-
)}
64-
65-
{jsonRpcResult.error && (
66-
<div className="text-xs text-red-600">
67-
{jsonRpcResult.error.message}
62+
{jsonRpcResult.result.content?.map((content) => content.text).join("\n") || ""}
63+
</MarkdownComponent>
6864
</div>
6965
)}
66+
67+
{jsonRpcResult.error && <div className="text-xs text-red-600">{jsonRpcResult.error.message}</div>}
7068
</div>
7169
</div>
7270
);

webapp/_webapp/src/components/message-entry-container/tools/tools.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,21 @@ export default function Tools({ messageId, functionName, message, error, prepari
4646
} else if (functionName === "always_exception") {
4747
return <AlwaysExceptionCard message={message} preparing={preparing} animated={animated} />;
4848
} else if (XTRA_MCP_TOOL_NAMES.includes(functionName)) {
49-
return <JsonRpc functionName={functionName} jsonRpcResult={jsonRpcResult || UNKNOWN_JSONRPC_RESULT} preparing={preparing} animated={animated} />;
49+
return (
50+
<JsonRpc
51+
functionName={functionName}
52+
jsonRpcResult={jsonRpcResult || UNKNOWN_JSONRPC_RESULT}
53+
preparing={preparing}
54+
animated={animated}
55+
/>
56+
);
5057
}
5158

5259
// fallback to unknown tool card if the json rpc result is not defined
5360
if (jsonRpcResult) {
54-
return <JsonRpc functionName={functionName} jsonRpcResult={jsonRpcResult} preparing={preparing} animated={animated} />;
61+
return (
62+
<JsonRpc functionName={functionName} jsonRpcResult={jsonRpcResult} preparing={preparing} animated={animated} />
63+
);
5564
} else {
5665
return <UnknownToolCard functionName={functionName} message={message} animated={animated} />;
5766
}
Lines changed: 74 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,91 @@
11
export type JsonRpcResult = {
2-
jsonrpc: string;
3-
id: number;
4-
result?: {
5-
content: Array<{
6-
type: string;
7-
text: string;
8-
}>;
9-
};
10-
error?: {
11-
code: number;
12-
message: string;
13-
}
14-
}
2+
jsonrpc: string;
3+
id: number;
4+
result?: {
5+
content: Array<{
6+
type: string;
7+
text: string;
8+
}>;
9+
};
10+
error?: {
11+
code: number;
12+
message: string;
13+
};
14+
};
1515

1616
export const UNKNOWN_JSONRPC_RESULT: JsonRpcResult = {
17-
jsonrpc: "2.0",
18-
id: -1,
19-
error: {
20-
code: -1,
21-
message: "Unknown JSONRPC result",
22-
},
23-
}
17+
jsonrpc: "2.0",
18+
id: -1,
19+
error: {
20+
code: -1,
21+
message: "Unknown JSONRPC result",
22+
},
23+
};
2424

2525
const isValidJsonRpcResult = (obj: any): obj is JsonRpcResult => {
26-
// Check if obj is an object and not null
27-
if (typeof obj !== 'object' || obj === null) {
28-
return false;
29-
}
26+
// Check if obj is an object and not null
27+
if (typeof obj !== "object" || obj === null) {
28+
return false;
29+
}
3030

31-
// Check required properties
32-
if (typeof obj.jsonrpc !== 'string' || typeof obj.id !== 'number') {
33-
return false;
34-
}
31+
// Check required properties
32+
if (typeof obj.jsonrpc !== "string" || typeof obj.id !== "number") {
33+
return false;
34+
}
3535

36-
// Check that either result or error is present (but not both required)
37-
const hasResult = obj.result !== undefined;
38-
const hasError = obj.error !== undefined;
36+
// Check that either result or error is present (but not both required)
37+
const hasResult = obj.result !== undefined;
38+
const hasError = obj.error !== undefined;
3939

40-
// Validate result structure if present
41-
if (hasResult) {
42-
if (typeof obj.result !== 'object' || obj.result === null) {
43-
return false;
44-
}
45-
if (obj.result.content !== undefined) {
46-
if (!Array.isArray(obj.result.content)) {
47-
return false;
48-
}
49-
// Validate each content item
50-
for (const item of obj.result.content) {
51-
if (typeof item !== 'object' || item === null ||
52-
typeof item.type !== 'string' || typeof item.text !== 'string') {
53-
return false;
54-
}
55-
}
40+
// Validate result structure if present
41+
if (hasResult) {
42+
if (typeof obj.result !== "object" || obj.result === null) {
43+
return false;
44+
}
45+
if (obj.result.content !== undefined) {
46+
if (!Array.isArray(obj.result.content)) {
47+
return false;
48+
}
49+
// Validate each content item
50+
for (const item of obj.result.content) {
51+
if (
52+
typeof item !== "object" ||
53+
item === null ||
54+
typeof item.type !== "string" ||
55+
typeof item.text !== "string"
56+
) {
57+
return false;
5658
}
59+
}
5760
}
61+
}
5862

59-
// Validate error structure if present
60-
if (hasError) {
61-
if (typeof obj.error !== 'object' || obj.error === null ||
62-
typeof obj.error.code !== 'number' || typeof obj.error.message !== 'string') {
63-
return false;
64-
}
63+
// Validate error structure if present
64+
if (hasError) {
65+
if (
66+
typeof obj.error !== "object" ||
67+
obj.error === null ||
68+
typeof obj.error.code !== "number" ||
69+
typeof obj.error.message !== "string"
70+
) {
71+
return false;
6572
}
73+
}
6674

67-
return true;
75+
return true;
6876
};
6977

7078
export const parseJsonRpcResult = (message: string): JsonRpcResult | undefined => {
71-
try {
72-
const json = JSON.parse(message);
73-
74-
// Validate the structure before casting
75-
if (isValidJsonRpcResult(json)) {
76-
return json;
77-
}
78-
79-
return undefined;
80-
} catch (error) {
81-
return undefined;
79+
try {
80+
const json = JSON.parse(message);
81+
82+
// Validate the structure before casting
83+
if (isValidJsonRpcResult(json)) {
84+
return json;
8285
}
83-
}
86+
87+
return undefined;
88+
} catch (error) {
89+
return undefined;
90+
}
91+
};

webapp/_webapp/src/index.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ body {
109109
@apply font-medium text-gray-500;
110110
}
111111

112-
113112
/* 相邻 tool-card 的样式处理 */
114113
.tool-card + .tool-card {
115114
/* 相邻的第二个卡片:移除上边框,调整上圆角,减少上边距,减少上 padding */

webapp/_webapp/src/libs/overleaf-socket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export async function wsConnect(
245245
const wsUrl = import.meta.env.DEV ? "ws://localhost:3000" : "wss://" + currentDomain;
246246
const data = await res.text();
247247
const sessionId = data.split(":")[0];
248-
248+
249249
// Set cookies for WebSocket connection
250250
document.cookie = `overleaf_session2=${overleafAuth.cookieOverleafSession2}; path=/; domain=${import.meta.env.DEV ? "localhost" : currentDomain}`;
251251
document.cookie = `GCLB=${overleafAuth.cookieGCLB}; path=/; domain=${import.meta.env.DEV ? "localhost" : currentDomain}`;

webapp/_webapp/src/views/login/index.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@ export const Login = () => {
1414

1515
return (
1616
<div className="flex flex-col h-full w-full items-center justify-center bg-gray-50 noselect py-12">
17-
{!showEndpointSettings && <>
18-
<Logo className="mb-4" />
19-
<div className="flex flex-col items-center justify-center">
20-
<p className="text-exo-2 text-2xl font-light mb-2">Welcome to</p>
21-
<div>
22-
<span className="text-exo-2 text-2xl font-light">Paper</span>
23-
<span className="text-exo-2 text-2xl font-bold">Debugger</span>
17+
{!showEndpointSettings && (
18+
<>
19+
<Logo className="mb-4" />
20+
<div className="flex flex-col items-center justify-center">
21+
<p className="text-exo-2 text-2xl font-light mb-2">Welcome to</p>
22+
<div>
23+
<span className="text-exo-2 text-2xl font-light">Paper</span>
24+
<span className="text-exo-2 text-2xl font-bold">Debugger</span>
25+
</div>
2426
</div>
25-
</div>
26-
</>}
27+
</>
28+
)}
2729
{showEndpointSettings && <AdvancedSettings />}
2830
<div className="flex-1"></div>
2931

30-
3132
<LoginWithGoogle
3233
isLoginLoading={isLoginLoading}
3334
setIsLoginLoading={setIsLoginLoading}

webapp/_webapp/src/views/settings/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { SettingsHeader } from "./settings-header";
66
import { UserDeveloperTools } from "./sections/user-developer-tools";
77
import { AccountSettings } from "./sections/account-settings";
88
import { UISettings } from "./sections/ui-settings";
9-
import { BetaFeatureSettings } from "./sections/beta-feature-settings";
109
import { RealDeveloperTools } from "./sections/real-developer-tools";
1110
import { SettingsFooter } from "./sections/footer";
1211

@@ -32,7 +31,6 @@ export const Settings = () => {
3231
<SettingsHeader />
3332
<div className="pd-app-tab-content-body">
3433
<UISettings />
35-
{/* <BetaFeatureSettings /> */}
3634
<AccountSettings />
3735
<SettingsFooter />
3836
{enableUserDeveloperTools && <UserDeveloperTools />}

0 commit comments

Comments
 (0)