@@ -212,7 +212,10 @@ describe("UsageService", () => {
212212 summary . sources . find ( ( source ) => source . fingerprint . provider === "cursor" ) ?. status ,
213213 "missing" ,
214214 ) ;
215- assert . strictEqual ( summary . buckets [ 0 ] ?. sourcePath , root ) ;
215+ assert . strictEqual (
216+ summary . buckets [ 0 ] ?. sourcePath ,
217+ yield * Effect . promise ( ( ) => NodeFSP . realpath ( root ) ) ,
218+ ) ;
216219 assert . strictEqual ( summary . buckets [ 0 ] ?. totals . outputTokens , 7 ) ;
217220 assert . strictEqual (
218221 summary . sources . find ( ( source ) => source . fingerprint . provider === "opencode" )
@@ -226,6 +229,60 @@ describe("UsageService", () => {
226229 } ) . pipe ( Effect . scoped ) ,
227230 ) ;
228231
232+ it . live ( "counts aliased OpenCode and Antigravity directories once" , ( ) =>
233+ Effect . gen ( function * ( ) {
234+ const { settings, home } = yield * setup ;
235+ const opencode = NodePath . join ( home , "opencode-store" ) ;
236+ const opencodeAlias = NodePath . join ( home , "opencode-alias" ) ;
237+ const conversations = NodePath . join ( home , "antigravity-conversations" ) ;
238+ const antigravityA = NodePath . join ( home , "antigravity-a" ) ;
239+ const antigravityB = NodePath . join ( home , "antigravity-b" ) ;
240+ yield * Effect . promise ( async ( ) => {
241+ await NodeFSP . mkdir ( opencode ) ;
242+ await NodeFSP . symlink ( opencode , opencodeAlias , "junction" ) ;
243+ await NodeFSP . mkdir ( conversations ) ;
244+ await NodeFSP . mkdir ( antigravityA ) ;
245+ await NodeFSP . mkdir ( antigravityB ) ;
246+ await NodeFSP . symlink (
247+ conversations ,
248+ NodePath . join ( antigravityA , "conversations" ) ,
249+ "junction" ,
250+ ) ;
251+ await NodeFSP . symlink (
252+ conversations ,
253+ NodePath . join ( antigravityB , "conversations" ) ,
254+ "junction" ,
255+ ) ;
256+ } ) ;
257+ const service = yield * UsageService . make . pipe (
258+ Effect . provide (
259+ serviceLayers ( {
260+ prefix : "usage-service-aliased-roots-test" ,
261+ home,
262+ settings,
263+ environment : {
264+ OPENCODE_DATA_DIR : `${ opencode } ,${ opencodeAlias } ` ,
265+ ANTIGRAVITY_DATA_DIR : `${ antigravityA } ,${ antigravityB } ` ,
266+ } ,
267+ } ) ,
268+ ) ,
269+ ) ;
270+ const summary = yield * service . readSummary ( WINDOW ) ;
271+ const sourcesFor = ( provider : "opencode" | "antigravity" ) =>
272+ summary . sources . filter ( ( source ) => source . fingerprint . provider === provider ) ;
273+ assert . strictEqual ( sourcesFor ( "opencode" ) . length , 1 ) ;
274+ assert . strictEqual ( sourcesFor ( "antigravity" ) . length , 1 ) ;
275+ assert . strictEqual (
276+ sourcesFor ( "opencode" ) [ 0 ] ?. fingerprint . resolvedHomePath ,
277+ yield * Effect . promise ( ( ) => NodeFSP . realpath ( opencode ) ) ,
278+ ) ;
279+ assert . strictEqual (
280+ sourcesFor ( "antigravity" ) [ 0 ] ?. fingerprint . resolvedHomePath ,
281+ yield * Effect . promise ( ( ) => NodeFSP . realpath ( conversations ) ) ,
282+ ) ;
283+ } ) . pipe ( Effect . scoped ) ,
284+ ) ;
285+
229286 it . live ( "reads configured and disabled accounts once across shared and aliased homes" , ( ) =>
230287 Effect . gen ( function * ( ) {
231288 const { transcript, settings, home } = yield * setup ;
0 commit comments