Skip to content

feat(web): show comment button on homepage when no cofeat(web): show comment button on homepage when no comments existmments exist#5844

Open
jin225298 wants to merge 2 commits intousememos:mainfrom
jin225298:feat/show-comment-button-on-homepage
Open

feat(web): show comment button on homepage when no cofeat(web): show comment button on homepage when no comments existmments exist#5844
jin225298 wants to merge 2 commits intousememos:mainfrom
jin225298:feat/show-comment-button-on-homepage

Conversation

@jin225298
Copy link
Copy Markdown

@jin225298 jin225298 commented Apr 16, 2026

Related Issue

Closes #5838 (partial - addresses the comment button visibility)

What this PR does

This PR adds a "Write a comment" button on memo cards in the homepage, even when there are no existing comments.

Why

As described in #5838, if a memo has no existing comments, the comment button is not shown. Users had to navigate to the memo detail page to write a comment. This PR fixes that by:

  • Showing the comment section on memo cards for logged-in users
  • Adding an inline "Write a comment" button that opens an editor directly on the homepage

Changes

  • MemoView.tsx: Show comment preview section for logged-in users (not just when comments exist)
  • MemoCommentListView.tsx: Added inline comment editor and "Write a comment" button

Screenshot

image image image

Testing

  • Tested locally with Docker build
  • Comment button appears on homepage when no comments exist
  • Inline comment editor works correctly

Summary by CodeRabbit

  • New Features

    • Inline comment editor with a "write a comment" trigger for quicker replies.
  • Bug Fixes

    • Comment preview now respects user sign-in state (shows only for signed-in users).
  • Improvements

    • Comment list UI: clearer header with icon, conditional counts and "View all" link.
    • Added "View all" localization across many languages.

- Add 'Write a comment' button on memo cards in homepage
- Allow users to comment directly without entering detail page
- Improve user experience for memo interaction
@jin225298 jin225298 requested a review from a team as a code owner April 16, 2026 08:28
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

📝 Walkthrough

Walkthrough

Comment preview gating moved from relying on comment count to user authentication; comment list now allows showing an inline editor and a ghost "write a comment" trigger even when there are no comments. Multiple locale files add a memo.comment.view-all key.

Changes

