@hienlh/ppm 0.8.78 → 0.8.80

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.
Files changed (23) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/web/assets/{browser-tab-DQJLMN11.js → browser-tab-CGOTINns.js} +1 -1
  3. package/dist/web/assets/{chat-tab-xp4ZqCGD.js → chat-tab-BqMDTKtI.js} +3 -3
  4. package/dist/web/assets/{code-editor-De6Xs-Kq.js → code-editor-CjRkLOUf.js} +1 -1
  5. package/dist/web/assets/{database-viewer-CExMyEmq.js → database-viewer-CYWYWp5I.js} +1 -1
  6. package/dist/web/assets/{diff-viewer-C7EECdwr.js → diff-viewer-B8GzQDcN.js} +1 -1
  7. package/dist/web/assets/{git-graph-DqFYj10H.js → git-graph-ChRS88JC.js} +1 -1
  8. package/dist/web/assets/{index-CiuAeXR3.js → index-JFBF6oPj.js} +3 -3
  9. package/dist/web/assets/keybindings-store-Cefijedj.js +1 -0
  10. package/dist/web/assets/{markdown-renderer-CnBEa3kk.js → markdown-renderer-BZgdGJ6Y.js} +1 -1
  11. package/dist/web/assets/{postgres-viewer-DvMnxJ7g.js → postgres-viewer-D7GKjN9D.js} +1 -1
  12. package/dist/web/assets/{settings-tab-C0ltpIWq.js → settings-tab-CuFxwHVl.js} +1 -1
  13. package/dist/web/assets/{sqlite-viewer-DR9KKOhW.js → sqlite-viewer-BKRNVjUr.js} +1 -1
  14. package/dist/web/assets/{terminal-tab-B__sTLzq.js → terminal-tab-BOjj9X-S.js} +1 -1
  15. package/dist/web/assets/{use-monaco-theme-BZiSwNRE.js → use-monaco-theme-CWzZ1S6x.js} +1 -1
  16. package/dist/web/index.html +1 -1
  17. package/dist/web/sw.js +1 -1
  18. package/package.json +1 -1
  19. package/src/services/cloud-ws.service.ts +6 -1
  20. package/src/services/supervisor.ts +26 -3
  21. package/src/web/components/chat/chat-tab.tsx +17 -12
  22. package/src/web/components/chat/chat-welcome.tsx +135 -0
  23. package/dist/web/assets/keybindings-store-DYgvd7L0.js +0 -1
