Skip to content

emoji suggestions - #40

Merged
PrivateGER merged 3 commits into
developfrom
feat/emoji-suggestions
Aug 12, 2026
Merged

emoji suggestions#40
PrivateGER merged 3 commits into
developfrom
feat/emoji-suggestions

Conversation

@PrivateGER

@PrivateGER PrivateGER commented Aug 12, 2026

Copy link
Copy Markdown
Owner

What

Why

Additional info (optional)

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Add story of storybook
  • (If needed) Update CHANGELOG.md
  • (If possible) Add tests

Summary by CodeRabbit

  • New Features
    • Signed-in users can submit custom emoji suggestions from the emoji management interface.
    • Added a dedicated page to view, track, and cancel submitted suggestions.
    • Moderators can review, accept, or reject pending suggestions.
    • Added pagination, confirmation dialogs, metadata, localized messaging, and navigation access.
    • Added API support and typed client entities for emoji suggestions.
  • Documentation
    • Added English localization strings for emoji suggestion workflows.
  • Tests
    • Added coverage for validation, acceptance, cancellation, concurrency, and failure recovery.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 49718602-54c5-422d-bcca-c9c7d6a0cb5f

📥 Commits

Reviewing files that changed from the base of the PR and between 7631d71 and 23ee93c.

📒 Files selected for processing (4)
  • packages/backend/migration/1786507200000-EmojiSuggestion.js
  • packages/backend/src/core/EmojiSuggestionService.ts
  • packages/backend/test/unit/EmojiSuggestionService.ts
  • packages/frontend/src/pages/about.emojis.vue
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/backend/migration/1786507200000-EmojiSuggestion.js
  • packages/frontend/src/pages/about.emojis.vue
  • packages/backend/src/core/EmojiSuggestionService.ts

Walkthrough

Adds an end-to-end emoji suggestion workflow. Users can submit, view, and cancel suggestions. Moderators can list, accept, and reject suggestions. The change includes persistence, API contracts, frontend pages, localization, and service tests.

Changes

Emoji suggestions

