@hienlh/ppm 0.7.9 → 0.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/web/assets/{chat-tab-BkUbaCUF.js → chat-tab-R_8ZfOG8.js} +2 -2
- package/dist/web/assets/{code-editor-BodXBGgt.js → code-editor-BbhIHbts.js} +1 -1
- package/dist/web/assets/{database-viewer-CCBt8nNo.js → database-viewer-BJYmlnr2.js} +1 -1
- package/dist/web/assets/{diff-viewer-BUSLkYnY.js → diff-viewer-CS-wesGq.js} +1 -1
- package/dist/web/assets/{git-graph-DKMqsIs6.js → git-graph-B9eaNltz.js} +1 -1
- package/dist/web/assets/index-qElHXk-7.js +28 -0
- package/dist/web/assets/index-sMxUHxFZ.css +2 -0
- package/dist/web/assets/keybindings-store-DrBQMVKg.js +1 -0
- package/dist/web/assets/{markdown-renderer-C7YWwr-S.js → markdown-renderer-DpIu7iOT.js} +1 -1
- package/dist/web/assets/{postgres-viewer-BI1XWAmh.js → postgres-viewer-B5-tRXE2.js} +1 -1
- package/dist/web/assets/{settings-tab-DW_kVkV9.js → settings-tab-3-ewawy0.js} +1 -1
- package/dist/web/assets/{sqlite-viewer-BdQj2XN9.js → sqlite-viewer-CfIer2x_.js} +1 -1
- package/dist/web/assets/{terminal-tab-DtINSbFR.js → terminal-tab-qJxp0iOK.js} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/src/services/claude-usage.service.ts +1 -8
- package/src/web/app.tsx +0 -4
- package/src/web/components/chat/usage-badge.tsx +23 -45
- package/dist/web/assets/index-BLfiBqwM.css +0 -2
- package/dist/web/assets/index-NvzSiZn3.js +0 -29
- package/dist/web/assets/keybindings-store-DOnYn9Ke.js +0 -1
- package/src/web/hooks/use-health-check.ts +0 -95
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./react-CYzKIDNi.js";import"./api-client-TUmacMRS.js";import{x as e}from"./index-NvzSiZn3.js";export{e as useKeybindingsStore};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
import { toast } from "sonner";
|
|
3
|
-
|
|
4
|
-
const POLL_INTERVAL = 5_000;
|
|
5
|
-
const HEALTH_URL = "/api/health";
|
|
6
|
-
const LOGS_URL = "/api/logs/recent";
|
|
7
|
-
const REPO = "hienlh/ppm";
|
|
8
|
-
|
|
9
|
-
/** Fetch recent server logs for bug report */
|
|
10
|
-
async function fetchRecentLogs(): Promise<string> {
|
|
11
|
-
try {
|
|
12
|
-
const res = await fetch(LOGS_URL, { signal: AbortSignal.timeout(3000) });
|
|
13
|
-
const json = await res.json();
|
|
14
|
-
return json.ok ? json.data.logs : "(failed to fetch logs)";
|
|
15
|
-
} catch {
|
|
16
|
-
return "(server logs unavailable)";
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** Open GitHub issue pre-filled with crash context + logs */
|
|
21
|
-
async function openBugReport() {
|
|
22
|
-
const logs = await fetchRecentLogs();
|
|
23
|
-
const title = encodeURIComponent("bug: server crashed unexpectedly");
|
|
24
|
-
const body = encodeURIComponent([
|
|
25
|
-
"## Environment",
|
|
26
|
-
`- URL: ${window.location.href}`,
|
|
27
|
-
`- UserAgent: ${navigator.userAgent}`,
|
|
28
|
-
`- Time: ${new Date().toISOString()}`,
|
|
29
|
-
"",
|
|
30
|
-
"## Description",
|
|
31
|
-
"The PPM server went down and restarted unexpectedly.",
|
|
32
|
-
"",
|
|
33
|
-
"## Steps to Reproduce",
|
|
34
|
-
"1. ",
|
|
35
|
-
"",
|
|
36
|
-
"## Recent Server Logs",
|
|
37
|
-
"```",
|
|
38
|
-
logs,
|
|
39
|
-
"```",
|
|
40
|
-
].join("\n"));
|
|
41
|
-
window.open(`https://github.com/${REPO}/issues/new?title=${title}&body=${body}`, "_blank");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Periodically pings /api/health. When server goes down and comes back,
|
|
46
|
-
* shows a toast suggesting the user report a bug.
|
|
47
|
-
*/
|
|
48
|
-
export function useHealthCheck() {
|
|
49
|
-
const wasDown = useRef(false);
|
|
50
|
-
const isFirstCheck = useRef(true);
|
|
51
|
-
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
let timer: ReturnType<typeof setInterval>;
|
|
54
|
-
|
|
55
|
-
async function check() {
|
|
56
|
-
try {
|
|
57
|
-
const res = await fetch(HEALTH_URL, { signal: AbortSignal.timeout(3000) });
|
|
58
|
-
if (res.ok) {
|
|
59
|
-
if (wasDown.current && !isFirstCheck.current) {
|
|
60
|
-
toast.warning("Server was restarted", {
|
|
61
|
-
description: "PPM server went down and recovered. If unexpected, please report it.",
|
|
62
|
-
duration: 15_000,
|
|
63
|
-
action: {
|
|
64
|
-
label: "Report Bug",
|
|
65
|
-
onClick: () => openBugReport(),
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
wasDown.current = false;
|
|
69
|
-
}
|
|
70
|
-
isFirstCheck.current = false;
|
|
71
|
-
} else {
|
|
72
|
-
wasDown.current = true;
|
|
73
|
-
}
|
|
74
|
-
} catch {
|
|
75
|
-
if (!wasDown.current && !isFirstCheck.current) {
|
|
76
|
-
toast.error("Server unreachable", {
|
|
77
|
-
description: "PPM server is not responding. It may have crashed.",
|
|
78
|
-
duration: 10_000,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
wasDown.current = true;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const initialDelay = setTimeout(() => {
|
|
86
|
-
check();
|
|
87
|
-
timer = setInterval(check, POLL_INTERVAL);
|
|
88
|
-
}, POLL_INTERVAL);
|
|
89
|
-
|
|
90
|
-
return () => {
|
|
91
|
-
clearTimeout(initialDelay);
|
|
92
|
-
clearInterval(timer);
|
|
93
|
-
};
|
|
94
|
-
}, []);
|
|
95
|
-
}
|