Skip to content

Conversation

plugyawn
Copy link
Collaborator

@plugyawn plugyawn commented Apr 5, 2022

What does this PR do?
Adds bot markers to bots.

Partial fix for #1155.

Tested?

  • Manually
  • Existing tests (adapted, if necessary)
  • New tests added (for any new behavior)
  • Passed linting & tests (each commit)

Commit flow

  • first commit adds BOT_MARKER to symbols.py. Currently set to robot face, U+1F916 (🤖).
  • second commit adds necessary changes in ui_mappings.py to associate BOT_MARKER with the "bot" status, as compared to the "inactive" status they were assigned earlier.
  • third commit checks if it is indeed a bot and associates the marker to it.

Notes & Questions

  • unsure about how to fix the black background against the robot emoji. I'm guessing it's because it's not a traditional character? I couldn't really choose a better character.

Visual changes

Screenshot 2022-04-06 at 12 00 38 AM

@zulipbot zulipbot added the size: S [Automatic label added by zulipbot] label Apr 5, 2022
@neiljp
Copy link
Collaborator

neiljp commented Apr 6, 2022

@plugyawn I mentioned about the symbol in the stream. Otherwise please use the standard commit text style for zulip-terminal as indicated in the README (and see gitlint), and adjust the commit flow ready for merging.

This looks straightforward; I'm not sure if we explicitly need tests for this.

In a bot-related way, you might consider how the user popup can be improved for the case of bots, as a follow-up.

@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback area: UI General user interface update labels Apr 6, 2022
@plugyawn
Copy link
Collaborator Author

plugyawn commented Apr 7, 2022

On it! I'll update the commit text and let you know asap.

@neiljp
Copy link
Collaborator

neiljp commented Apr 21, 2022

@plugyawn I'm mainly waiting for a commit reflow here, which may be simple, but just checked functionality again as it stands as this seems a quick PR. However, it seems that the symbol you're using is styled to be black on a white background somehow, and that is bleeding into the user search box names too. That doesn't seem to be intentional, so I wonder if it's part of the symbol itself somehow?

@plugyawn plugyawn force-pushed the feature-bot-marker branch from a4f1961 to e0f5236 Compare May 6, 2022 13:55
@plugyawn
Copy link
Collaborator Author

plugyawn commented May 6, 2022

@neiljp updated the commit flow.

Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@plugyawn This is tidier, but as per my inline notes, please keep the tidying (and intentional changes) that go with each set of changes in the associated commit. Reading your changes through in the github interface, as if reviewing your own code, will likely show obvious issues like the pawn vs robot unicode codepoint.

We don't always end up needing the commits to be so small, but keeping logical changes separate makes it much easier to read.

@neiljp
Copy link
Collaborator

neiljp commented May 6, 2022

Also note that the formatting being in the wrong commit would be picked up if you ran tools/check-branch.

@plugyawn plugyawn force-pushed the feature-bot-marker branch from e0f5236 to c39cbd2 Compare June 7, 2022 08:53
@plugyawn plugyawn added PR needs review PR requires feedback to proceed PR needs buddy review and removed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Jun 7, 2022
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@plugyawn This looks much tidier :)

I think the first two commits may be squashable together later, as they're very small.

This appears to work fine on one machine, but I tested on my new machine (python3.9, debian) and it doesn't show the symbols, but that may be a local issue.

My remaining concerns are if we have other locations where the status is otherwise used which haven't been updated. This is evident since like I mentioned in the last group chat, many locations directly access this data and so it's rather fragile.

One thing we might do to address this is to define the types of the elements of user_dict, and mypy may then be able to work with that, particularly if we use Literal types for the status.

