@hienlh/ppm 0.13.4 → 0.13.6
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 +14 -0
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/dist/web/assets/{audio-preview-BSAe2WQB.js → audio-preview-DEJiSXcO.js} +1 -1
- package/dist/web/assets/{chat-tab-UFEFOnpl.js → chat-tab-DQBl8oq4.js} +7 -7
- package/dist/web/assets/{code-editor-BJ1tSNWA.js → code-editor-JxVGEgWY.js} +2 -2
- package/dist/web/assets/{conflict-editor-CrgrMZ2F.js → conflict-editor-BZ4mdQJX.js} +1 -1
- package/dist/web/assets/{database-viewer-e_NAkIL_.js → database-viewer-CBfw4hkk.js} +1 -1
- package/dist/web/assets/{diff-viewer-C2eOczTs.js → diff-viewer-4hobWs-B.js} +1 -1
- package/dist/web/assets/{extension-webview-B95nOfj-.js → extension-webview-DEOG3sef.js} +1 -1
- package/dist/web/assets/{image-preview-DAuPOzYl.js → image-preview-YNpn3xj7.js} +1 -1
- package/dist/web/assets/{index-DSOP0R0s.css → index-BJ76xcQz.css} +1 -1
- package/dist/web/assets/index-C7gvr4Xo.js +27 -0
- package/dist/web/assets/keybindings-store-BhvgfX51.js +1 -0
- package/dist/web/assets/{markdown-renderer-DwINRWo4.js → markdown-renderer-B7yiCjpQ.js} +1 -1
- package/dist/web/assets/{pdf-preview-CqoQE09t.js → pdf-preview-D3u3Hr2R.js} +1 -1
- package/dist/web/assets/{port-forwarding-tab-De7qxkjp.js → port-forwarding-tab-CSGpa5Bk.js} +1 -1
- package/dist/web/assets/{postgres-viewer-Dd6rLb8b.js → postgres-viewer-Cf4sjXxY.js} +1 -1
- package/dist/web/assets/{settings-tab-BdTEumwU.js → settings-tab-BLlfwRRc.js} +1 -1
- package/dist/web/assets/{sqlite-viewer-Ccz2crvN.js → sqlite-viewer-WAA8mf_X.js} +1 -1
- package/dist/web/assets/{terminal-tab-D7u7wsyb.js → terminal-tab-Bn8wLy9d.js} +1 -1
- package/dist/web/assets/{video-preview-BSDzqlzk.js → video-preview-CRDjNIVX.js} +1 -1
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +1 -1
- package/src/server/routes/chat.ts +27 -17
- package/src/services/jsonl-transcript-parser.ts +10 -1
- package/src/services/supervisor.ts +35 -35
- package/src/web/components/chat/message-list.tsx +49 -2
- package/src/web/components/layout/draggable-tab.tsx +1 -1
- package/src/web/components/layout/mobile-nav.tsx +39 -4
- package/src/web/hooks/use-chat.ts +8 -1
- package/dist/web/assets/index-DJOjXTcq.js +0 -27
- package/dist/web/assets/keybindings-store-V12kZZHO.js +0 -1
- package/docs/journals/2026-04-22-compare-files-feature-ship.md +0 -53
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { Subprocess } from "bun";
|
|
8
8
|
import { resolve } from "node:path";
|
|
9
9
|
import {
|
|
10
|
-
readFileSync, writeFileSync, existsSync, mkdirSync, openSync, appendFileSync,
|
|
10
|
+
readFileSync, writeFileSync, existsSync, mkdirSync, openSync, closeSync, appendFileSync,
|
|
11
11
|
unlinkSync,
|
|
12
12
|
} from "node:fs";
|
|
13
13
|
import { getPpmDir } from "./ppm-dir.ts";
|
|
@@ -170,40 +170,28 @@ export async function spawnServer(
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// ─── Tunnel management ─────────────────────────────────────────────────
|
|
173
|
-
|
|
174
|
-
const reader = stderr.getReader();
|
|
175
|
-
const decoder = new TextDecoder();
|
|
176
|
-
let buffer = "";
|
|
173
|
+
const cloudflaredLogPath = () => resolve(getPpmDir(), "cloudflared.log");
|
|
177
174
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Poll cloudflared log file for trycloudflare URL.
|
|
177
|
+
* Stderr is redirected to this file (not piped) so cloudflared survives
|
|
178
|
+
* parent supervisor exit during self-replace (no SIGPIPE on closed pipe).
|
|
179
|
+
*/
|
|
180
|
+
async function extractUrlFromLogFile(child: Subprocess): Promise<string> {
|
|
181
|
+
const path = cloudflaredLogPath();
|
|
182
|
+
const deadline = Date.now() + 30_000;
|
|
183
|
+
while (Date.now() < deadline) {
|
|
184
|
+
if (existsSync(path)) {
|
|
182
185
|
try {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
try { while (!(await reader.read()).done) {} } catch {}
|
|
193
|
-
})();
|
|
194
|
-
resolve(match[0]);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
clearTimeout(timeout);
|
|
199
|
-
reject(new Error("cloudflared exited without providing URL"));
|
|
200
|
-
} catch (err) {
|
|
201
|
-
clearTimeout(timeout);
|
|
202
|
-
reject(err);
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
read();
|
|
206
|
-
});
|
|
186
|
+
const content = readFileSync(path, "utf8");
|
|
187
|
+
const match = content.match(TUNNEL_URL_REGEX);
|
|
188
|
+
if (match) return match[0];
|
|
189
|
+
} catch {}
|
|
190
|
+
}
|
|
191
|
+
if (child.exitCode !== null) throw new Error("cloudflared exited without providing URL");
|
|
192
|
+
await Bun.sleep(200);
|
|
193
|
+
}
|
|
194
|
+
throw new Error("Tunnel URL timeout (30s)");
|
|
207
195
|
}
|
|
208
196
|
|
|
209
197
|
async function syncUrlToCloud(url: string) {
|
|
@@ -243,11 +231,23 @@ export async function spawnTunnel(port: number): Promise<void> {
|
|
|
243
231
|
]
|
|
244
232
|
: [bin, "tunnel", "--url", `http://127.0.0.1:${port}`];
|
|
245
233
|
|
|
246
|
-
|
|
234
|
+
// Redirect cloudflared stderr to a log file (not pipe). This way cloudflared
|
|
235
|
+
// survives parent supervisor exit during self-replace — a piped stderr would
|
|
236
|
+
// close when parent exits, causing SIGPIPE on next cloudflared log write and
|
|
237
|
+
// killing the tunnel ~10-15s later (silently breaking adoption).
|
|
238
|
+
const logPath = cloudflaredLogPath();
|
|
239
|
+
try { unlinkSync(logPath); } catch {} // truncate stale URLs from prior run
|
|
240
|
+
const tunnelLogFd = openSync(logPath, "a");
|
|
241
|
+
try {
|
|
242
|
+
tunnelChild = Bun.spawn(tunnelCmd, { stderr: tunnelLogFd, stdout: "ignore", stdin: "ignore" });
|
|
243
|
+
} finally {
|
|
244
|
+
// Close our handle; cloudflared keeps its own via dup2
|
|
245
|
+
try { closeSync(tunnelLogFd); } catch {}
|
|
246
|
+
}
|
|
247
247
|
if (underSystemd) log("INFO", "Tunnel spawned inside transient systemd-run scope (escapes ppm.service cgroup)");
|
|
248
248
|
|
|
249
249
|
try {
|
|
250
|
-
tunnelUrl = await
|
|
250
|
+
tunnelUrl = await extractUrlFromLogFile(tunnelChild);
|
|
251
251
|
} catch (err) {
|
|
252
252
|
log("ERROR", `Tunnel URL extraction failed: ${err}`);
|
|
253
253
|
tunnelUrl = null;
|
|
@@ -109,12 +109,21 @@ export function MessageList({
|
|
|
109
109
|
onFork?.(msgContent, msgId);
|
|
110
110
|
}, [onFork]);
|
|
111
111
|
|
|
112
|
-
//
|
|
113
|
-
//
|
|
112
|
+
// Scroll anchor bridge published from inside StickToBottom (needs the context's scrollRef).
|
|
113
|
+
// MessageList captures pre-expand scroll metrics and restores post-render so the compact
|
|
114
|
+
// message stays at the same viewport offset when history is prepended.
|
|
115
|
+
const scrollAnchorRef = useRef<ScrollAnchorHandle | null>(null);
|
|
116
|
+
|
|
117
|
+
// Wrap expandCompact: bump visibleCount, then restore scroll after React commits the new DOM.
|
|
118
|
+
// Pre-compact messages land at top of flattened array, above pagination window — bumping
|
|
119
|
+
// visibleCount by loaded count ensures they render immediately.
|
|
114
120
|
const handleExpandCompact = useCallback(async (compactId: string, jsonlPath: string): Promise<number> => {
|
|
115
121
|
if (!onExpandCompact) throw new Error("Expansion not wired");
|
|
122
|
+
scrollAnchorRef.current?.capture();
|
|
116
123
|
const count = await onExpandCompact(compactId, jsonlPath);
|
|
117
124
|
setVisibleCount((c) => c + count);
|
|
125
|
+
// rAF fires after React commits + layout; two rAFs to cover any async measure (lazy markdown).
|
|
126
|
+
requestAnimationFrame(() => requestAnimationFrame(() => scrollAnchorRef.current?.restore()));
|
|
118
127
|
return count;
|
|
119
128
|
}, [onExpandCompact]);
|
|
120
129
|
|
|
@@ -140,6 +149,7 @@ export function MessageList({
|
|
|
140
149
|
<div className="relative flex-1 overflow-hidden flex flex-col min-h-0">
|
|
141
150
|
<StickToBottom className="flex-1 overflow-y-auto overflow-x-hidden [contain:strict] [overflow-anchor:auto]" resize="smooth" initial="instant">
|
|
142
151
|
<StickToBottom.Content className="p-4 space-y-4 select-none [&>*]:[overflow-anchor:auto]">
|
|
152
|
+
<ScrollAnchorBridge bridgeRef={scrollAnchorRef} />
|
|
143
153
|
{hasMore && (
|
|
144
154
|
<button onClick={() => setVisibleCount((c) => c + PAGE_SIZE)}
|
|
145
155
|
className="w-full py-2 text-xs text-text-secondary hover:text-text-primary bg-surface-elevated/50 hover:bg-surface-elevated rounded-md border border-border/50 transition-colors">
|
|
@@ -179,6 +189,43 @@ export function MessageList({
|
|
|
179
189
|
);
|
|
180
190
|
}
|
|
181
191
|
|
|
192
|
+
/** Imperative handle exposed by ScrollAnchorBridge — capture & restore scroll on prepend. */
|
|
193
|
+
interface ScrollAnchorHandle {
|
|
194
|
+
/** Record current scrollTop + scrollHeight before a prepend. No-op if user is at bottom. */
|
|
195
|
+
capture: () => void;
|
|
196
|
+
/** After prepend commits, adjust scrollTop by the height delta so viewport stays locked. */
|
|
197
|
+
restore: () => void;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Consumes StickToBottom's scrollRef (only accessible inside its subtree) and publishes
|
|
202
|
+
* capture/restore functions to a ref owned by the parent MessageList, so prepend-history
|
|
203
|
+
* expansion can preserve scroll position across the re-render.
|
|
204
|
+
*/
|
|
205
|
+
function ScrollAnchorBridge({ bridgeRef }: { bridgeRef: React.MutableRefObject<ScrollAnchorHandle | null> }) {
|
|
206
|
+
const { scrollRef, isAtBottom } = useStickToBottomContext();
|
|
207
|
+
const state = useRef<{ top: number; height: number } | null>(null);
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
bridgeRef.current = {
|
|
210
|
+
capture: () => {
|
|
211
|
+
const el = scrollRef.current;
|
|
212
|
+
if (!el || isAtBottom) { state.current = null; return; } // skip if sticking to bottom
|
|
213
|
+
state.current = { top: el.scrollTop, height: el.scrollHeight };
|
|
214
|
+
},
|
|
215
|
+
restore: () => {
|
|
216
|
+
const el = scrollRef.current;
|
|
217
|
+
const s = state.current;
|
|
218
|
+
if (!el || !s) return;
|
|
219
|
+
const delta = el.scrollHeight - s.height;
|
|
220
|
+
if (delta !== 0) el.scrollTop = s.top + delta;
|
|
221
|
+
state.current = null;
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
return () => { bridgeRef.current = null; };
|
|
225
|
+
}, [bridgeRef, scrollRef, isAtBottom]);
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
|
|
182
229
|
/** Floating button to scroll back to bottom when user has scrolled up */
|
|
183
230
|
function ScrollToBottomButton() {
|
|
184
231
|
const { isAtBottom, scrollToBottom } = useStickToBottomContext();
|
|
@@ -166,7 +166,7 @@ export function DraggableTab({
|
|
|
166
166
|
// Tag identity marker — VS Code-style vertical bar on left edge (centered, ~60% height, rounded right)
|
|
167
167
|
<span
|
|
168
168
|
aria-hidden
|
|
169
|
-
className="absolute left-0 top-2 bottom-2 w-[
|
|
169
|
+
className="absolute left-0 top-2 bottom-2 w-[3px] rounded-r-full pointer-events-none"
|
|
170
170
|
style={{ backgroundColor: tagColor }}
|
|
171
171
|
/>
|
|
172
172
|
)}
|
|
@@ -15,9 +15,11 @@ import type { Tab, TabType } from "@/stores/tab-store";
|
|
|
15
15
|
import { cn } from "@/lib/utils";
|
|
16
16
|
import { openCommandPalette } from "@/hooks/use-global-keybindings";
|
|
17
17
|
import { useNotificationStore, notificationColor } from "@/stores/notification-store";
|
|
18
|
+
import { useStreamingStore } from "@/stores/streaming-store";
|
|
18
19
|
import { useTabOverflow, getHiddenUnreadDirection } from "@/hooks/use-tab-overflow";
|
|
19
20
|
import { downloadFile } from "@/lib/file-download";
|
|
20
21
|
import { FileActions } from "@/components/explorer/file-actions";
|
|
22
|
+
import { api, projectUrl } from "@/lib/api-client";
|
|
21
23
|
|
|
22
24
|
const NEW_TAB_OPTIONS: { type: TabType; label: string }[] = [
|
|
23
25
|
{ type: "terminal", label: "Terminal" },
|
|
@@ -63,6 +65,9 @@ export function MobileNav({ onMenuPress, onProjectsPress }: MobileNavProps) {
|
|
|
63
65
|
const mobileScrollRef = useRef<HTMLDivElement>(null);
|
|
64
66
|
const prevTabCount = useRef(tabs.length);
|
|
65
67
|
const notifications = useNotificationStore((s) => s.notifications);
|
|
68
|
+
const streamingSessions = useStreamingStore((s) => s.sessions);
|
|
69
|
+
const [sessionTagMap, setSessionTagMap] = useState<Record<string, { id: number; name: string; color: string }>>({});
|
|
70
|
+
|
|
66
71
|
const { canScrollLeft, canScrollRight, scrollRight: doScrollRight } =
|
|
67
72
|
useTabOverflow(mobileScrollRef);
|
|
68
73
|
const hiddenUnread = getHiddenUnreadDirection(mobileScrollRef.current, tabRefs.current as Map<string, HTMLElement>, tabs, notifications);
|
|
@@ -154,6 +159,19 @@ export function MobileNav({ onMenuPress, onProjectsPress }: MobileNavProps) {
|
|
|
154
159
|
|
|
155
160
|
// Active project avatar for the Projects button
|
|
156
161
|
const { activeProject, projects, customOrder } = useProjectStore(useShallow((s) => ({ activeProject: s.activeProject, projects: s.projects, customOrder: s.customOrder })));
|
|
162
|
+
|
|
163
|
+
// Session tag map — same fetch pattern as desktop tab-bar so mobile tabs can show tag bar
|
|
164
|
+
const chatSessionIds = tabs.filter((t) => t.type === "chat" && t.metadata?.sessionId).map((t) => t.metadata!.sessionId as string);
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
if (!activeProject?.name || chatSessionIds.length === 0) return;
|
|
167
|
+
api.get<{ sessions: { id: string; tag?: { id: number; name: string; color: string } | null }[] }>(
|
|
168
|
+
`${projectUrl(activeProject.name)}/chat/sessions?limit=50`,
|
|
169
|
+
).then((data) => {
|
|
170
|
+
const map: Record<string, { id: number; name: string; color: string }> = {};
|
|
171
|
+
for (const s of data.sessions) { if (s.tag) map[s.id] = s.tag; }
|
|
172
|
+
setSessionTagMap(map);
|
|
173
|
+
}).catch(() => {});
|
|
174
|
+
}, [activeProject?.name, chatSessionIds.join(",")]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
157
175
|
const ordered = resolveOrder(projects, customOrder ?? null);
|
|
158
176
|
const allNames = ordered.map((p) => p.name);
|
|
159
177
|
const activeIdx = ordered.findIndex((p) => p.name === activeProject?.name);
|
|
@@ -218,6 +236,8 @@ export function MobileNav({ onMenuPress, onProjectsPress }: MobileNavProps) {
|
|
|
218
236
|
const sessionId = tab.type === "chat" ? (tab.metadata?.sessionId as string) : undefined;
|
|
219
237
|
const entry = sessionId ? notifications.get(sessionId) : undefined;
|
|
220
238
|
const notiType = entry && entry.count > 0 ? entry.type : null;
|
|
239
|
+
const tagColor = sessionId ? sessionTagMap[sessionId]?.color : undefined;
|
|
240
|
+
const isStreaming = sessionId ? streamingSessions.has(sessionId) : false;
|
|
221
241
|
return (
|
|
222
242
|
<button
|
|
223
243
|
key={tab.id}
|
|
@@ -231,15 +251,30 @@ export function MobileNav({ onMenuPress, onProjectsPress }: MobileNavProps) {
|
|
|
231
251
|
onTouchMove={cancelLongPress}
|
|
232
252
|
onContextMenu={(e) => e.preventDefault()}
|
|
233
253
|
className={cn(
|
|
234
|
-
"flex items-center gap-1 px-3 h-12 whitespace-nowrap text-xs shrink-0 border-t-2 transition-colors",
|
|
254
|
+
"relative flex items-center gap-1 px-3 h-12 whitespace-nowrap text-xs shrink-0 border-t-2 transition-colors",
|
|
235
255
|
isActive ? "border-primary bg-surface text-primary" : "border-transparent text-text-secondary",
|
|
236
256
|
)}
|
|
237
257
|
>
|
|
238
|
-
|
|
258
|
+
{tagColor && (
|
|
259
|
+
// Tag identity marker — VS Code-style vertical bar on left edge, matches desktop tab
|
|
260
|
+
<span
|
|
261
|
+
aria-hidden
|
|
262
|
+
className="absolute left-0 top-2 bottom-2 w-[3px] rounded-r-full pointer-events-none"
|
|
263
|
+
style={{ backgroundColor: tagColor }}
|
|
264
|
+
/>
|
|
265
|
+
)}
|
|
266
|
+
<span className={cn("relative", isStreaming && "text-amber-500")}>
|
|
239
267
|
<Icon className="size-4" />
|
|
240
|
-
{
|
|
268
|
+
{isStreaming ? (
|
|
269
|
+
// Messenger-style typing dots inside chat bubble — inherits amber via bg-current
|
|
270
|
+
<span aria-hidden className="absolute inset-0 flex items-center justify-center gap-[1.5px]">
|
|
271
|
+
<span className="tab-typing-dot size-[2px] rounded-full bg-current" />
|
|
272
|
+
<span className="tab-typing-dot size-[2px] rounded-full bg-current" style={{ animationDelay: "0.15s" }} />
|
|
273
|
+
<span className="tab-typing-dot size-[2px] rounded-full bg-current" style={{ animationDelay: "0.3s" }} />
|
|
274
|
+
</span>
|
|
275
|
+
) : notiType && !isActive ? (
|
|
241
276
|
<span className={cn("absolute -top-1 -right-1 size-2 rounded-full", notificationColor(notiType))} />
|
|
242
|
-
)}
|
|
277
|
+
) : null}
|
|
243
278
|
</span>
|
|
244
279
|
<span className="max-w-[80px] truncate">{tab.title}</span>
|
|
245
280
|
{tab.closable && (
|
|
@@ -816,7 +816,14 @@ export function useChat(sessionId: string | null, providerId = "claude", project
|
|
|
816
816
|
/** Fetch pre-compact transcript. Idempotent: re-expanding same id replaces entry. */
|
|
817
817
|
const expandCompact = useCallback(async (compactMessageId: string, jsonlPath: string): Promise<number> => {
|
|
818
818
|
if (!projectName) throw new Error("No project context available");
|
|
819
|
-
|
|
819
|
+
// Claude's compact summary references the CURRENT session file (pre+summary+post).
|
|
820
|
+
// Strip the `pc-{hash}-` prefix added by prefixPreCompactIds for nested expansions
|
|
821
|
+
// so BE receives the raw session uuid and truncates at the correct boundary.
|
|
822
|
+
const rawUuid = compactMessageId.replace(/^pc-[^-]+-/, "");
|
|
823
|
+
const url =
|
|
824
|
+
`${projectUrl(projectName)}/chat/pre-compact-messages` +
|
|
825
|
+
`?jsonlPath=${encodeURIComponent(jsonlPath)}` +
|
|
826
|
+
`&before=${encodeURIComponent(rawUuid)}`;
|
|
820
827
|
const loaded = await api.get<ChatMessage[]>(url);
|
|
821
828
|
const prefixed = prefixPreCompactIds(loaded, jsonlPath);
|
|
822
829
|
setExpansions((prev) => {
|