pi-web-ui 0.10.0 → 0.10.2

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/README.md CHANGED
@@ -72,6 +72,37 @@ npm i -g .
72
72
  > install scripts, approve node-pty's native build once after installing:
73
73
  > `npm approve-scripts node-pty@1.1.0` (standard npm does this automatically).
74
74
 
75
+ ### As a pi package (web UI inside pi)
76
+
77
+ `pi-web-ui` is also published as a **pi package** (`pi-package` on npm) so it
78
+ can be installed and used from within a pi session:
79
+
80
+ ```bash
81
+ pi install npm:pi-web-ui
82
+ ```
83
+
84
+ Once installed, a `/webui` command becomes available inside pi, launching the
85
+ local web UI against your current working directory:
86
+
87
+ ```
88
+ /webui # start + open browser (current dir)
89
+ /webui --port 9000 # start on a specific port
90
+ /webui --no-browser # start without opening the browser
91
+ /webui stop # stop the running instance
92
+ /webui status # show URL / status
93
+ ```
94
+
95
+ > **Note — `pi install` is NOT a global CLI install.**
96
+ >
97
+ > `pi install npm:pi-web-ui` only loads the package into pi's extension tree
98
+ > (`~/.pi/agent/npm/node_modules/`) and registers its extension for pi sessions.
99
+ > It does **not** put a `pi-web-ui` executable on your shell `PATH`, so you
100
+ > cannot run the `pi-web-ui` terminal command from that install. For the CLI you
101
+ > still need the global npm install above (`npm i -g pi-web-ui`), which is what
102
+ > `which pi-web-ui` resolves to. `pi install` ≠ `npm i -g`: one is for pi
103
+ > extensions, the other for a system-wide command. Both can coexist (the global
104
+ > 0.x CLI for terminal use, the pi package for the `/webui` in-pi entry).
105
+
75
106
  ### Start
76
107
 
77
108
  ```bash
@@ -777,6 +777,7 @@ export class ClientSession {
777
777
  lastActiveAt: Date.now(),
778
778
  msgIds: new Map(),
779
779
  nextMsgId: 1,
780
+ userSeqByTs: new Map(),
780
781
  uiMessageCache: new Map(),
781
782
  lastMessagesSig: "",
782
783
  lastMessagesArray: [],
@@ -910,7 +911,18 @@ export class ClientSession {
910
911
  const cached = conv.uiMessageCache.get(cacheKey);
911
912
  if (cached)
912
913
  return cached;
913
- const msg = serializeMessage(m, n);
914
+ // User-message id suffix is a 1-based count of user messages sharing
915
+ // this timestamp (that's what resolveUserMessageEntryId() expects). n is
916
+ // a global per-conversation counter across ALL roles, so it can't be
917
+ // reused as the seq — otherwise editing anything but the first question
918
+ // fails to resolve ("找不到要编辑的消息").
919
+ let seq = n;
920
+ if (m.role === "user") {
921
+ const ts = m.timestamp ?? 0;
922
+ seq = (conv.userSeqByTs.get(ts) ?? 0) + 1;
923
+ conv.userSeqByTs.set(ts, seq);
924
+ }
925
+ const msg = serializeMessage(m, seq);
914
926
  if (msg)
915
927
  conv.uiMessageCache.set(cacheKey, msg);
916
928
  return msg;
@@ -2110,7 +2122,10 @@ export class ClientSession {
2110
2122
  const ts = Number(m[1]);
2111
2123
  const seq = m[2] ? Number(m[2]) : 1;
2112
2124
  let count = 0;
2113
- for (const entry of this.session.sessionManager.getEntries()) {
2125
+ // Resolve against the compaction-aware current leaf path — the same list
2126
+ // the UI renders (state.messages). Scanning the whole file (getEntries)
2127
+ // could match a summarized entry or one on a different branch.
2128
+ for (const entry of this.session.sessionManager.buildContextEntries()) {
2114
2129
  if (entry.type !== "message")
2115
2130
  continue;
2116
2131
  const msg = entry.message;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-web-ui",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Web chat interface for the pi coding agent, powered by the pi SDK (@earendil-works/pi-coding-agent) — one-command run, Docker/systemd/launchd deployable",
5
5
  "license": "MIT",
6
6
  "type": "module",