Comment on lines +953 to +985
if user["is_bot"]:
self.user_dict[user["email"]] = {
"full_name": user["full_name"],
"email": email,
"user_id": user["user_id"],
"status": "bot",
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bots don't have status - hence the marker - so let's avoid doing the work just above this and treat a bot specially, like with the user running the application, in a block further up.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you understand my suggestion? You've not replied or updated for it.

@neiljp
Copy link
Collaborator

neiljp commented Jun 9, 2022

See other feedback in the stream. I resolved my issue with it not working at all on one of my computers.

@srdeotarse
Copy link
Collaborator

I have reviewed the PR and have posted some questions in the stream.

Copy link
Collaborator

@mounilKshah mounilKshah left a comment

Choose a reason for hiding this comment

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

Upon running the PR, it worked without any glitches/crashes. It didn't work for Notification Bot though but I think this has been discussed in the stream already. The changes look good to me.

@neiljp
Copy link
Collaborator

neiljp commented Jun 24, 2022

@plugyawn This PR would be good to close out, now you've got feedback too?

@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs review PR requires feedback to proceed labels Jun 24, 2022
@plugyawn plugyawn force-pushed the feature-bot-marker branch 3 times, most recently from b8f09bd to 830032e Compare August 6, 2022 11:30
@plugyawn plugyawn force-pushed the feature-bot-marker branch from 830032e to e83a43f Compare August 6, 2022 11:38
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@plugyawn The system bots appear to work now (eg. Notification bot), though I assume you'll check yourself again since you left a comment :)

As you said in the stream, the styles are still strange, which is likely related to the way styles are picked for each user status - like the green/yellow/white. These are connected somewhere, so we likely want to extend the styles to cover the bot case you added.

@@ -985,7 +994,7 @@ def get_all_users(self) -> List[Dict[str, Any]]:
"full_name": bot["full_name"],
"email": email,
"user_id": bot["user_id"],
"status": "inactive",
"status": "bot", #FIXME was inactive, does this work?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you tested this? See Mounil's comment on the PR to test for that bot user, eg. Notification bot or Welcome bot.

@plugyawn plugyawn force-pushed the feature-bot-marker branch from e83a43f to e404149 Compare August 6, 2022 18:50
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@plugyawn This looks cleaner now 👍

I've left more feedback inline, but also please try and keep the linting clean, and adapt tests appropriately where necessary, ideally on a per-commit basis - keeping those up to date means that the PR is closer to a mergeable state at any given time. Have you been using black or make fix on commits to tidy these? That should keep the manual tidying load down.

There was a previous comment you didn't address, but that could be a refactor later - it's just us avoiding calculating presence for bots from memory.

@@ -24,6 +24,7 @@
'user_idle' : (Color.YELLOW, Color.BLACK),
'user_offline' : (Color.WHITE, Color.BLACK),
'user_inactive' : (Color.WHITE, Color.BLACK),
'user_bot' : (Color.WHITE, Color.BLACK),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be in more than one style (and aligned) - I still get the previous bad styling/highlighting behavior in eg. gruvbox_dark.

While arguable, I would also place this commit before the other in order to have good styling available before you use it. The other commit may still "work" (if incompletely/wrongly visually), but in addition it reads strangely, specifically like a bugfix.

Comment on lines +1024 to +1028
bot = [
properties
for properties in self.user_dict.values()
if properties["status"] == "bot"
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is different behavior than what you had before, and what we have now, so it at least warrants mentioning what changed in the commit text. I'd almost suggest this could be a separate commit, since it's a different change - the ordering, not the icon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Rebased anda added a new commit.

@plugyawn plugyawn force-pushed the feature-bot-marker branch from e404149 to 8d7eb2c Compare August 9, 2022 03:02
@zulipbot zulipbot added size: M [Automatic label added by zulipbot] and removed size: S [Automatic label added by zulipbot] labels Aug 9, 2022
@plugyawn plugyawn force-pushed the feature-bot-marker branch 2 times, most recently from 26dcb75 to 2fee25d Compare August 9, 2022 03:13
@zulipbot zulipbot added size: S [Automatic label added by zulipbot] and removed size: M [Automatic label added by zulipbot] labels Aug 9, 2022
@plugyawn plugyawn force-pushed the feature-bot-marker branch from 2fee25d to 1e036de Compare August 9, 2022 03:14
@zulipbot zulipbot added size: M [Automatic label added by zulipbot] and removed size: S [Automatic label added by zulipbot] labels Aug 9, 2022
@plugyawn plugyawn force-pushed the feature-bot-marker branch 2 times, most recently from 1953af2 to a9d41e3 Compare August 9, 2022 08:23
@plugyawn plugyawn force-pushed the feature-bot-marker branch from a9d41e3 to 34ac885 Compare August 9, 2022 08:32
neiljp added a commit to neiljp/zulip-terminal that referenced this pull request Apr 12, 2023
This will be picked up using earlier commits, to show it differently in
the UI.

With a different status, they are now explicitly placed at the end of the
user list.

Tests updated.

Original logic by Progyan, simplified using logic suggested in review by
neiljp in zulip#1187.

Co-authored-by: neiljp (Neil Pilgrim) <[email protected]>
neiljp added a commit to neiljp/zulip-terminal that referenced this pull request Apr 12, 2023
This will be picked up using earlier commits, to show it differently in
the UI.

With a different status, they are now explicitly placed at the end of the
user list.

Tests updated.

Original logic by Progyan, simplified using logic suggested in review by
neiljp in zulip#1187.

Co-authored-by: neiljp (Neil Pilgrim) <[email protected]>
neiljp added a commit to neiljp/zulip-terminal that referenced this pull request Apr 12, 2023
This will be picked up using earlier commits, to show it differently in
the UI.

With a different status, bots are now explicitly placed at the end of the
user list.

Tests updated.

Original logic by Progyan, simplified using logic suggested in review by
neiljp in zulip#1187.

Co-authored-by: neiljp (Neil Pilgrim) <[email protected]>
neiljp added a commit that referenced this pull request Apr 12, 2023
This will be picked up using earlier commits, to show it differently in
the UI.

With a different status, bots are now explicitly placed at the end of the
user list.

Tests updated.

Original logic by Progyan, simplified using logic suggested in review by
neiljp in #1187.

Co-authored-by: neiljp (Neil Pilgrim) <[email protected]>
@neiljp
Copy link
Collaborator

neiljp commented Apr 12, 2023

@plugyawn Thanks for working on this 👍 I reworked this slightly after a preliminary refactor and a few adjustments, and this work is effectively merged as #1377 🎉

@neiljp neiljp closed this Apr 12, 2023
@neiljp neiljp added this to the Next Release milestone Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: UI General user interface update PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback PR replaced by another PR size: M [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants