pi-web-ui 0.10.1 → 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.
@@ -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.1",
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",