Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed and pending message to end of conversation. #818

Closed
wants to merge 1 commit into from

Conversation

ntoll
Copy link
Contributor

@ntoll ntoll commented Feb 25, 2020

Description

Fixes #653 .

This is a spike. TODO: unit tests to confirm. Pushed and PR'd so folks can see/check my approach.

Status

Requesting feedback

Test Plan

Checklist

If these changes modify code paths involving cryptography, the opening of files in VMs or network (via the RPC service) traffic, Qubes testing in the staging environment is required. For fine tuning of the graphical user interface, testing in any environment in Qubes is required. Please check as applicable:

  • I have tested these changes in the appropriate Qubes environment
  • I do not have an appropriate Qubes OS workstation set up (the reviewer will need to test these changes)
  • These changes should not need testing in Qubes

If these changes add or remove files other than client code, packaging logic (e.g., the AppArmor profile) may need to be updated. Please check as applicable:

  • I have submitted a separate PR to the packaging repo
  • No update to the packaging logic (e.g., AppArmor profile) is required for these changes
  • I don't know and would appreciate guidance

@ntoll
Copy link
Contributor Author

ntoll commented Feb 25, 2020

Current state of this problem:

  • We don't handle the case where a reply is in a failed or pending state.
  • Therefore, when we update / insert messages into the conversation to reflect the state of the order of the conversation from the server's point of view, there may be mis-ordering because of the "spare" replies in failed or pending states that are not known to the server (but which already exist in a position in the conversation on the client).
  • Therefore, we need to handle this case of slotting in such replies which have a failed or pending state.
  • As of this first (spike) draft I have handled this case by putting all replies in the failed or pending state to the bottom of the conversation whilst retaining the order in which they were added to the conversation. This both demonstrates that we now have code to handle such a case whilst also doing the wrong thing.
  • The "right thing" ™️ is for the replies in failed or pending states to be added to the conversation so they are in the correct position according to the order of the timestamp value associated with them (i.e. they're no longer moved to the bottom). As a result, the replies in the failed or pending state retain their conversational context.
  • In addition, as @ninavizz pointed out during stand-up, there needs to be some way to signal to the user that a reply may have failed.
  • Finally, if the client is closed and then restarted, the conversation needs to retain the timestamp ordered conversational items.

I'd also add, that I believe we have stale code (the loop to delete out of date widgets) which should be refactored out. I also believe that we could improve the readability of this method for the benefit of future maintainers...

Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

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

[posting my comment from earlier I couldn't due to GH 500s]

so the following situation can occur:

successful message A
failed message B (e.g. failed from previous session)
successful message C
failed message D

it seems like with this change we’d have items appearing out of order, i.e. A, C, B, D, when we should have A, B, C, D

Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

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

just leaving a couple comments before i see if this fixes the issue with reordering replies after one fails

@@ -1776,7 +1776,8 @@ def __init__(
message_failed_signal.connect(self._on_reply_failure)

# Set styles
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this comment seems out of place (i know this wasn't introduced by your code but just noticed it above your new lines of code and was like, this isn't setting styles!)

for index, conversation_item in enumerate(collection):
item_widget = current_conversation.get(conversation_item.uuid)
if item_widget:
current_conversation.pop(conversation_item.uuid)
if item_widget.index != index:
if isinstance(item_widget, ReplyWidget) and item_widget.reply_status != "SUCCEEDED":
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this if-elif block doesn't cover the case for reply widgets that are successful where item_widget.index == index

Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

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

this is what i see when running though STR#2 from #653:

reordering-replies

which looks like the behavior you described where non-successful replies are pushed to the bottom?

@ntoll
Copy link
Contributor Author

ntoll commented Feb 27, 2020

The TL;DR from my re-reading of my changes and your feedback and commentary (many thanks for that!), is that the code is confusing (ripe for refactoring). If it were not so confusing, we'd know what's going on. ;-)

A quick check tells me that @redshiftzero is correct in saying that the conversation ordering is handled elsewhere (see #653 (comment)) so we should always display the conversation in the current order as found from local storage. The obvious solution is just to re-draw the conversation, but this was one aspect of the cause of the UI freeze with lots of sources -- hence the desire to re-order the widgets in place. I believe my changes in this PR just add unnecessary complexity to an already complicated and often-re-written piece of code.

We have two things that are ordered:

  • The collection of conversation items, from local storage.
  • The widgets held in the conversation_view object.

We've obviously not catered for all possible re-ordering of existing widgets, or "slotting in" of new widgets into the conversation_view given the source-of-truth conversation passed into update_conversation. I'd like (tomorrow) to refactor this method so it's clear we have all cases covered.

It also appears that update_conversation is only called when the source being viewed is changed. The behaviour I observe (I just checked) is that the conversation IS updated even when the source isn't changed - so I'm not sure what's going on there.

@redshiftzero redshiftzero mentioned this pull request Feb 27, 2020
6 tasks
@redshiftzero
Copy link
Contributor

After further investigation it appears that this was actually due to the ordering in source.collection, and the widgets in the conversation view were correctly reflecting the state of the database (see: #653 (comment)).

It also appears that update_conversation is only called when the source being viewed is changed. The behaviour I observe (I just checked) is that the conversation IS updated even when the source isn't changed - so I'm not sure what's going on there.

Indeed - though reply widgets can be added to ConversationView outside of update_conversation via add_reply_from_reply_box (see related #834)

Gonna close this one for now, but feel free to open issues/wip for other improvements you think make sense to simplify ConversationView

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.

Replies are sometimes displayed out of order
3 participants