-
Notifications
You must be signed in to change notification settings - Fork 9
charm-cleanup-again #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
charm-cleanup-again #608
Changes from all commits
3211bc2
7202f0e
39a58a5
063ced5
e43e700
bb10817
a4492cd
3d91af3
a497c44
a7fdf1c
2025d72
64f7b6b
2efbadb
f4db551
6549a51
e6445cf
57e5f53
164e91c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,14 +161,17 @@ export class CharmManager { | |
| return this.pinnedCharms; | ||
| } | ||
|
|
||
| // FIXME(ja): this says it returns a list of charm, but it isn't! you will | ||
| // have to call .get() to get the actual charm (this is missing the schema) | ||
| // how can we fix the type here? | ||
| getCharms(): Cell<Cell<Charm>[]> { | ||
| // Start syncing if not already syncing. Will trigger a change to the list | ||
| // once loaded. | ||
| storage.syncCell(this.charmsDoc); | ||
| return this.charms; | ||
| } | ||
|
|
||
| async add(newCharms: Cell<Charm>[]) { | ||
| private async add(newCharms: Cell<Charm>[]) { | ||
| await storage.syncCell(this.charmsDoc); | ||
| await idle(); | ||
|
|
||
|
|
@@ -181,6 +184,8 @@ export class CharmManager { | |
| await idle(); | ||
| } | ||
|
|
||
| // FIXME(ja): if we are already running the charm, can we just return it? | ||
| // if a charm has sideeffects we might multiple versions... | ||
| async get<T = Charm>( | ||
| id: string | Cell<Charm>, | ||
| runIt: boolean = true, | ||
|
|
@@ -291,46 +296,6 @@ export class CharmManager { | |
| ): Promise<Cell<Charm>> { | ||
| await idle(); | ||
|
|
||
| // Fill in missing parameters from other charms. It's a simple match on | ||
| // hashtags: For each top-level argument prop that has a hashtag in the | ||
| // description, look for a charm that has a top-level output prop with the | ||
| // same hashtag in the description, or has the hashtag in its own description. | ||
| // If there is a match, assign the first one to the input property. | ||
|
|
||
| // TODO(seefeld,ben): This should be in spellcaster. | ||
| /* | ||
| if ( | ||
| !isDoc(inputs) && // Adding to a cell input is not supported yet | ||
| !isDocLink(inputs) && // Neither for cell reference | ||
| recipe.argumentSchema && | ||
| (recipe.argumentSchema as any).type === "object" | ||
| ) { | ||
| const properties = (recipe.argumentSchema as any).properties; | ||
| const inputProperties = | ||
| typeof inputs === "object" && inputs !== null ? Object.keys(inputs) : []; | ||
| for (const key in properties) { | ||
| if (!(key in inputProperties) && properties[key].description?.includes("#")) { | ||
| const hashtag = properties[key].description.match(/#(\w+)/)?.[1]; | ||
| if (hashtag) { | ||
| this.charms.get().forEach((charm) => { | ||
| const type = charm.getAsDocLink().cell?.sourceCell?.get()?.[TYPE]; | ||
| const recipe = getRecipe(type); | ||
| const charmProperties = (recipe?.resultSchema as any)?.properties as any; | ||
| const matchingProperty = Object.keys(charmProperties ?? {}).find((property) => | ||
| charmProperties[property].description?.includes(`#${hashtag}`), | ||
| ); | ||
| if (matchingProperty) { | ||
| inputs = { | ||
| ...inputs, | ||
| [key]: { $alias: { cell: charm.getAsDocLink().cell, path: [matchingProperty] } }, | ||
| }; | ||
| } | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| }*/ | ||
|
|
||
| const syncAllMentionedCells = ( | ||
| value: any, | ||
| promises: any[] = [], | ||
|
|
@@ -360,7 +325,7 @@ export class CharmManager { | |
| } | ||
|
|
||
| // FIXME(JA): this really really really needs to be revisited | ||
| async syncRecipe(charm: Cell<Charm>): Promise<string | undefined> { | ||
| async syncRecipe(charm: Cell<Charm>): Promise<string> { | ||
| const recipeId = charm.getSourceCell()?.get()?.[TYPE]; | ||
| if (!recipeId) throw new Error("charm missing recipe ID"); | ||
|
|
||
|
|
@@ -372,7 +337,7 @@ export class CharmManager { | |
| } | ||
|
|
||
| async syncRecipeCells(recipeId: string) { | ||
| // NOTE(ja): I don't think this actually syncs the recipe | ||
| // NOTE(ja): this doesn't sync recipe to storage | ||
| if (recipeId) await storage.syncCellById(this.space, { "/": recipeId }); | ||
|
Comment on lines
+340
to
341
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does it do...? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it just creates a cell ... with nothing in it |
||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,8 +58,8 @@ async function main() { | |
| ); | ||
|
|
||
| // let's add the cell to the charmManager | ||
| await charmManager.add([cell]); | ||
| log(charmManager, "charmmanager after adding cell"); | ||
| // await charmManager.add([cell]); | ||
| // log(charmManager, "charmmanager after adding cell"); | ||
|
Comment on lines
-61
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is half-way written code by @ellyxir - I asked her if I can just comment out - she said yep |
||
| } | ||
|
|
||
| main(); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you say more about the future improvements we need here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should clarify what recipes go where - since right now we are throwing everything at blobby. should we rely on blobby for anything more than "spellbook/sharing"
how does that impact spellcasting? maybe everything should go?
would love to whiteboard about this