Skip to content

feat(inbox): Add item and event serializers - #129373

Merged
cvxluo merged 1 commit into
cvxluo/define-api-response-typesfrom
cvxluo/add-item-and-event-serializers
Nov 2, 2026
Merged

cvxluo merged 1 commit into
cvxluo/define-api-response-typesfrom
cvxluo/add-item-and-event-serializers

Conversation

@cvxluo

@cvxluo cvxluo commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Add serializers for inbox items and events. With this we'll be able to go from model -> api response.

Fixes ISWF-3645

@linear-code

linear-code Bot commented Oct 30, 2026

Copy link
Copy Markdown

ISWF-3645

@cvxluo
cvxluo added this pull request to stack #129374 October 30, 2026 21:34
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 30, 2026
@cvxluo
cvxluo marked this pull request as ready for review November 2, 2026 18:34
@cvxluo
cvxluo force-pushed the cvxluo/add-item-and-event-serializers branch 2 times, most recently from 02074e7 to a6e1350 Compare November 2, 2026 18:50
latest_events, serialize(latest_events, user, InboxItemEventSerializer())
)
}
# Get titles for each item based on the subject type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this ends up being a little complicated to read. i think a longer term solution will be to decouple some of the shared functionality like get_title from the subject registry, but for now this works

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

agreed, seems to make sense to have as a function exposed from an inbox item service or subject registry mapping

@cvxluo
cvxluo requested a review from a team November 2, 2026 18:51
latest_events, serialize(latest_events, user, InboxItemEventSerializer())
)
}
# Get titles for each item based on the subject type

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

agreed, seems to make sense to have as a function exposed from an inbox item service or subject registry mapping

if value is not None:
data[key] = str(value)
data = convert_dict_key_case(data, snake_to_camel_case)
last_read_at = obj.inbox_item.last_read_at

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should we be prefetching this in get_attrs() like we do in InboxItemSerializer? not 100% sure if it currently actually results in extra queries tho

actor = {"type": "system", "id": None, "name": "Sentry", "avatar": None}
else:
actor_user = attrs["user"]
actor = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use ActorSerializer here to ensure this is consistent with other user objects?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i don't think we can be consistent here, since ActorSerializer would be missing the avatar. i'll think about this one more

"avatar": actor_user.get("avatar") if actor_user else None,
}
data = {key: value for key, value in obj.data.items() if key != "summary"}
for key in ("comment_id", "seer_run_id"):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems wrong for the serializer to need to know what kinds of properties data might have?

@cvxluo cvxluo Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hm i can probably think of something better here. the problem is that we want to conditionally stringify some fields of data as part of serialization, but since data can be anything, we need to identify what fields to stringify here. i'll follow up with a change for each InboxEventData to own it's own data serialization

Load subject titles, event aggregates, and latest events in bulk.
Resolve user actors once per page and expose stored summaries with camelCase payload keys.

Keep retained events readable when their subject or event registration is removed.

Fixes ISWF-3645

Co-authored-by: Codex <codex@openai.com>
@cvxluo
cvxluo force-pushed the cvxluo/add-item-and-event-serializers branch from a6e1350 to c301029 Compare November 2, 2026 20:01
@cvxluo
cvxluo merged commit 30b98ed into master Nov 2, 2026
67 of 68 checks passed
@cvxluo
cvxluo deleted the cvxluo/add-item-and-event-serializers branch November 2, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants