Skip to content

Commit e2beb8a

Browse files
committed
Profile_browser removes its singular import of a type in the app package.
Now, packets should be stringified. Part of #64.
1 parent b81a224 commit e2beb8a

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

app/profile_browser.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ import {
2727
EMBEDDINGS_BY_MODEL
2828
} from '../src/llm.js';
2929

30-
import {
31-
Packets
32-
} from './types.js';
33-
3430
const STORE_KEY_PREFIX = 'store_';
3531
const MEMORY_KEY_PREFIX = 'memory_';
3632

@@ -76,15 +72,15 @@ type AssociativeMemory = z.infer<typeof associativeMemory>;
7672
//This profile knows how to load local packets from state.
7773
export class ProfileBrowser extends Profile {
7874

79-
_packets : Packets;
75+
_packets : Record<string,string>;
8076

8177
//Profile has base _stores and _memories of different types
8278
_associativeMemories : {[name : MemoryID]: AssociativeMemory};
8379
_storeApps : {[name : StoreID] : StoreBrowser};
8480

85-
constructor(packets : Packets) {
81+
constructor(stringifiedPackets : Record<string, string>) {
8682
super();
87-
this._packets = packets;
83+
this._packets = stringifiedPackets;
8884
//We lazy load this since the garden might be loaded and torn down
8985
//multiple times in quick succession, so loading and parsing each store
9086
//at boot would be prohibitively expensive for large profiles.
@@ -221,8 +217,6 @@ export class ProfileBrowser extends Profile {
221217
override async localFetch(location: SeedPacketAbsoluteLocalLocation): Promise<string> {
222218
//TODO: also stash local-but-actually-remotes here so they don't have to
223219
//be refetched if we already have them.
224-
const packet = this._packets[location];
225-
if (!packet) return '';
226-
return JSON.stringify(packet, null, '\t');
220+
return this._packets[location] || '';
227221
}
228222
}

app/selectors.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ export const selectCurrentSeed = createSelector(
7979

8080
export const selectProfile = createSelector(
8181
selectPackets,
82-
(packets) => new ProfileBrowser(packets)
82+
(packets) => {
83+
const stringifiedPackets = Object.fromEntries(Object.entries(packets).map(entry => [entry[0], JSON.stringify(entry[1], null, '\t')]));
84+
return new ProfileBrowser(stringifiedPackets);
85+
}
8386
);
8487

8588
export const selectGarden = createSelector(

0 commit comments

Comments
 (0)