Skip to content

Instantly share code, notes, and snippets.

@prah23
Created August 23, 2021 16:07
Show Gist options
  • Save prah23/354d1de5093bdbfca48ecfd3e668fa3f to your computer and use it in GitHub Desktop.
Save prah23/354d1de5093bdbfca48ecfd3e668fa3f to your computer and use it in GitHub Desktop.
GSoC 2021 Work Product

Google Summer of Code 2021 with Zulip - Work Product

This work product is a summary of the work I did for the zulip-terminal client under the Zulip organization as part of Google Summer of Code 2021.

Project Description

Contributions

Merged Pull Requests

This was to introduce a compose_box_status attribute to the WriteBox class, to indicate the current compose status of the WriteBox. A method was created and configured to reset this attribute and other compose-related attributes to their defaults.

  • 44edbe4: refactor: tests: boxes: Extend test_init to more write_box attributes.
  • 61f0ad6: boxes: Use an indicator attribute to specify current compose box status.
  • 4d1b776: boxes: Use a helper method to set compose attributes to defaults.

This was to fix a bug within the narrow validation process that was triggered every time a message was sent, by constructing the narrow accurately before validating.

  • 45a856c: tests: Fix parameter type in outside-narrow notification test.
  • 96743e1: bugfix: helper: Avoid always notifying as outside narrow for group PMs.

This was to migrate instances of tmpdir within the project to instances of the tmp_path fixture instead, which is a pathlib.Path object.

  • 8cd7940: refactor: tests: run: Use the tmp_path fixture instead of tmpdir

This added type annotations to the test_run.py file.

  • 159c2ba: refactor: tests: run: Add type annotations.
  • 2ec67b0: tools: Include test_run.py under files to be type-checked with mypy.

This added type annotations to the test_core.py file, along with prior bugfixes and refactors to ensure type consistency and usage of appropriate data structures.

  • 30f358a: bugfix: tests: core: Assign ThemeSpec instance to controller theme.
  • 65c9114: bugfix: tests: core: Assign a set to model's muted_streams.
  • 12ea36c: refactor: tests: core: Use mocker.patch in place of Mock() assignment.
  • 7be4db3: refactor: tests: core/conftest: Add & use index_search_messages fixture.
  • a657f0d: refactor: tests: core: Avoid using user_button in test_narrow_to_user.
  • a9fcd49: refactor: tests: core: Avoid using stream_button in stream narrow test.
  • b1e571e: refactor: tests: core: Avoid using msg_box in test_narrow_to_topic.
  • a13b9b2: refactor: tests: core: Add type annotations.
  • e598904: tools: Include test_core.py to be checked by mypy.

This added type annotations to the test_emoji_data.py file.

  • ad8e489: refactor: tests: emoji_data: Add type annotations.
  • 707d289: tools: Include test_emoji_data.py to be checked by mypy.

This refactor changed the stream_muting_confirmation_popup method's parameters to abstract the StreamButton by directly passing in stream parameters to the method.

  • 3800417: refactor: buttons/core: Avoid using StreamButton as a popup parameter.

This added type annotations to the test_helper.py file, along with a prior bugfix to ensure type consistency and usage of appropriate data structures.

  • 8817bd6: bugfix: tests: helper: Use Sets as params for muted_streams.
  • a3f8676: refactor: tests: helper: Add type annotations.
  • 9cc7004: tools: Include test_helper.py to be checked by mypy.

This added type annotations to the test_server_url.py file.

  • 54b78ac: refactor: tests: server_url: Add type annotations.
  • 664702f: tools: Include test_server_url.py to be checked by mypy.

This added type annotations to the test_ui.py file, along with prior refactors to ensure type consistency and appropriate patching.

  • 295f69b: refactor: ui: Patch *_box_views in OPEN_DRAFT tests.
  • 1530c22: refactor: ui: Use patch for non-existent attributes instead of Mock.
  • 880e33d: refactor: tests: ui: Add type annotations.
  • 1e647b4: tools: Include test_ui.py to be checked by mypy.

This added type annotations to the test_conftest.py file, along with prior refactors and a bugfix to ensure type consistency and usage of appropriate data structures.

  • 6286235: refactor: tests: conftest: Return a Message from template factory.
  • b63165f: refactor: tests: conftest: Return Index instance from empty_index.
  • de52893: refactor: tests: conftest: Return Index instances for index_* fixtures.
  • d302f63: bugfix: tests: conftest: Return empty tuple when widget isn't box/flow.
  • d836723: refactor: api_types/helper/views: Type user's bot_type as Optional.
  • d6d10aa: refactor: model: Change the default bot_type value for a user to None.
  • 8807abc: refactor: tests: conftest: Add type annotations.
  • 53d13f1: tools: Include conftest.py to be checked by mypy.