Layer / File(s) Summary
Suggestion persistence and schemas
packages/backend/migration/..., packages/backend/src/models/..., packages/backend/src/misc/json-schema.ts, packages/backend/src/postgres.ts
Adds the emoji_suggestion table, MiEmojiSuggestion entity, repository bindings, packed response schema, indexes, and database registration.
Suggestion processing services
packages/backend/src/core/EmojiSuggestionService.ts, packages/backend/src/core/entities/EmojiSuggestionEntityService.ts, packages/backend/src/core/CoreModule.ts, packages/backend/test/unit/EmojiSuggestionService.ts
Adds validation, creation, acceptance, cancellation, rejection, entity packing, dependency registration, and tests for concurrency and rollback behavior.
Suggestion API endpoints
packages/backend/src/server/api/emoji-suggestion.ts, packages/backend/src/server/api/endpoints/..., packages/backend/src/server/api/endpoint-list.ts
Adds authenticated user endpoints and moderator endpoints for creating, listing, cancelling, accepting, and rejecting suggestions.
Client contracts and workflow
packages/misskey-js/src/*, packages/frontend/src/pages/*, packages/frontend/src/router.definition.ts, packages/frontend/src/ui/_common_/common.ts, locales/index.d.ts, sharkey-locales/en-US.yml
Adds API and entity types, the suggestion page, editor submission flow, navigation and routing, moderator actions, and localized text.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant EmojiSuggestionsPage
  participant EmojiSuggestionAPI
  participant EmojiSuggestionService
  participant StorageAndEmojiService
  User->>EmojiSuggestionsPage: Submit or act on suggestion
  EmojiSuggestionsPage->>EmojiSuggestionAPI: Call suggestion endpoint
  EmojiSuggestionAPI->>EmojiSuggestionService: Validate and process request
  EmojiSuggestionService->>StorageAndEmojiService: Copy file and create emoji on acceptance
  EmojiSuggestionAPI-->>EmojiSuggestionsPage: Return packed suggestion or emoji
  EmojiSuggestionsPage-->>User: Update suggestion list
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description contains only the template and omits implementation details, motivation, testing information, and checklist status. Complete the What and Why sections, add testing information, and mark the applicable checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding emoji suggestions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/emoji-suggestions

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/frontend/src/pages/about.emojis.vue

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7631d717fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


// Consume the suggestion before doing any work. This makes acceptance,
// cancellation, rejection, and another acceptance mutually exclusive.
const claimed = await this.emojiSuggestionsRepository.delete({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the claimed name and file reserved during acceptance

Deleting the row before the potentially slow uploadFromUrl operation releases both unique indexes. If another create request for the same file or name arrives before the emoji is inserted, it passes both duplicate checks and leaves a pending suggestion for an emoji that was just accepted; if acceptance instead fails, restoreSuggestion() can collide with that new row and mask the original error. Claim the row without releasing its uniqueness reservations until acceptance has completed.

Useful? React with 👍 / 👎.

Comment thread packages/backend/src/core/EmojiSuggestionService.ts
@PrivateGER

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
packages/backend/src/core/EmojiSuggestionService.ts (1)

134-153: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚖️ Poor tradeoff

Consider a transaction for the claim-and-restore sequence.

The claim deletes the row, and restoreSuggestion re-inserts it through a separate statement. A process crash or a connection loss between the two leaves the suggestion permanently deleted while no emoji exists. A SELECT ... FOR UPDATE inside a transaction, or a status column instead of a delete, would make the claim recoverable.

The current design is defensible for a moderation queue. Treat this as a durability trade-off to record, not a blocker.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/backend/src/core/EmojiSuggestionService.ts` around lines 134 - 153,
Document the durability trade-off around the claim-and-restore sequence in the
relevant method of EmojiSuggestionService, noting that the separate delete and
restoreSuggestion insert can permanently lose the suggestion after a crash or
connection failure. Record that a transaction with row locking or a
status-column claim would make it recoverable, without changing the current
moderation-queue behavior.
packages/backend/test/unit/EmojiSuggestionService.ts (1)

89-124: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the remaining create guard branches.

The tests cover noSuchFile and duplicateSuggestion. Three guards stay untested: unsupportedFileType on Line 78, duplicateName on Line 79, and tooManyPendingSuggestions on Line 90 of packages/backend/src/core/EmojiSuggestionService.ts. The tooManyPendingSuggestions boundary matters because the check uses >= against MAX_PENDING_EMOJI_SUGGESTIONS. reject also has no test.

I can generate these cases if you want them.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/backend/test/unit/EmojiSuggestionService.ts` around lines 89 - 124,
Add tests for the remaining EmojiSuggestionService.create guards:
unsupportedFileType, duplicateName, and tooManyPendingSuggestions, including the
exact MAX_PENDING_EMOJI_SUGGESTIONS boundary, plus a reject test covering its
expected behavior. Reuse the existing createService fixtures and assertions to
verify each domain result and that persistence is not performed when
appropriate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/backend/migration/1786507200000-EmojiSuggestion.js`:
- Line 16: Add the missing semicolon to the name assignment in the
EmojiSuggestion1786507200000 migration, matching the semicolon style used by the
other migrations.

In `@packages/backend/src/core/EmojiSuggestionService.ts`:
- Around line 192-214: Update the catch block in EmojiSuggestionService to
preserve the original createEmoji error while isolating failures from deleteFile
and restoreSuggestion cleanup. Ensure both cleanup operations are attempted
without replacing the caught error, then allow isDuplicateKeyValueError(error)
to map duplicate failures to duplicateName and rethrow the original error
otherwise; use the service’s injected logger, adding LoggerService if needed, to
record cleanup failures.

In `@packages/frontend/src/pages/about.emojis.vue`:
- Around line 8-11: Update the custom emoji manager button condition in the
about page to include $i.isAdmin, matching the access condition used in
common.ts while preserving the existing moderator and canManageCustomEmojis
checks.

---

Nitpick comments:
In `@packages/backend/src/core/EmojiSuggestionService.ts`:
- Around line 134-153: Document the durability trade-off around the
claim-and-restore sequence in the relevant method of EmojiSuggestionService,
noting that the separate delete and restoreSuggestion insert can permanently
lose the suggestion after a crash or connection failure. Record that a
transaction with row locking or a status-column claim would make it recoverable,
without changing the current moderation-queue behavior.

In `@packages/backend/test/unit/EmojiSuggestionService.ts`:
- Around line 89-124: Add tests for the remaining EmojiSuggestionService.create
guards: unsupportedFileType, duplicateName, and tooManyPendingSuggestions,
including the exact MAX_PENDING_EMOJI_SUGGESTIONS boundary, plus a reject test
covering its expected behavior. Reuse the existing createService fixtures and
assertions to verify each domain result and that persistence is not performed
when appropriate.
🪄 Autofix

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 Plus

Run ID: 83bf692c-0e74-4a66-8e80-b50b3b4a2c65

📥 Commits

Reviewing files that changed from the base of the PR and between ad46559 and 7631d71.

📒 Files selected for processing (29)
  • locales/index.d.ts
  • packages/backend/migration/1786507200000-EmojiSuggestion.js
  • packages/backend/src/core/CoreModule.ts
  • packages/backend/src/core/EmojiSuggestionService.ts
  • packages/backend/src/core/entities/EmojiSuggestionEntityService.ts
  • packages/backend/src/di-symbols.ts
  • packages/backend/src/misc/json-schema.ts
  • packages/backend/src/models/EmojiSuggestion.ts
  • packages/backend/src/models/RepositoryModule.ts
  • packages/backend/src/models/_.ts
  • packages/backend/src/models/json-schema/emoji-suggestion.ts
  • packages/backend/src/postgres.ts
  • packages/backend/src/server/api/emoji-suggestion.ts
  • packages/backend/src/server/api/endpoint-list.ts
  • packages/backend/src/server/api/endpoints/admin/emoji-suggestions/accept.ts
  • packages/backend/src/server/api/endpoints/admin/emoji-suggestions/list.ts
  • packages/backend/src/server/api/endpoints/admin/emoji-suggestions/reject.ts
  • packages/backend/src/server/api/endpoints/emoji-suggestions/cancel.ts
  • packages/backend/src/server/api/endpoints/emoji-suggestions/create.ts
  • packages/backend/src/server/api/endpoints/emoji-suggestions/list.ts
  • packages/backend/test/unit/EmojiSuggestionService.ts
  • packages/frontend/src/pages/about.emojis.vue
  • packages/frontend/src/pages/emoji-edit-dialog.vue
  • packages/frontend/src/pages/emoji-suggestions.vue
  • packages/frontend/src/router.definition.ts
  • packages/frontend/src/ui/_common_/common.ts
  • packages/misskey-js/src/api.types.ts
  • packages/misskey-js/src/entities.ts
  • sharkey-locales/en-US.yml

Comment thread packages/backend/migration/1786507200000-EmojiSuggestion.js Outdated
Comment thread packages/backend/src/core/EmojiSuggestionService.ts
Comment thread packages/frontend/src/pages/about.emojis.vue
@PrivateGER
PrivateGER merged commit 4126d1d into develop Aug 12, 2026
4 checks passed
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.

1 participant