feat(chat): fix spacing around messages #159

Merged
hodlbod merged 1 commits from theAnuragMishra/flotilla:158-message-blocks into dev 2026-04-07 16:50:54 +00:00
Contributor

This pr makes the following changes to implement a better structure for chat messages.

Add components/RoomMessageBlock.svelte to render a block header (profile picture, display name, timestamp) and
group consecutive messages from the same user.
Refactor src/app/components/RoomItem.svelte to support grouped-mode (isGrouped) and remove per-message header/spacing, keep
reactions/actions intact.
Update message feed processing in:
src/routes/spaces/[relay]/[h]/+page.svelte
src/routes/spaces/[relay]/chat/+page.svelte
to emit message-block items (respecting the existing 3-minute gap rule) and render blocks via RoomMessageBlock.

Before and After screenshots attached in that order.

image.png
image.png

This pr makes the following changes to implement a better structure for chat messages. Add components/RoomMessageBlock.svelte to render a block header (profile picture, display name, timestamp) and group consecutive messages from the same user. Refactor src/app/components/RoomItem.svelte to support grouped-mode (isGrouped) and remove per-message header/spacing, keep reactions/actions intact. Update message feed processing in: src/routes/spaces/[relay]/[h]/+page.svelte src/routes/spaces/[relay]/chat/+page.svelte to emit message-block items (respecting the existing 3-minute gap rule) and render blocks via RoomMessageBlock. Before and After screenshots attached in that order. ![image.png](/attachments/70e8aaf2-7da2-4d66-9b9e-cdf11d892f6b) ![image.png](/attachments/6f21b784-19df-4b11-a398-abab9a8d4136)
114 KiB
132 KiB
Author
Contributor

fixes #158

fixes #158
Owner

This PR is sort of a mess:

  • RoomItem is never used without isGrouped, so the else is dead code and the flag is redundant
  • Message hover behavior is per group, with nested hover per message which doesn't reach all the way to the left
  • There is a bunch of unnecessary snapshotting and as any stuff

The problem you've identified is relevant, and the solution is sound, could you do another pass and tidy things up?

This PR is sort of a mess: - RoomItem is never used without isGrouped, so the else is dead code and the flag is redundant - Message hover behavior is per group, with nested hover per message which doesn't reach all the way to the left - There is a bunch of unnecessary snapshotting and `as any` stuff The problem you've identified is relevant, and the solution is sound, could you do another pass and tidy things up?
Author
Contributor

I gave everythign a thorough look again and cleared most of the mess. Everything looks perfect but there's one problem still remaining. On the first message of the block, you would expect the action buttons to appear on hovering anywhere including the profile picture, name or pubkey, or the message content.
But since this redesign separates messages from pfp and pubkey, it currently only shows these buttons when hovering the message content.

Now I'm split and rethinking whether I should have just fixed the paddings/margins without redesigning the whole layout.

I gave everythign a thorough look again and cleared most of the mess. Everything looks perfect but there's one problem still remaining. On the first message of the block, you would expect the action buttons to appear on hovering anywhere including the profile picture, name or pubkey, or the message content. But since this redesign separates messages from pfp and pubkey, it currently only shows these buttons when hovering the message content. Now I'm split and rethinking whether I should have just fixed the paddings/margins without redesigning the whole layout.
hodlbod requested changes 2026-04-06 22:32:52 +00:00
hodlbod left a comment
Owner

Yeah, I like the refactor, but the UI is slightly worse. There's the issue you pointed out, but the context menu is in a different spot and interrupts hovering on adjacent messages. So I think it's probably best to just fix the original bug.

Yeah, I like the refactor, but the UI is slightly worse. There's the issue you pointed out, but the context menu is in a different spot and interrupts hovering on adjacent messages. So I think it's probably best to just fix the original bug.
@@ -0,0 +28,4 @@
const openProfile = () => pushModal(ProfileDetail, {pubkey: firstEvent.pubkey, url})
</script>
<div class="relative flex w-full flex-col p-2 pb-3 text-left gap-3">
Owner

We should remove this gap-3, it leaves dead space between messages and reduces information density

We should remove this gap-3, it leaves dead space between messages and reduces information density
theAnuragMishra marked this conversation as resolved
@@ -253,0 +261,4 @@
elements.push({
type: "message-block",
id: currentBlock[0].id,
events: [...currentBlock],
Owner

currentBlock.splice(0) would be a tad better, the next line's reassignment wouldn't be necessary.

`currentBlock.splice(0)` would be a tad better, the next line's reassignment wouldn't be necessary.
theAnuragMishra marked this conversation as resolved
Author
Contributor

Yes.. grouping into blocks was very appealing at first but after workign on the refactor for quite some time, I have come to a conclusion that leaving roomitems as individual entities is more suitable than creating blocks.

I will start from scratch and only adjust spacings and layouts keeping the same dom flow as is currently in the dev branch.

Yes.. grouping into blocks was very appealing at first but after workign on the refactor for quite some time, I have come to a conclusion that leaving roomitems as individual entities is more suitable than creating blocks. I will start from scratch and only adjust spacings and layouts keeping the same dom flow as is currently in the dev branch.
theAnuragMishra changed title from feat(chat): group consecutive messages into message blocks for more consistent dom flow and fixing weird spacing to feat(chat): fix spacing around messages 2026-04-07 09:43:54 +00:00
Author
Contributor

I have updated the pr with a simpler fix of the layout.
The current look of the UI is attached

I have updated the pr with a simpler fix of the layout. The current look of the UI is attached
hodlbod added 1 commit 2026-04-07 16:50:41 +00:00
hodlbod force-pushed 158-message-blocks from 76f20fffce to 5db66cc25d 2026-04-07 16:50:41 +00:00 Compare
hodlbod merged commit 7470f28f31 into dev 2026-04-07 16:50:54 +00:00
hodlbod deleted branch 158-message-blocks 2026-04-07 16:50:54 +00:00
Sign in to join this conversation.