@caius_kong/ccusage-dashboard 0.2.3 → 0.2.4

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/lib/index.html CHANGED
@@ -188,8 +188,8 @@ function renderSessions(data){
188
188
  if(!list.length){$("sessionsList").innerHTML='<div class="empty">no sessions in range</div>';return;}
189
189
  $("sessionsList").innerHTML=list.map(s=>{
190
190
  const label = s.hasCwd
191
- ? `<span class="name">${esc(s.dirName||s.cwd)} <span class="pill sessid">${esc(s.id.slice(0,8))}</span></span>`
192
- : `<span class="name muted">${esc(s.id.slice(0,8))}</span>`;
191
+ ? `<span class="name" title="workdir from ccusage: ${esc(s.cwd||s.projectKey)}">${esc(s.dirName||s.id.slice(0,8))} <span class="pill sessid">${esc(s.id.slice(0,8))}</span></span>`
192
+ : `<span class="name muted" title="workdir not provided by ccusage for ${esc(s.agent)}">${esc(s.id.slice(0,8))}</span>`;
193
193
  const last=(s.lastActivity||"").slice(0,10);
194
194
  return `<div class="row">
195
195
  <div class="row-top"><span>${label} <span class="pill">${esc(s.agent)}</span></span><span class="cost">${fmtUsd(s.cost)}</span></div>
package/lib/server.py CHANGED
@@ -230,8 +230,9 @@ def sessions(since_days: int = 30) -> dict:
230
230
  "cacheReadTokens": r.get("cacheReadTokens", 0),
231
231
  "cacheCreationTokens": r.get("cacheCreationTokens", 0),
232
232
  "lastActivity": last_activity,
233
- "cwd": cwd, # absolute-ish path, empty if ccusage didn't provide it
233
+ "cwd": cwd, # best-effort decoded path, empty if ccusage didn't provide it
234
234
  "dirName": dir_name, # last path segment; empty if ccusage didn't provide
235
+ "projectKey": project_raw, # raw ccusage projectPath (authoritative, may be encoded)
235
236
  "hasCwd": bool(project_raw),
236
237
  }
237
238
  )
@@ -242,12 +243,18 @@ def sessions(since_days: int = 30) -> dict:
242
243
  def _decode_cwd(raw: str) -> str:
243
244
  """Best-effort decode of ccusage's projectPath into a readable path.
244
245
 
245
- pi's projectPath is a Claude-Code-style encoded dir name where '/' became '-'.
246
+ pi's projectPath is a Claude-Code-style encoded dir name where '/' became '-',
247
+ and literal '-' inside a dir name is NOT distinguishable from the separator
248
+ (encoding is lossy). So this is approximate: 'fund-tracker' may come back as
249
+ 'fund/tracker'. The authoritative string is the raw projectPath itself.
246
250
  Example: '--Users-caius-kong-Documents-...-AutoTrans--' -> /Users/caius_kong/.../AutoTrans
247
251
  """
248
252
  if not raw:
249
253
  return ""
250
- return raw.replace("-", "/")
254
+ parts = [p for p in raw.replace("-", "/").split("/") if p]
255
+ if not parts:
256
+ return ""
257
+ return "/" + "/".join(parts)
251
258
 
252
259
 
253
260
  def _basename(raw: str) -> str:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caius_kong/ccusage-dashboard",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "One-command local dashboard for ccusage: today/week/month/custom cost by model, 30-day trend, monthly budget alert. Numbers straight from ccusage.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",