@@ -0,0 +1,135 @@
1
+ import { useState, useEffect, useCallback } from "react";
2
+ import { Bot, MessageSquare, Pin, PinOff } from "lucide-react";
3
+ import { api, projectUrl } from "@/lib/api-client";
4
+ import type { SessionInfo } from "../../../types/chat";
5
+
6
+ const MAX_RECENT_SESSIONS = 5;
7
+
8
+ function formatRelativeDate(iso: string): string {
9
+ try {
10
+ const date = new Date(iso);
11
+ const now = new Date();
12
+ const diffMs = now.getTime() - date.getTime();
13
+ const diffMin = Math.floor(diffMs / 60_000);
14
+ if (diffMin < 1) return "just now";
15
+ if (diffMin < 60) return `${diffMin}m ago`;
16
+ const diffHr = Math.floor(diffMin / 60);
17
+ if (diffHr < 24) return `${diffHr}h ago`;
18
+ const diffDay = Math.floor(diffHr / 24);
19
+ if (diffDay < 7) return `${diffDay}d ago`;
20
+ return date.toLocaleDateString(undefined, { month: "short", day: "numeric" });
21
+ } catch {
22
+ return "";
23
+ }
24
+ }
25
+
26
+ interface ChatWelcomeProps {
27
+ projectName: string;
28
+ onSelectSession: (session: SessionInfo) => void;
29
+ }
30
+
31
+ export function ChatWelcome({ projectName, onSelectSession }: ChatWelcomeProps) {
32
+ const [sessions, setSessions] = useState<SessionInfo[]>([]);
33
+ const [loading, setLoading] = useState(false);
34
+
35
+ const loadSessions = useCallback(async () => {
36
+ if (!projectName) return;
37
+ setLoading(true);
38
+ try {
39
+ const data = await api.get<SessionInfo[]>(`${projectUrl(projectName)}/chat/sessions`);
40
+ setSessions(data.slice(0, MAX_RECENT_SESSIONS));
41
+ } catch {
42
+ // silently ignore
43
+ } finally {
44
+ setLoading(false);
45
+ }
46
+ }, [projectName]);
47
+
48
+ useEffect(() => { loadSessions(); }, [loadSessions]);
49
+
50
+ const togglePin = useCallback(async (e: React.MouseEvent, session: SessionInfo) => {
51
+ e.stopPropagation();
52
+ if (!projectName) return;
53
+ const url = `${projectUrl(projectName)}/chat/sessions/${session.id}/pin`;
54
+ try {
55
+ if (session.pinned) {
56
+ await api.del(url);
57
+ } else {
58
+ await api.put(url);
59
+ }
60
+ setSessions((prev) => {
61
+ const updated = prev.map((s) => s.id === session.id ? { ...s, pinned: !s.pinned } : s);
62
+ return updated.sort((a, b) => {
63
+ if (a.pinned && !b.pinned) return -1;
64
+ if (!a.pinned && b.pinned) return 1;
65
+ return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
66
+ });
67
+ });
68
+ } catch {
69
+ // silently ignore
70
+ }
71
+ }, [projectName]);
72
+
73
+ const pinnedSessions = sessions.filter((s) => s.pinned);
74
+ const recentSessions = sessions.filter((s) => !s.pinned).slice(0, MAX_RECENT_SESSIONS);
75
+
76
+ function renderSessionRow(session: SessionInfo) {
77
+ return (
78
+ <button
79
+ key={session.id}
80
+ onClick={() => onSelectSession(session)}
81
+ className="group flex items-center gap-2.5 w-full px-3 py-2.5 text-left hover:bg-surface-elevated active:bg-surface-elevated transition-colors border-b border-border/50 last:border-0"
82
+ >
83
+ <MessageSquare className="size-3.5 shrink-0 text-text-subtle" />
84
+ <span className="flex-1 min-w-0 text-xs font-medium truncate text-text-primary">
85
+ {session.title || "Untitled"}
86
+ </span>
87
+ {session.updatedAt && (
88
+ <span className="text-[10px] text-text-subtle shrink-0">
89
+ {formatRelativeDate(session.updatedAt)}
90
+ </span>
91
+ )}
92
+ <span
93
+ role="button"
94
+ tabIndex={0}
95
+ onClick={(e) => togglePin(e, session)}
96
+ className={`p-1 rounded transition-colors shrink-0 ${
97
+ session.pinned
98
+ ? "text-primary hover:text-primary/70"
99
+ : "text-text-subtle md:opacity-0 md:group-hover:opacity-100 hover:text-text-primary"
100
+ }`}
101
+ aria-label={session.pinned ? "Unpin session" : "Pin session"}
102
+ >
103
+ {session.pinned ? <PinOff className="size-3" /> : <Pin className="size-3" />}
104
+ </span>
105
+ </button>
106
+ );
107
+ }
108
+
109
+ return (
110
+ <div className="flex flex-col items-center justify-center h-full gap-6 text-text-secondary overflow-y-auto">
111
+ <div className="flex flex-col items-center gap-3">
112
+ <Bot className="size-10 text-text-subtle" />
113
+ <p className="text-sm">Send a message to start a new conversation</p>
114
+ </div>
115
+
116
+ {!loading && pinnedSessions.length > 0 && (
117
+ <div className="flex flex-col gap-2 w-full max-w-sm px-4">
118
+ <p className="text-xs text-text-subtle text-center">Pinned</p>
119
+ <div className="w-full rounded-md border border-border bg-surface overflow-hidden">
120
+ {pinnedSessions.map(renderSessionRow)}
121
+ </div>
122
+ </div>
123
+ )}
124
+
125
+ {!loading && recentSessions.length > 0 && (
126
+ <div className="flex flex-col gap-2 w-full max-w-sm px-4">
127
+ <p className="text-xs text-text-subtle text-center">Recent chats</p>
128
+ <div className="w-full rounded-md border border-border bg-surface overflow-hidden">
129
+ {recentSessions.map(renderSessionRow)}
130
+ </div>
131
+ </div>
132
+ )}
133
+ </div>
134
+ );
135
+ }
@@ -1 +0,0 @@
1
- import"./react-nm2Ru1Pt.js";import"./api-client-BfBM3I7n.js";import{M as e}from"./index-CiuAeXR3.js";export{e as useKeybindingsStore};