Skip to content

chore: fix missing group key#253

Merged
appflowy merged 2 commits intomainfrom
fill_missing_group_key2
Feb 7, 2026
Merged

chore: fix missing group key#253
appflowy merged 2 commits intomainfrom
fill_missing_group_key2

Conversation

@appflowy
Copy link
Contributor

@appflowy appflowy commented Feb 7, 2026

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

Align Yjs database types and keys with new relation, grouping, and calculation metadata requirements and ensure groups are created with an explicit type.

New Features:

  • Support additional Yjs database keys for relation configuration, calculation values, collapsed groups, and auxiliary metadata.

Bug Fixes:

  • Ensure generated database groups include their field type to prevent missing group type metadata.

Enhancements:

  • Relax and extend Yjs map typings to handle numeric or optional values for group types, calculation values, reciprocal relation fields, relation limits, and boolean flags.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 7, 2026

Reviewer's Guide

Adds missing Yjs database keys and corresponding typed getters, and ensures database group objects are initialised with a type, fixing issues with group metadata and calculations for relations and grouped views.

Class diagram for updated Yjs database types and group initialization

classDiagram
  direction LR

  class YjsDatabaseKey {
    <<enumeration>>
    data
    iid
    database_id
    is_two_way
    reciprocal_field_id
    reciprocal_field_name
    source_limit
    target_limit
    relation_field_id
    target_field_id
    calculation_type
    calculations
    field_id
    calculation_value
    cv
    source_field_type
    condition
    schema_version
    format
    filter_type
    visible
    collapsed_group_ids
    hide_ungrouped_column
    collapse_hidden_groups
    first_day_of_week
  }

  class YDatabaseGroup {
    +get(key YjsDatabaseKey.field_id) FieldId
    +get(key YjsDatabaseKey.type) number|string
    +get(key YjsDatabaseKey.content) string
    +get(key YjsDatabaseKey.groups) YDatabaseGroupColumns
    +get(key YjsDatabaseKey.collapsed_group_ids) YArray_string_or_string_array_or_undefined
  }

  class YDatabaseGroupColumns {
    <<typealias>>
    elements : Array_GroupColumn
  }

  class Array_GroupColumn {
    <<object>>
    id : string
    visible : boolean
  }

  class YDatabaseCalculation {
    +get(key YjsDatabaseKey.field_id) FieldId
    +get(key YjsDatabaseKey.id) string
    +get(key YjsDatabaseKey.cv) string
    +get(key YjsDatabaseKey.type) string|number
    +get(key YjsDatabaseKey.calculation_value) string|number|undefined
  }

  class YMapFieldTypeOption {
    +get(key YjsDatabaseKey.name) string
    +get(key YjsDatabaseKey.icon) string
    +get(key YjsDatabaseKey.description) string
    +get(key YjsDatabaseKey.condition_value) string
    +get(key YjsDatabaseKey.reciprocal_field_id) string|undefined
    +get(key YjsDatabaseKey.reciprocal_field_name) string|undefined
    +get(key YjsDatabaseKey.time_format) string|undefined
    +get(key YjsDatabaseKey.date_format) string
    +get(key YjsDatabaseKey.database_id) DatabaseId
    +get(key YjsDatabaseKey.is_two_way) boolean
    +get(key YjsDatabaseKey.include_time) boolean
    +get(key YjsDatabaseKey.source_limit) number|undefined
    +get(key YjsDatabaseKey.target_limit) number|undefined
    +get(key YjsDatabaseKey.calculation_type) number
    +get(key YjsDatabaseKey.show_as) number
    +get(key YjsDatabaseKey.format) string
    +get(key YjsDatabaseKey.auto_fill) boolean
  }

  class YDatabaseField {
    +fieldId : FieldId
    +fieldType : FieldType
  }

  class YDatabaseGroupFactory {
    +generateGroupByField(field YDatabaseField) YDatabaseGroup
  }

  class YArray_string_or_string_array_or_undefined {
    <<union>>
  }

  class FieldId
  class DatabaseId
  class FieldType

  YDatabaseGroup o-- YDatabaseGroupColumns : groups
  YDatabaseGroup --> YjsDatabaseKey : uses_keys
  YDatabaseCalculation --> YjsDatabaseKey : uses_keys
  YMapFieldTypeOption --> YjsDatabaseKey : uses_keys
  YDatabaseGroupFactory --> YDatabaseGroup : creates
  YDatabaseGroupFactory --> YDatabaseField : reads
  YDatabaseGroupFactory --> YjsDatabaseKey : sets_field_id_id_type
Loading

File-Level Changes

Change Details Files
Extend YjsDatabaseKey enum and related Yjs map interfaces to cover new relation, calculation, and grouping metadata keys.
  • Add enum members for relation metadata (is_two_way, reciprocal_field_id, reciprocal_field_name, source_limit, target_limit).
  • Add enum members for calculation/value metadata (cv) and grouping state (collapsed_group_ids).
  • Update YDatabaseGroup get overloads to support retrieving type and collapsed_group_ids with correct types.
  • Refine YDatabaseCalculation get overloads to separate id/cv, type, and calculation_value with more accurate string/number/undefined unions.
  • Extend YMapFieldTypeOption get overloads to surface reciprocal relation fields, relation configuration booleans, and limits with proper types.
src/application/types.ts
Ensure generated database group definitions include the field type when grouping is created.
  • In database-yjs dispatch layer, set the group.type to the fieldType when generating a group-by-field definition.
  • Mirror the same group.type assignment in the grouped-dispatch module to keep both code paths consistent.
src/application/database-yjs/dispatch.ts
src/application/database-yjs/dispatch/group.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 reviewed your changes and they look great!


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 935557d into main Feb 7, 2026
13 of 14 checks passed
@appflowy appflowy deleted the fill_missing_group_key2 branch February 7, 2026 03:28
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