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

Save creation time of message in ChatMessage #12570

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Szpoti
Copy link
Collaborator

@Szpoti Szpoti commented Feb 28, 2024

Partially fixes #12429

This is only business code. The time of creation now gets saved in the ChatMessage object, for both user and agent messages, but it's not visible anywhere, that will be a UI task. @zkSNACKs/ui-team

What happened:

  • Moved ParseRawMessage from AssistantViewModel and moved it to the base, MessageViewModel.
  • This saves us from code duplication and will solve removing the ugly timestamp from every message.
  • From some places I removed the setting of UiMessage, as now it's handled in the base class.
  • Only exception is the OfferMessageViewModel, where it has to be overwritten.
  • Added a small logic in WorkflowStep.EditMessageAsync so the timestamp from the raw text doesn't disappear.
  • Expanded the ChatMessage record, so it reads DateTime from the Unix timestamp of the message.

Comment on lines +171 to +173
var timestamp = GetTimestampFromMessage(chatMessage);

newMessage = newMessage with { Text = timestamp + userMessage };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
var timestamp = GetTimestampFromMessage(chatMessage);
newMessage = newMessage with { Text = timestamp + userMessage };
newMessage = newMessage with { Text = GetTimestampFromMessage(chatMessage) + userMessage };

Since we don't do any checks on timestamp, maybe we could simplify this. WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, but I like my version slightly better for readability.

WalletWasabi/BuyAnything/ChatMessage.cs Outdated Show resolved Hide resolved
Copy link
Collaborator

@soosr soosr left a comment

Choose a reason for hiding this comment

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

Sorry for the late comment, taking a look at the problem now I think it should be the following (Although this is just my opinion, a final decision is @molnard's):

  1. Whenever we receive the raw string from SIB, during parsing it should also parse the time stamps and store it in ChatMessage's property, and store the message text without the @xxxxxx@ part.
  2. The UI should not deal with parsing (For the release it was fine, but now we could do it properly) that is the business side's responsibility.
  3. The UI, when adds a new message, should just set the timestamp property in ChatMessage.
  4. When we send back the whole conversation, the business side should form it properly back to a raw string (get the timestamp from the property and paste in front of the message text in the correct format).

@molnard molnard marked this pull request as draft March 5, 2024 09:48
@molnard molnard removed their request for review April 2, 2024 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[UI] [Buy Anything Button] see date/time of a message
3 participants