Cohort / File(s) Summary
Comment Preview Gating
web/src/components/MemoView/MemoView.tsx
Replaced computeCommentAmount(memoData) > 0 in showCommentPreview with currentUser; removed computeCommentAmount usage and adjusted imports.
Comment Editor & Rendering
web/src/components/MemoView/components/MemoCommentListView.tsx
Uses useTranslate(); header shows MessageCircleIcon + translated text and conditional count; removed early return for zero comments (except on detail page); conditionally renders "View all" only when commentAmount > 0; adds local showEditor state to render MemoEditor or a ghost "write a comment" button when currentUser exists.
Locales (i18n additions)
web/src/locales/*.json (many files, e.g. en.json, fr.json, ja.json, zh-Hans.json, etc.)
Added memo.comment.view-all = "View all" across locale files and adjusted trailing commas where needed to add the new key.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • boojack

Poem

🐰
I hopped in code where comments sleep,
A tiny button woke from keep;
Now writers nibble, lines unfurl,
A quiet memo meets the world.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: showing a comment button on the homepage when no comments exist, which is the primary objective of this changeset.
Linked Issues check ✅ Passed The PR successfully implements the primary coding requirement from issue #5838: making the comment button visible on memo cards regardless of comment count, enabling inline commenting from the homepage.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue's first objective. The changes include: UI logic updates in MemoView and MemoCommentListView components, localization additions for the 'View all' button text across 27 locales.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/components/MemoView/components/MemoCommentListView.tsx`:
- Around line 47-55: The "View all" string in MemoCommentListView.tsx is
hardcoded; replace it with the translation function call (use the existing t
function used elsewhere in this component) so the Link renders t('memo.viewAll')
(or similar key) instead of the literal "View all", and add the new translation
key (e.g., "memo.viewAll") with appropriate translations into the locale files
to keep i18n consistent; update any imports if necessary to ensure t is
available in MemoCommentListView.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ddfd0e88-cec5-4d6b-82bb-ee288182c3c9

📥 Commits

Reviewing files that changed from the base of the PR and between f394e94 and c0cb65d.

📒 Files selected for processing (2)
  • web/src/components/MemoView/MemoView.tsx
  • web/src/components/MemoView/components/MemoCommentListView.tsx

Comment thread web/src/components/MemoView/components/MemoCommentListView.tsx
- Replace hardcoded "View all" with translation function
- Add memo.comment.view-all key to all locale files
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
web/src/components/MemoView/components/MemoCommentListView.tsx (1)

33-35: handleCommentCreated need not be async.

The handler performs only a synchronous setShowEditor(false); the async keyword and unused parameter add noise. Simplify to a plain function (and drop the parameter or keep it typed but sync).

♻️ Suggested change
-  const handleCommentCreated = async (_memoCommentName: string) => {
-    setShowEditor(false);
-  };
+  const handleCommentCreated = () => {
+    setShowEditor(false);
+  };

(If MemoEditor's onConfirm prop type requires the parameter, keep it but drop async.)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/components/MemoView/components/MemoCommentListView.tsx` around lines
33 - 35, Remove the unnecessary async and unused parameter from the comment
handler: change the async function handleCommentCreated(_memoCommentName:
string) to a plain synchronous function (either handleCommentCreated() or
handleCommentCreated(_memoCommentName: string) without async) and keep its body
setShowEditor(false); also ensure the signature still matches MemoEditor’s
onConfirm prop type if required (keep the parameter for typing only, but drop
async).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/components/MemoView/components/MemoCommentListView.tsx`:
- Around line 31-35: The showCreateButton logic currently hides the inline
"Write a comment" affordance when a memo already has comments; update the
condition to allow logged-in users to always see the create button by removing
the !hasComments check (i.e., make showCreateButton depend only on currentUser),
and mirror this same change where the same gating is applied later (the other
occurrence around the create-button rendering). Ensure you update references to
showCreateButton and any related conditional rendering so the comment composer
trigger appears below the previewed comments even when hasComments is true.

---

Nitpick comments:
In `@web/src/components/MemoView/components/MemoCommentListView.tsx`:
- Around line 33-35: Remove the unnecessary async and unused parameter from the
comment handler: change the async function
handleCommentCreated(_memoCommentName: string) to a plain synchronous function
(either handleCommentCreated() or handleCommentCreated(_memoCommentName: string)
without async) and keep its body setShowEditor(false); also ensure the signature
still matches MemoEditor’s onConfirm prop type if required (keep the parameter
for typing only, but drop async).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aeed0be0-e161-4d53-a6fa-46eef3d6ded5

📥 Commits

Reviewing files that changed from the base of the PR and between c0cb65d and 95e4fb0.

📒 Files selected for processing (34)
  • web/src/components/MemoView/components/MemoCommentListView.tsx
  • web/src/locales/ar.json
  • web/src/locales/ca.json
  • web/src/locales/cs.json
  • web/src/locales/de.json
  • web/src/locales/en-GB.json
  • web/src/locales/en.json
  • web/src/locales/es.json
  • web/src/locales/fa.json
  • web/src/locales/fr.json
  • web/src/locales/gl.json
  • web/src/locales/hi.json
  • web/src/locales/hr.json
  • web/src/locales/hu.json
  • web/src/locales/id.json
  • web/src/locales/it.json
  • web/src/locales/ja.json
  • web/src/locales/ka-GE.json
  • web/src/locales/ko.json
  • web/src/locales/mr.json
  • web/src/locales/nb.json
  • web/src/locales/nl.json
  • web/src/locales/pl.json
  • web/src/locales/pt-BR.json
  • web/src/locales/pt-PT.json
  • web/src/locales/ru.json
  • web/src/locales/sl.json
  • web/src/locales/sv.json
  • web/src/locales/th.json
  • web/src/locales/tr.json
  • web/src/locales/uk.json
  • web/src/locales/vi.json
  • web/src/locales/zh-Hans.json
  • web/src/locales/zh-Hant.json
✅ Files skipped from review due to trivial changes (33)
  • web/src/locales/th.json
  • web/src/locales/de.json
  • web/src/locales/gl.json
  • web/src/locales/uk.json
  • web/src/locales/mr.json
  • web/src/locales/pt-BR.json
  • web/src/locales/ca.json
  • web/src/locales/nb.json
  • web/src/locales/en.json
  • web/src/locales/ar.json
  • web/src/locales/pl.json
  • web/src/locales/hi.json
  • web/src/locales/hu.json
  • web/src/locales/cs.json
  • web/src/locales/zh-Hant.json
  • web/src/locales/ka-GE.json
  • web/src/locales/tr.json
  • web/src/locales/zh-Hans.json
  • web/src/locales/fr.json
  • web/src/locales/sv.json
  • web/src/locales/it.json
  • web/src/locales/es.json
  • web/src/locales/ko.json
  • web/src/locales/hr.json
  • web/src/locales/vi.json
  • web/src/locales/id.json
  • web/src/locales/fa.json
  • web/src/locales/pt-PT.json
  • web/src/locales/nl.json
  • web/src/locales/en-GB.json
  • web/src/locales/ja.json
  • web/src/locales/ru.json
  • web/src/locales/sl.json

Comment on lines +31 to +35
const showCreateButton = currentUser && !showEditor;

const handleCommentCreated = async (_memoCommentName: string) => {
setShowEditor(false);
};
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Apr 17, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Consider allowing inline comment creation even when comments already exist.

The showCreateButton is gated by !hasComments, so once a memo has any comments, logged-in users lose the homepage inline "Write a comment" affordance and must navigate to the detail page again — re-introducing the exact mobile/UX friction that issue #5838 calls out. The linked issue asks for the comment button to be visible on memo cards "regardless of whether a memo currently has comments." Consider dropping the !hasComments condition (the trigger would sit below the 3 preview comments), unless the screenshots in the PR description intentionally reflect a different design decision.

♻️ Suggested change
-      {showCreateButton && !hasComments && (
-        <Button variant="ghost" size="sm" className="w-full mt-1 text-muted-foreground" onClick={() => setShowEditor(true)}>
+      {showCreateButton && (
+        <Button variant="ghost" size="sm" className="w-full mt-1 text-muted-foreground" onClick={() => setShowEditor(true)}>
           <MessageCircleIcon className="w-4 h-4 mr-1" />
           {t("memo.comment.write-a-comment")}
         </Button>
       )}

Also applies to: 92-97

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/components/MemoView/components/MemoCommentListView.tsx` around lines
31 - 35, The showCreateButton logic currently hides the inline "Write a comment"
affordance when a memo already has comments; update the condition to allow
logged-in users to always see the create button by removing the !hasComments
check (i.e., make showCreateButton depend only on currentUser), and mirror this
same change where the same gating is applied later (the other occurrence around
the create-button rendering). Ensure you update references to showCreateButton
and any related conditional rendering so the comment composer trigger appears
below the previewed comments even when hasComments is true.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for the feedback. You raise a valid point.
However, I'd like to explain the current design rationale:

  1. UI Balance: When a memo already has comments, we display up to 3 preview comments in the card. Adding another "Write a comment" button below would make the card significantly taller and potentially cluttered, especially on mobile devices.
  2. Clear Call-to-Action: When there are no comments, the "Write a comment" button serves as a clear, prominent call-to-action to encourage engagement. When comments exist, the "View all" link provides a natural path to the detail page where users can see all comments and add their own.
  3. Progressive Enhancement: This PR addresses the primary pain point in Improvements to comments feature (button, sorting) #5838 - the inability to comment from homepage when there are NO comments at all. Users previously had no way to comment without first navigating to the detail page. The current implementation solves this issue.
    That said, I'm open to adjusting the design if the maintainers prefer the button to always be visible. I can remove the !hasComments condition if needed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The PR description images show three states of the feature:

  1. Image 1 (empty state): A memo card with a "Comments" section showing a centered "Write a comment" button — the main feature of this PR.
  2. Image 2 (editor open): The expanded inline comment editor with a text field ("Add your comment here..."), attachment (+), Private dropdown, Cancel, and Save controls.
  3. Image 3 (comments exist): The card after a comment is posted, showing "Comments (1)" with a "View all" link and a preview of the comment from user "kang".

@jin225298, thank you for the thorough explanation — the design rationale is well-reasoned and the PR screenshots clearly validate it. The three-state flow (no comments → inline editor → "View all" once comments exist) is a clean and coherent UX pattern that avoids card bloat on mobile. I'll withdraw my suggestion.


✏️ Learnings added
Learnt from: jin225298
Repo: usememos/memos PR: 5844
File: web/src/components/MemoView/components/MemoCommentListView.tsx:31-35
Timestamp: 2026-04-17T01:49:50.248Z
Learning: In `web/src/components/MemoView/components/MemoCommentListView.tsx`, the "Write a comment" inline button on the homepage memo card is intentionally shown **only when `commentAmount === 0`** (`showCreateButton && !hasComments`). Once a memo has comments, the card shows up to 3 comment previews and a "View all" link instead. This is a deliberate UX/UI design decision to avoid card height bloat and clutter on mobile, and to provide a clear call-to-action only in the zero-comment state. Do not flag the `!hasComments` guard on the create button as missing functionality.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: milvasic
Repo: usememos/memos PR: 5680
File: web/src/components/MemoContent/Table.tsx:115-133
Timestamp: 2026-03-23T18:28:03.127Z
Learning: In `web/src/components/MemoContent/Table.tsx`, the edit (pencil) and delete (trash) icon buttons on rendered tables are intentionally `opacity-0` and revealed only on `group-hover/table`. This is by design — table editing via dialog is not practical on touch devices, and touch users are served by always-visible "Add row" / "Add column" controls instead. Do not flag the hover-only toolbar as a touch-accessibility issue.

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.

Improvements to comments feature (button, sorting)

1 participant