Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/events/src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function Index() {
<div className="flex flex-row gap-2 justify-between items-center">
<Input value={spaceName} onChange={(e) => setSpaceName(e.target.value)} />
<Button
disabled={true} // disabled until we have delegation for creating a space
onClick={async (event) => {
event.preventDefault();
// const smartAccountWalletClient = await getSmartAccountWalletClient();
Expand All @@ -96,7 +97,7 @@ function Index() {
<Link to="/space/$spaceId" params={{ spaceId: space.id }}>
<Card>
<CardHeader>
<CardTitle>{space.id}</CardTitle>
<CardTitle>{space.name}</CardTitle>
</CardHeader>
</Card>
</Link>
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/handlers/getSpace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const getSpace = async ({ spaceId, accountAddress }: Params) => {

return {
id: space.id,
name: space.name,
events: space.events.map((wrapper) => JSON.parse(wrapper.event)),
keyBoxes,
inboxes: space.inboxes.map((inbox) => ({
Expand Down
2 changes: 2 additions & 0 deletions packages/hypergraph-react/src/HypergraphAppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ export function HypergraphAppProvider({
store.send({
type: 'setSpaceFromList',
spaceId: space.id,
name: space.name,
});
});
break;
Expand Down Expand Up @@ -425,6 +426,7 @@ export function HypergraphAppProvider({

store.send({
type: 'setSpace',
name: response.name,
spaceId: response.id,
updates: response.updates as Messages.Updates,
events: response.events as Array<SpaceEvents.SpaceEvent>,
Expand Down
2 changes: 2 additions & 0 deletions packages/hypergraph/src/messages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ export const ResponseListSpaces = Schema.Struct({
spaces: Schema.Array(
Schema.Struct({
id: Schema.String,
name: Schema.String,
}),
),
});
Expand Down Expand Up @@ -347,6 +348,7 @@ export type ResponseAccountInbox = Schema.Schema.Type<typeof ResponseAccountInbo
export const ResponseSpace = Schema.Struct({
type: Schema.Literal('space'),
id: Schema.String,
name: Schema.String,
events: Schema.Array(SpaceEvent),
keyBoxes: Schema.Array(KeyBoxWithKeyId),
updates: Schema.optional(Updates),
Expand Down
1 change: 1 addition & 0 deletions packages/hypergraph/src/store-connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ type StoreEvent =
| {
type: 'setSpace';
spaceId: string;
name: string;
updates?: Updates;
events: SpaceEvent[];
inboxes?: SpaceInboxStorageEntry[];
Expand Down
10 changes: 8 additions & 2 deletions packages/hypergraph/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type AccountInboxStorageEntry = {

export type SpaceStorageEntry = {
id: string;
name: string;
events: SpaceEvent[];
state: SpaceState | undefined;
keys: { id: string; key: string }[];
Expand Down Expand Up @@ -85,7 +86,7 @@ type StoreEvent =
| { type: 'reset' }
| { type: 'addUpdateInFlight'; updateId: string }
| { type: 'removeUpdateInFlight'; updateId: string }
| { type: 'setSpaceFromList'; spaceId: string }
| { type: 'setSpaceFromList'; spaceId: string; name: string }
| { type: 'applyEvent'; spaceId: string; event: SpaceEvent; state: SpaceState }
| { type: 'updateConfirmed'; spaceId: string; clock: number }
| { type: 'applyUpdate'; spaceId: string; firstUpdateClock: number; lastUpdateClock: number }
Expand Down Expand Up @@ -122,6 +123,7 @@ type StoreEvent =
| {
type: 'setSpace';
spaceId: string;
name: string;
updates?: Updates;
events: SpaceEvent[];
inboxes?: SpaceInboxStorageEntry[];
Expand Down Expand Up @@ -170,7 +172,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create
updatesInFlight: context.updatesInFlight.filter((id) => id !== event.updateId),
};
},
setSpaceFromList: (context, event: { spaceId: string }) => {
setSpaceFromList: (context, event: { spaceId: string; name: string }) => {
if (!context.repo) {
return context;
}
Expand All @@ -188,6 +190,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create
if (existingSpace.id === event.spaceId) {
const newSpace: SpaceStorageEntry = {
id: existingSpace.id,
name: existingSpace.name,
Copy link

Copilot AI Jun 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the existing space update logic, the event carries a new name but the code reuses the existing space name. Consider using event.name to update the space name consistently.

Suggested change
name: existingSpace.name,
name: event.name,

Copilot uses AI. Check for mistakes.

events: existingSpace.events ?? [],
state: existingSpace.state,
keys: existingSpace.keys ?? [],
Expand All @@ -210,6 +213,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create
...context.spaces,
{
id: event.spaceId,
name: event.name,
events: [],
state: undefined,
keys: [],
Expand Down Expand Up @@ -398,6 +402,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create
context,
event: {
spaceId: string;
name: string;
updates?: Updates;
inboxes?: SpaceInboxStorageEntry[];
events: SpaceEvent[];
Expand All @@ -415,6 +420,7 @@ export const store: Store<StoreContext, StoreEvent, GenericEventObject> = create
result.handle.doneLoading();

const newSpace: SpaceStorageEntry = {
name: event.name,
id: event.spaceId,
events: event.events,
state: event.spaceState,
Expand Down
Loading