Skip to content

typing: widget: Add typed widget outputs and JSON shapes.#1612

Open
aryan98795 wants to merge 1 commit intozulip:mainfrom
aryan98795:refactor-widget-types
Open

typing: widget: Add typed widget outputs and JSON shapes.#1612
aryan98795 wants to merge 1 commit intozulip:mainfrom
aryan98795:refactor-widget-types

Conversation

@aryan98795
Copy link
Collaborator

@aryan98795 aryan98795 commented Feb 1, 2026

Define TypedDicts for todo/poll widget outputs and JSON payloads. Update widget processing to use typed structures and casts. Update widget rendering to use the new return shape. Add a widget test fixture and normalize submessages in tests.

Fixes: #1576

External discussion & connections

  • Discussed in #zulip-terminal in topic
  • Fully fixes #
  • Partially fixes issue #
  • Builds upon previous unmerged work in PR #
  • Is a follow-up to work in PR #
  • Requires merge of PR #
  • Merge will enable work on #

How did you test this?

  • Manually - Behavioral changes
  • Adapting existing automated tests
  • Manually - Visual changes
  • Adding automated tests for new behavior (or missing tests)
  • Existing automated tests should already cover this (only a refactor of tested code)

Self-review checklist for each commit

  • It is a minimal coherent idea
  • It has a commit summary following the documented style (title & body)
  • It has a commit summary describing the motivation and reasoning for the change
  • It individually passes linting and tests
  • It contains test additions for any new behavior
  • It flows clearly from a previous branch commit, and/or prepares for the next commit

Copilot AI review requested due to automatic review settings February 1, 2026 11:56
@zulipbot zulipbot added size: XL [Automatic label added by zulipbot] area: refactoring area: widgets GSoC Possible GSoC project component TRACKING labels Feb 1, 2026
@zulipbot
Copy link
Member

zulipbot commented Feb 1, 2026

Hello @zulip/server-refactoring members, this pull request was labeled with the "area: refactoring" label, so you may want to check it out!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds stronger typing around widget (submessage) payloads and processing results, and updates widget rendering/tests to use the new structured return shapes.

Changes:

  • Define TypedDict types for submessages and poll/todo widget payloads/results.
  • Update process_todo_widget / process_poll_widget to return typed dict “result objects” instead of tuples.
  • Update message rendering and widget unit tests to consume the new result shape.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
zulipterminal/widget.py Switch widget processors to typed result dicts and import shared widget/submessage types.
zulipterminal/ui_tools/messages.py Update widget rendering to use the new {title,tasks} / {question,options} result shapes.
zulipterminal/model.py Normalize stored submessage schema (use id, drop type/submessage_id).
zulipterminal/api_types.py Add TypedDict definitions for submessages and poll/todo widget structures; tighten Message.submessages typing.
tests/widget/test_widget.py Update widget tests to assert on new result dict shapes and use shared api_types types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aryan98795 aryan98795 force-pushed the refactor-widget-types branch 2 times, most recently from d9ca6e8 to 2b035e8 Compare February 1, 2026 13:45
Define TypedDicts for todo/poll widget outputs and JSON payloads.
Update widget processing to use typed structures and casts.
Update widget rendering to use the new return shape.
Add a widget test fixture and normalize submessages in tests.

Fixes: zulip#1576
@aryan98795 aryan98795 force-pushed the refactor-widget-types branch 2 times, most recently from 7c18b34 to 8706f5f Compare February 1, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: refactoring area: widgets GSoC Possible GSoC project component size: XL [Automatic label added by zulipbot] TRACKING

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve typing & test approach for widgets

3 participants