@hienlh/ppm 0.13.4 → 0.13.5
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 +6 -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-BdRw2cYi.js} +1 -1
- package/dist/web/assets/{chat-tab-UFEFOnpl.js → chat-tab-C2NBEXEX.js} +7 -7
- package/dist/web/assets/{code-editor-BJ1tSNWA.js → code-editor-BhmUC3pD.js} +2 -2
- package/dist/web/assets/{conflict-editor-CrgrMZ2F.js → conflict-editor-Br_CSQdA.js} +1 -1
- package/dist/web/assets/{database-viewer-e_NAkIL_.js → database-viewer-CbIMjroK.js} +1 -1
- package/dist/web/assets/{diff-viewer-C2eOczTs.js → diff-viewer-oq0RiOpV.js} +1 -1
- package/dist/web/assets/{extension-webview-B95nOfj-.js → extension-webview-DxP22X_y.js} +1 -1
- package/dist/web/assets/{image-preview-DAuPOzYl.js → image-preview-yX0yZtyd.js} +1 -1
- package/dist/web/assets/{index-DSOP0R0s.css → index-BJ76xcQz.css} +1 -1
- package/dist/web/assets/{index-DJOjXTcq.js → index-DJQJu6Ef.js} +3 -3
- package/dist/web/assets/keybindings-store-zxSQXdFL.js +1 -0
- package/dist/web/assets/{markdown-renderer-DwINRWo4.js → markdown-renderer-DHD3HPwK.js} +1 -1
- package/dist/web/assets/{pdf-preview-CqoQE09t.js → pdf-preview-BlRtar7G.js} +1 -1
- package/dist/web/assets/{port-forwarding-tab-De7qxkjp.js → port-forwarding-tab-DOYZIXHo.js} +1 -1
- package/dist/web/assets/{postgres-viewer-Dd6rLb8b.js → postgres-viewer-DM6b5mZl.js} +1 -1
- package/dist/web/assets/{settings-tab-BdTEumwU.js → settings-tab-JzeC-QC7.js} +1 -1
- package/dist/web/assets/{sqlite-viewer-Ccz2crvN.js → sqlite-viewer-IvosQxK2.js} +1 -1
- package/dist/web/assets/{terminal-tab-D7u7wsyb.js → terminal-tab-D4xxia2I.js} +1 -1
- package/dist/web/assets/{video-preview-BSDzqlzk.js → video-preview-ClY8ALGJ.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 +2 -1
- 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/hooks/use-chat.ts +8 -1
- 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
|
)}
|
|
@@ -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) => {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./vendor-markdown-0Mxgxy0L.js";import"./api-client-r4nyVy7H.js";import{E as e}from"./index-DJOjXTcq.js";export{e as useKeybindingsStore};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# Compare-Files Feature Ship
|
|
2
|
-
|
|
3
|
-
**Date**: 2026-04-22 14:35
|
|
4
|
-
**Severity**: Low
|
|
5
|
-
**Component**: Web IDE / Diff Viewer
|
|
6
|
-
**Status**: Resolved
|
|
7
|
-
|
|
8
|
-
## What Happened
|
|
9
|
-
|
|
10
|
-
Shipped compare-files feature (file diff picker) for PPM web IDE. Four trigger paths — tab context menu, file-tree context menu, command palette, keyboard shortcut `Mod+Alt+D`. Reused existing DiffViewer + git-diff tab type; zero backend changes. Added zustand store with persist middleware, ComparePicker singleton at App root, and in-flight guard to prevent double-invoke race.
|
|
11
|
-
|
|
12
|
-
## Technical Details
|
|
13
|
-
|
|
14
|
-
- **370 new lines of code** across 3 new files + 6 edited files
|
|
15
|
-
- **Zustand store** (`useCompareStore`) with `persist` middleware that strips dirty content >500KB
|
|
16
|
-
- **Dirty-buffer semantic**: snapshot at select-time, not compare-time (closing the tab doesn't invalidate selection)
|
|
17
|
-
- **Custom event** (`open-compare-picker`) dispatched from 4 trigger points, singleton listener mounted at App root
|
|
18
|
-
- **Keyboard shortcut**: `Mod+Alt+D` single-stroke (chord parser doesn't support `Cmd+K D` yet)
|
|
19
|
-
- **Module-scope subscription**: `useProjectStore.subscribe` auto-clears selection on project switch
|
|
20
|
-
- **In-flight guard**: ref-based tracking in `handlePick` to block concurrent invocations (reviewer comment M5)
|
|
21
|
-
- **Test coverage**: 1698 pass, 48 pre-existing unrelated failures, 0 new regressions
|
|
22
|
-
- **Code review**: 7.5/10, 0 critical, 6 major (1 addressed: M5; 3 deferred: M3/M4/M6)
|
|
23
|
-
|
|
24
|
-
## Why This Matters
|
|
25
|
-
|
|
26
|
-
Snapshot-at-select semantics felt risky initially but aligns with user mental model: "I'm picking a version to diff." Closing the tab doesn't invalidate the selection — this is more intuitive than invalidating on every interaction. Deferring byte-accurate persist limit (M4), clear-on-error (M3), and legacy multi-select-compare unification (M6) kept scope tight; all are low-risk YAGNI.
|
|
27
|
-
|
|
28
|
-
## Key Decisions
|
|
29
|
-
|
|
30
|
-
1. **Same-project only**: Cross-project selection auto-cleared rather than supported. Reduces state complexity; users can switch projects and re-pick.
|
|
31
|
-
2. **Single-stroke `Mod+Alt+D`**: Chord parser limitation means `Cmd+K D` unsupported. Single-stroke is good enough; avoiding yak-shave on chord parsing.
|
|
32
|
-
3. **Snapshot timing**: Capturing dirty buffer at select-time (not compare-time) prevents stale diffs after file edits. User closes tab; selection still valid.
|
|
33
|
-
4. **Defer judgment calls**: M3/M4/M6 are correctness edge-cases, not showstoppers. Shipping first; addressing in follow-up if telemetry justifies.
|
|
34
|
-
|
|
35
|
-
## Lessons Learned
|
|
36
|
-
|
|
37
|
-
- **Persist middleware footprint**: 500KB strip limit is conservative but safe; no observed bloat in dev.
|
|
38
|
-
- **Custom events + singleton**: Avoids prop-drilling 4 trigger points through component tree. Event-driven pattern cleaner than callback props.
|
|
39
|
-
- **In-flight guard as ref**: Simpler than promise-based debounce; prevents race without async complexity.
|
|
40
|
-
- **Deferred ≠ broken**: 6 major review comments sound high, but only 1 was blocking (M5). Others are judgment-calls; shipping with known trade-offs is valid.
|
|
41
|
-
|
|
42
|
-
## Next Steps
|
|
43
|
-
|
|
44
|
-
- Monitor telemetry for M3 (clear-on-error) if users report stale diffs
|
|
45
|
-
- Consider byte-accurate persist limit (M4) if DB bloat observed
|
|
46
|
-
- Unify legacy multi-select-compare path (M6) in v0.14 if feature gains adoption
|
|
47
|
-
|
|
48
|
-
Commit: `cc09bb5b9e652a2feefde4e533934a6f53301895`
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
**Status:** Resolved
|
|
53
|
-
**Summary:** Shipped compare-files feature with 4 trigger paths, zustand persist store, and event-driven ComparePicker. 370 new LOC, 0 new test regressions, 1 review blocker addressed (M5), 3 judgment-calls deferred (M3/M4/M6). Snapshot-at-select semantics and same-project-only scope kept complexity tight.
|