GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): canonicalize usage transcript sources · pingdotgg/t3code@6f17728

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/usage
    • UsageService.test.ts
    • UsageService.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/usage/UsageService.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/usage/UsageService.test.ts
+51-1Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import * as NodePath from "node:path";
77
import { assert, describe, it } from "@effect/vitest";
88
import * as NodeServices from "@effect/platform-node/NodeServices";
99
import { HostProcessEnvironment } from "@t3tools/shared/hostProcess";
10-
import { UsageDay, type UsageSummaryInput } from "@t3tools/contracts";
10+
import {
11+
EnvironmentId,
12+
USAGE_CONTRACT_VERSION,
13+
UsageDay,
14+
type UsageSummaryInput,
15+
} from "@t3tools/contracts";
16+
import { mergeUsage } from "@t3tools/shared/usageMerge";
1117
import * as Duration from "effect/Duration";
1218
import * as Deferred from "effect/Deferred";
1319
import * as Effect from "effect/Effect";
@@ -98,6 +104,50 @@ function totalOutputTokens(summary: { buckets: readonly { totals: { outputTokens
98104
}
99105

100106
describe("UsageService", () => {
107+
it.live("counts a transcript home once when another environment uses a directory alias", () =>
108+
Effect.gen(function* () {
109+
const { transcript, settings, home } = yield* setup;
110+
yield* Effect.promise(() => NodeFSP.writeFile(transcript, claudeLine(1, 5)));
111+
const alias = NodePath.join(home, "claude-alias");
112+
yield* Effect.promise(() =>
113+
NodeFSP.symlink(settings.providers.claudeAgent.homePath, alias, "junction"),
114+
);
115+
116+
const direct = yield* UsageService.make.pipe(
117+
Effect.provide(serviceLayers({ prefix: "usage-direct-home", home, settings })),
118+
);
119+
const linked = yield* UsageService.make.pipe(
120+
Effect.provide(
121+
serviceLayers({
122+
prefix: "usage-linked-home",
123+
home,
124+
settings: {
125+
providers: { ...settings.providers, claudeAgent: { homePath: alias } },
126+
},
127+
}),
128+
),
129+
);
130+
const directSummary = yield* direct.readSummary(WINDOW);
131+
const linkedSummary = yield* linked.readSummary(WINDOW);
132+
const merged = mergeUsage(
133+
[
134+
{ environmentId: EnvironmentId.make("direct"), label: "Direct", summary: directSummary },
135+
{ environmentId: EnvironmentId.make("linked"), label: "Linked", summary: linkedSummary },
136+
],
137+
USAGE_CONTRACT_VERSION,
138+
);
139+
140+
assert.strictEqual(merged.outputTokens, 5);
141+
assert.strictEqual(merged.sessions, 1);
142+
assert.deepStrictEqual(
143+
directSummary.sources.find((source) => source.fingerprint.provider === "claude")
144+
?.fingerprint,
145+
linkedSummary.sources.find((source) => source.fingerprint.provider === "claude")
146+
?.fingerprint,
147+
);
148+
}).pipe(Effect.scoped),
149+
);
150+
101151
it.live("reprices unchanged transcripts when custom prices are added, edited, or removed", () =>
102152
Effect.gen(function* () {
103153
const { transcript, settings, home } = yield* setup;
Collapse file

‎apps/server/src/usage/UsageService.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/usage/UsageService.ts
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,10 @@ export const make = Effect.gen(function* () {
388388
Effect.provideService(Path.Path, path),
389389
);
390390
const scanned: ScannedDir[] = [];
391-
for (const { provider, dir, fileName } of dirs) {
391+
for (const { provider, dir: configuredDir, fileName } of dirs) {
392+
const dir = yield* fileSystem
393+
.realPath(configuredDir)
394+
.pipe(Effect.orElseSucceed(() => configuredDir));
392395
const volumeId = yield* Effect.promise(() => readDirectoryVolumeId(dir));
393396
const exists = yield* fileSystem
394397
.exists(dir)

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.