Skip to content

Conversation

@appflowy
Copy link
Contributor

@appflowy appflowy commented Dec 26, 2025

Description


Checklist

General

  • I've included relevant documentation or comments for the changes introduced.
  • I've tested the changes in multiple environments (e.g., different browsers, operating systems).

Testing

  • I've added or updated tests to validate the changes introduced for AppFlowy Web.

Feature-Specific

  • For feature additions, I've added a preview (video, screenshot, or demo) in the "Feature Preview" section.
  • I've verified that this feature integrates seamlessly with existing functionality.

Summary by Sourcery

Simplify how translated row content is aggregated from the AI translation response.

Bug Fixes:

  • Ensure generated AI translation for a row only includes the item content field instead of concatenating all key-value pairs.

Enhancements:

  • Streamline translation response processing by mapping directly to item content, filtering out empty entries, and joining them into a single string.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 26, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the AI translation utility for table rows to only use the translated content field from the API response and simplify how the final translation string is constructed.

Sequence diagram for updated generateAITranslateForRow translation flow

sequenceDiagram
  participant Caller
  participant HttpService
  participant AITranslateAPI

  Caller->>HttpService: generateAITranslateForRow(workspaceId, payload)
  HttpService->>AITranslateAPI: POST /ai/translate_row with payload
  AITranslateAPI-->>HttpService: payloadResponse with items
  Note over HttpService: items: [{ content, ...otherFields }]

  loop For each item in payloadResponse.items
    HttpService->>HttpService: extract item.content
    HttpService->>HttpService: filter out empty content
  end

  HttpService->>HttpService: join contents with ", "
  HttpService-->>Caller: translatedRowContentString
Loading

File-Level Changes

Change Details Files
Simplify and correct how AI row translations are extracted and concatenated from the HTTP API response.
  • Replace generic Object.entries-based serialization of each response item with direct access to its content property.
  • Filter out falsy or empty content values before concatenation to avoid blank lines or artifacts in the result.
  • Change the join delimiter so that all non-empty contents are joined in a single comma-separated string instead of multi-line key-value pairs.
src/application/services/js-services/http/http_api.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The separator between translated rows changed from a newline ('\n') to ', ', which may affect any consumer logic or display that relied on line breaks—confirm this formatting change is intentional.
  • The new implementation assumes every item has a content field; if this shape isn’t guaranteed by the API, consider adding a more defensive access pattern or a runtime check to avoid silent data loss.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The separator between translated rows changed from a newline (`'\n'`) to `', '`, which may affect any consumer logic or display that relied on line breaks—confirm this formatting change is intentional.
- The new implementation assumes every item has a `content` field; if this shape isn’t guaranteed by the API, consider adding a more defensive access pattern or a runtime check to avoid silent data loss.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@appflowy appflowy merged commit cfbbc44 into main Dec 27, 2025
11 of 12 checks passed
@appflowy appflowy deleted the fix_db_translate branch December 27, 2025 02:33
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