Skip to content

Commit 5060159

Browse files
authored
Fix home space schema application for favorites (commontoolsinc#2178)
* Fix home space schema application for favorites * Fix type error * Fix lint
1 parent 8a45283 commit 5060159

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

packages/charm/src/manager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ export class CharmManager {
157157
);
158158
// Use the space DID as the cause - it's derived from the space name
159159
// and consistently available everywhere
160-
this.spaceCell = this.runtime.getSpaceCell(this.space);
160+
// For home space (where space DID = user identity DID), getHomeSpaceCell()
161+
// uses homeSpaceCellSchema which includes favorites for proper sync/query behavior.
162+
const isHomeSpace = this.space === this.runtime.userIdentityDID;
163+
this.spaceCell = isHomeSpace
164+
? this.runtime.getHomeSpaceCell()
165+
: this.runtime.getSpaceCell(this.space);
161166

162167
const syncSpaceCell = Promise.resolve(this.spaceCell.sync());
163168

packages/runner/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { Runtime, spaceCellSchema } from "./runtime.ts";
1+
export { homeSpaceCellSchema, Runtime, spaceCellSchema } from "./runtime.ts";
22
export type {
33
CharmMetadata,
44
ConsoleHandler,

packages/runner/src/runtime.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export interface SpaceCellContents {
9595
* Home space contains user-specific data like favorites that persists across all spaces.
9696
* See docs/common/HOME_SPACE.md for more details.
9797
*/
98-
export interface HomeSpaceCellContents {
98+
export interface HomeSpaceCellContents extends SpaceCellContents {
9999
favorites: Cell<{ cell: Cell<unknown>; tag: string }[]>;
100100
}
101101

@@ -128,6 +128,17 @@ export const spaceCellSchema: JSONSchema = {
128128
export const homeSpaceCellSchema: JSONSchema = {
129129
type: "object",
130130
properties: {
131+
// Include all space cell properties
132+
allCharms: {
133+
type: "array",
134+
items: { not: true, asCell: true },
135+
},
136+
recentCharms: {
137+
type: "array",
138+
items: { not: true, asCell: true },
139+
},
140+
defaultPattern: { not: true, asCell: true },
141+
// Plus home-space-specific properties
131142
favorites: {
132143
type: "array",
133144
items: {

0 commit comments

Comments
 (0)