@wrongstack/webui 0.4.1 → 0.5.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/dist/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/wrongstack.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>WrongStack WebUI</title>
8
- <script type="module" crossorigin src="/assets/index-Do84Z2Fv.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-q1lcmxqy.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/vendor-Dff2jyfM.js">
10
10
  <link rel="stylesheet" crossorigin href="/assets/index-B-u6omip.css">
11
11
  </head>
package/dist/index.js CHANGED
@@ -795,15 +795,22 @@ var useSessionStore = create2()(
795
795
  todos: [],
796
796
  setSession: (session) => set({ session }),
797
797
  updateUsage: (usage) => set((state) => {
798
- const totalInput = (usage.input ?? 0) + (usage.cacheRead ?? 0) + (usage.cacheWrite ?? 0);
798
+ const inputDelta = usage.input + (usage.cacheRead ?? 0) + (usage.cacheWrite ?? 0);
799
+ const cacheReadDelta = usage.cacheRead ?? 0;
800
+ const cacheWriteDelta = usage.cacheWrite ?? 0;
799
801
  return {
800
802
  totalTokens: {
801
803
  input: state.totalTokens.input + usage.input,
802
804
  output: state.totalTokens.output + usage.output,
803
- cacheRead: (state.totalTokens.cacheRead ?? 0) + (usage.cacheRead ?? 0),
804
- cacheWrite: (state.totalTokens.cacheWrite ?? 0) + (usage.cacheWrite ?? 0)
805
+ cacheRead: (state.totalTokens.cacheRead ?? 0) + cacheReadDelta,
806
+ cacheWrite: (state.totalTokens.cacheWrite ?? 0) + cacheWriteDelta
805
807
  },
806
- lastInputTokens: totalInput || state.lastInputTokens
808
+ // lastInputTokens = the single most-recent turn's effective input
809
+ // (fresh + cached). This drives the ctx % chip in the topbar and
810
+ // is NOT additive — it's the latest provider response's token count.
811
+ // Use cacheWrite too because cache-write tokens were part of this
812
+ // turn's context cost (written to build the cache for next turn).
813
+ lastInputTokens: inputDelta || state.lastInputTokens
807
814
  };
808
815
  }),
809
816
  addCost: (cost) => set((state) => ({ cost: state.cost + cost })),
@@ -1055,6 +1062,15 @@ function installHandlers(ws) {
1055
1062
  });
1056
1063
  useSessionStore.setState({ lastInputTokens: payload.after });
1057
1064
  });
1065
+ on("provider.response", (msg) => {
1066
+ const payload = msg.payload;
1067
+ const u = payload?.usage;
1068
+ if (!u) return;
1069
+ const delta = (u.input ?? 0) + (u.cacheWrite ?? 0) - (u.cacheRead ?? 0);
1070
+ if (delta > 0) {
1071
+ useSessionStore.setState({ lastInputTokens: delta });
1072
+ }
1073
+ });
1058
1074
  on("context.repaired", (msg) => {
1059
1075
  const payload = msg.payload;
1060
1076
  const removed = payload.removedToolUses.length + payload.removedToolResults.length + payload.removedMessages;