This added type annotations to the test_keys.py, test_themes.py, and test_color.py files, along with a prior bugfix to ensure type consistency and usage of appropriate data structures.

  • be783a3: bugfix: tests: keys: Use lists for keys of key bindings.
  • 62cb7f5: refactor: tests: keys: Add type annotations.
  • a029eea: tools: Include test_keys.py to be checked by mypy.
  • 6b241af: refactor: tests: themes: Add type annotations.
  • 6cfe4b2: tools: Include test_themes.py to be checked by mypy.
  • 5b76aa8: refactor: tests: color: Rename variable to avoid conflict with class.
  • 5410ec9: refactor: tests: color: Add type annotations.
  • 77ebd71: tools: Include test_color.py to be checked by mypy.

This added type annotations to the test_boxes.py file, along with prior refactors and a bugfix to ensure type consistency and appropriate patching.

  • eed807f: refactor: boxes: Use mocker.patch to mock write_box method.
  • dc5ed28: refactor: tests: boxes: Remove mocker as parameter where unnecessary.
  • 09d2962: bugfix: tests: boxes: Assert on to_write_box after private_box_view.
  • 29e057c: refactor: tests: boxes: Add type annotations.
  • c9a59fa: tools: Include test_boxes.py to be checked by mypy.

This added type annotations to the test_buttons.py file, along with prior refactors to ensure type consistency and usage of appropriate data structures.

  • 1860127: refactor: tests: buttons: Change params from dicts to TypedDicts.
  • d5059a0: refactor: tests: buttons: Assign method mocker.patchs to variables.
  • 3c6f730: refactor: tests: buttons: Add type annotations.
  • 4c939a6: tools: Include test_buttons.py to be checked by mypy.

This added type annotations to the test_utils.py file.

  • 70094d3: refactor: tests: utils: Add type annotations.
  • 098e8a2: tools: Include test_utils.py to be checked by mypy.

Pull Requests updated and merged during GSoC

This was a minor enhancement to the protocol followed to send typing notifications to the server, where a stop event is no longer sent without a prior start event.

  • 9edc43e: bugfix: boxes: Send typing 'stop' event only after prior 'start' event.

This made use of the extended user-mention syntax to help distinguish between users having the same name before mentioning them.

  • 7e01b3a: tests: Introduce 'Human Duplicate' to test for users with the same name.
  • 9280f09: boxes: Use user_ids in autocomplete for ambiguous user mentions.

The private message header was plugged into a more thorough validation method here, and the recipients were also tidied automatically when a user wanted to perform a relevant action.

  • bad30b0: refactor: boxes/model: Verify each email individually through model.
  • 2d2c0a0: refactor: boxes: Extract current recipient validation into a helper.
  • 56b802e: boxes: Validate private message recipients more thoroughly.
  • 5bdae3d: boxes: Validate recipients on SEND_MESSAGE and SAVE_AS_DRAFT keypresses.
  • e42100f: boxes: Inform the user to use autocomplete on invalid recipients

This migrated from using recipient_emails to send messages towards using recipient_user_ids. The abstraction between the narrow model and the Composition API type is still maintained by modifying the corresponding connections to the narrow model such that the delivery emails are still in use in the narrow model currently.

  • ceca7f5: refactor: boxes: Update user_ids as well in recipient update method.
  • ed16b92: conftest: Add a fixture for user_id_email_dict.
  • 8f92d53: boxes/ui/model/helper/api_types: Use user_ids as message destinations.
  • b4c4635: refactor: boxes/buttons/ui: Remove emails from private_box_view.

This was a minor optimization to avoid sending typing updates to oneself as well as receiving them to oneself. A helper method was also introduced to maintain synchrony between recipient_user_ids and the newer typing_recipient_user_ids.

  • e7b6da9: bugfix: model: Don't display typing updates from oneself.
  • a10cd96: bugfix: boxes: Don't send typing updates to oneself.
  • 733926d: refactor: boxes: Use helper method to set/reset recipient user_ids.

Open Pull Requests

This addition was to update topic and stream headers mid-compose automatically when the corresponding event is received. The user is also notified appropriately using the report_warning method.

This adds type annotations to the test_popups.py file, along with prior refactors to ensure type consistency and usage of appropriate data structures.

This addition aims to keep the sets of message_ids by topic under the topic_msg_ids key of the index accurate when a message's topic is changed.

Future Work

The terminal project still has multiple open issues, along with enhancements/follow-ups to the work I've done. Apart from this, a couple of issues that I initially planned on working were pushed behind to accommodate other higher priority issues. A list of all the open issues can be found here. I would work on further enhancing the private messages interface (a part of which is mentioned here), adding support for moving topics between streams, further improving the internal structure and updating my outstanding pull requests to get them merged.

Acknowledgements

I would like to sincerely thank my mentors, the Zulip community, and Google for giving me an enriching experience this summer. I am extremely thankful for the opportunity to participate in this program and enhance my programming skills while improving the zulip-terminal project.

I am immensely grateful to Neil Pilgrim and Preet Mishra for their constant guidance, timely and extensive code reviews, and engagement in regular discussion to clarify my queries.

The Zulip community has always been welcoming and helpful. Their efforts towards improving the developer experience have provided a very conducive environment to contribute. I am grateful and elated to be a part of it.

Post GSoC

Contributing to Zulip has been amazing and I intend on continuing my contributions to the project. I would also review other contributors' work and help maintain the project to make it even better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment