Skip to content

NO MERGE - Curb JS - Frontend#63

Closed
frdomovic wants to merge 33 commits intomasterfrom
feat-js-curb-ui-logic
Closed

NO MERGE - Curb JS - Frontend#63
frdomovic wants to merge 33 commits intomasterfrom
feat-js-curb-ui-logic

Conversation

@frdomovic
Copy link
Copy Markdown
Member

@frdomovic frdomovic commented Nov 13, 2025

Curb JS - Frontend

Description

Contains frontend for Curb JS -> simplified and changes some components, logic, hooks, handlers


Note

Modernizes the app to the new Calimero client/backend contract and expands channel management.

  • Upgrade @calimero-network/calimero-client to 1.24.1 and realign ClientMethod names, payloads, and types (lowercase ChannelType, new DTOs, normalized DM structures)
  • Overhaul clientApi/data sources: new channel directory (getChannels, getChannelDirectory), moderator ops (promoteModerator, demoteModerator, removeUserFromChannel), deleteChannel, revamped messages (args/result mapping, reactions/attachments normalization), and getNonMemberUsers returning username maps
  • UI refactor to consume new shapes: pass channelMeta through navbar/containers, show members/moderators, add member invites with autocomplete, role actions (promote/demote/remove), and optional channel delete; improved message edit/mentions and thread pagination; safer create-channel error handling
  • Hooks rewritten: useChannels maps members/moderators/unread to ChannelMeta; useChannelMembers returns records and fetches invitees; search page uses new directory and join/leave flows
  • Misc: WebSocket status uses real events; message store merges reaction updates; minor layout/styling tweaks; remove unused node createContext; update .gitignore

Written by Cursor Bugbot for commit 96eb95e. This will update automatically on new commits. Configure here.

@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
calimero-curb-chat Ready Ready Preview, Comment Jan 15, 2026 3:33pm
calimero-curb-rs Ready Ready Preview, Comment Jan 15, 2026 3:33pm

Comment thread app/src/api/clientApi.ts
CREATE_CHANNEL = "createChannel",
GET_CHANNELS = "getChannels",
GET_ALL_CHANNELS_SEARCH = "getChannelDirectory",
GET_CHANNEL_MEMBERS = "abc",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Placeholder "abc" used for API method name

The GET_CHANNEL_MEMBERS enum value is set to "abc". This placeholder isn't a valid API method name, so calls to getChannelMembers will fail because the backend won't recognize it.

Fix in Cursor Fix in Web

userId: typeof username === 'string' ? username : userId,
username: typeof username === 'string' ? username : userId,
}))
: activeChannelMembers || [];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Wrong userId assigned in DM mentions extraction

In handleEditedMessage, when preparing membersForMentions for DMs, the userId field is incorrectly populated with the username instead of the actual user ID. This happens because the map's key (user ID) is overwritten by its value (username) during array transformation, causing extractAndAddMentions to return usernames in place of user IDs for edited DM message mentions.

Fix in Cursor Fix in Web

const usernames = userEntries.map(([_, user]) => {
// @ts-expect-error - value is not typed
return (user.username as string).toLowerCase();
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Accessing .username on string values causes TypeError

The chatMembers and membersList props are Map<string, string>, but functions like isValidIdentityId in DMHeader and extractAndAddMentions in ChatContainer's sendMessage expect map values to be objects with a username property. This causes a TypeError in DMHeader and silently prevents mention extraction in sendMessage.

Additional Locations (1)

Fix in Cursor Fix in Web

);
const isDM = activeChatRef.current?.type === "direct_message";

// @ts-expect-error - membersListRef.current is a Map
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Map passed to function expecting array of objects

The extractAndAddMentions function is called with membersListRef.current which is a Map<string, string>, but the function expects an array of objects with userId and username properties. Iterating over a Map yields [key, value] tuples, not objects with named properties. When the function accesses user.username and user.userId, these will be undefined, causing mentions extraction to silently fail and return empty arrays.

Fix in Cursor Fix in Web

Comment thread app/src/hooks/useChannels.ts
async getChannels(): ApiResponse<ChannelDataResponse[]> {
try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const response = await getJsonRpcClient().execute<any, Channels>(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

createChannel ignores visibility, readOnly, and moderator settings

The createChannel implementation only sends name to the backend via argsJson, but the caller in ChannelHeader.tsx passes channel_type (public/private visibility), readOnly, moderators, links_allowed, and created_at. All these configuration options are silently ignored, meaning newly created channels will not have the intended visibility settings, read-only mode, or moderator assignments.

Additional Locations (1)

Fix in Cursor Fix in Web

Comment thread app/src/api/clientApi.ts
GROUP = "Default",
PUBLIC = "public",
PRIVATE = "private",
GROUP = "default",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ChannelType enum change breaks private channel detection

The ChannelType enum values were changed from PascalCase ("Private") to lowercase ("private"), but existing code in DetailsDropdown.tsx and DetailsContainer.tsx still compares against the old PascalCase value "Private". This means private channels will not be detected correctly, causing the wrong icon (public hashtag instead of lock) to display for private channels throughout the UI.

Additional Locations (2)

Fix in Cursor Fix in Web


// Transform messages from backend format to frontend format
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const transformedMessages = getMessagesObject.messages.map((msg: any) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing array check before mapping messages causes crash

Medium Severity

The code calls getMessagesObject.messages.map(...) without verifying that messages is an array. While getMessagesObject is null-checked, if the API returns an object without a messages property (e.g., { total_count: 0, start_position: 0 }), calling .map() on undefined will throw a TypeError and crash the application.

Fix in Cursor Fix in Web

// } else if (response.error) {
// setError(response.error.message || "Failed to fetch channel members");
// }
setChannelUsers({});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

fetchChannelMembers is disabled and returns empty object

High Severity

The fetchChannelMembers function has its API call commented out and unconditionally sets channelUsers to an empty object {}. This breaks any functionality that depends on fetching channel members, including member lists and user lookups. The function accepts a _channelId parameter (prefixed with underscore indicating it's unused) but does nothing with it.

Fix in Cursor Fix in Web

if (!membersMap.has(moderator.publicKey)) {
upsertMember(moderator, true);
}
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing null checks on channel arrays causes crash

Medium Severity

The code calls channel.moderators.map(...) and channel.members.forEach(...) without checking if these properties are valid arrays. If the API returns a channel object with null or undefined for members or moderators, the code will crash with a TypeError when attempting to call array methods on non-array values.

Fix in Cursor Fix in Web

@frdomovic
Copy link
Copy Markdown
Member Author

Outdated, needs to be redone.

@frdomovic frdomovic closed this Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants