-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Conversation
I've rewritten the chat input from scratch with the minimal amount of functionality necessary (and with hooks because why not!). The only thing that works is sending messages with markdown in threads. And… it seems to be fine and doable! 👍 I estimate we can get the plaintext chat input with full functionality to a shippable state in 1-2 days. The thread editor would take a bit longer, I think we could get that ready to go in a week. Pros
Cons
I think we should do this given how many complaints we get about the text writing experience. What do you think @brianlovin? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the meat of the change right now is in chatInput/index.js
(https://github.com/withspectrum/spectrum/pull/4472/files#diff-f37f8727e3ee11c56ff3a6ae6894c358) but the diff is basically useless since I rewrote everything—it's probably easier to just look at the entire file without the diff!
@@ -38,7 +38,7 @@ | |||
"prettier": "^1.14.3", | |||
"raw-loader": "^0.5.1", | |||
"react-app-rewire-hot-loader": "^1.0.3", | |||
"react-hot-loader": "^4.3.11", | |||
"react-hot-loader": "^4.6.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to upgrade to get compatibility with react hooks
"react-apollo": "^2.3.2", | ||
"react-app-rewire-styled-components": "^3.0.0", | ||
"react-app-rewired": "^1.6.2", | ||
"react-clipboard.js": "^2.0.1", | ||
"react-dom": "16.4.2", | ||
"react-dom": "^16.7.0-alpha.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to upgrade to get react hooks
I'm going to go ahead and try to get some more functionality in, let's see how this scales. |
Getting there, latest commits add quoted message and media message support. Todos before this is shippable
|
We should just transform the plaintext to draftjs in the optimistic response ;)
You know I'm all about doing this - let's go for it! Will jump in today and see if I can help. |
I know but this isn't as easy as it sounds without shipping a lot more code on the frontend, which I'd like to avoid. |
We could render the optimistic response at ~70% opacity to indicate it's in a processing state? |
Yeah I think that'd be a good enough solution for now! |
How much does it add to the bundle to transform the plaintext to draftjs in the optimistic response? This outcome feels a bit janky especially on slow networks. This direction feels super good though as far as simplicity of the input!!
Brian
…________________________________
From: Max Stoiber <notifications@github.com>
Sent: Sunday, December 16, 2018 11:56 PM
To: withspectrum/spectrum
Cc: Brian Lovin; Mention
Subject: Re: [withspectrum/spectrum] Spike plaintext chatinput (#4472)
Latest commit makes optimistic responses 0.7 opacity, looks like this:
[optimistic-responses]<https://user-images.githubusercontent.com/7525670/50073621-73922780-01d9-11e9-9fda-b417bc57565d.gif>
Is that acceptable from a UX perspective?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#4472 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AB1YvDeAwTqyUXFyaJdREUfDj77j4F-Mks5u504RgaJpZM4ZTOMZ>.
|
The one we use on the backend is 32.5kB—that's a lot. 😕 The underlying issue is that we'd have to ship a markdown parser to the frontend, which is never cheap, even though we don't really even need all of markdown for messages. I'll see if I can find something or whip something up that'll only handle inline styles and code blocks… |
🙏🙏
Brian
…________________________________
From: Max Stoiber <notifications@github.com>
Sent: Monday, December 17, 2018 12:04:12 AM
To: withspectrum/spectrum
Cc: Brian Lovin; Mention
Subject: Re: [withspectrum/spectrum] Spike plaintext chatinput (#4472)
The one we use on the backend is 32.5kB<https://bundlephobia.com/result?p=markdown-draft-js@1.3.1>—that's a lot. 😕 The underlying issue is that we'd have to ship a markdown parser to the frontend, which is never cheap, even though we don't really even need all of markdown for messages. I'll see if I can find something or whip something up that'll only handle inline styles and code blocks…
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#4472 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AB1YvImJH66_EHwUVouWK1G_ZYmAkAh8ks5u50_8gaJpZM4ZTOMZ>.
|
Found the Latest commit uses that to richly render optimistic responses on the frontend, works great as far as I can tell! Maybe we should switch to using that one on the backend too for compatibility 🤔 |
Not sure, I'll let you make that call. 8kb sucks, but I know we've been meaning to do some bundle cleanup anyways at some point, I'm sure we're shipping something dumb that we could cut to neutralize the 8kb :P |
Geeeez look at this @brianlovin: 2e9d461 Basically, we need almost no code to do the local storage persistence since 1. nothing can crash anymore now that we only store plain text and 2. React hooks are epic. This also works better than before since it keys by the thread ID in localStorage, meaning if you switch between threads it'll show the cached/uncached content! 😍 The only thing I removed was the expiry of cached content—since it's now keyed by the thread there's really no reason to expire anymore. |
There is a bug where you can't create a new DM thread with both an image and some text in the message, but that bug is generally around so I won't fix it since it'd require a bit of a backend refactor which I'd like to avoid. I'll log it in a new issue. |
I honestly don't really know how to solve single line break paragraphs. @sstur how hard would it be to get support for that into draft-js-import/export-markdown? |
Whoops! Thanks for the extra details :)
Only short-term workaround I could think of would be to convert from a 'chat input' style input to a 'comment textarea' style; if it looks like a comment box where 'enter' doesn't send the message by default, we could better explain that it behaves the same way as any other markdown document. |
@brianlovin Those screencaps are super helpful! @mxstbr I do believe that is the spec-compliant behavior for Markdown (I use the term "spec" loosely ; ) However I do believe the "Github Flavored Markdown" variant changes that behavior. It considers a single line break as a I'd be happy to support both behaviors, in fact, it might already be an option baked in to the underlying markdown parser we use. Edit: I forget we forked that library instead of importing it, can't remember the reason off the top of my head. Edit 2: The parsing library does indeed support github flavored markdown including the linebreaks feature however draft-js-import-markdown is not passing those options through. I made a PR if you want to take a look. |
Latest commit makes single line breaks work, so this is ready for another code review @brianlovin!! 🎉 Thanks @sstur for the quick help, appreciated |
Gah, @mxstbr this is SO close!!! Sorry I just found this one: editing a code block doesn't transfer the code block into the edit message input: https://www.dropbox.com/s/q2iv1z7bb205uv5/Kapture%202019-01-10%20at%2018.24.24.gif?dl=0 |
It does! Code blocks in markdown can be written with four spaces in front of the code (like on StackOverflow), only GitHub-flavoured markdown added support for fenced code blocks—so what you're seeing there is a code block. @sstur how hard would it be to add a GFM mode to |
@mxstbr, I think this is not too hard. Probably something like this: Such an option will solve your immediate problem, but I'd venture to say there's a larger underlying issue which I'd describe as follows: Many different markdown representations can produce a single visual output (such as extraneous newlines, different formats for (a) italic (b) italic and (a) bold (b) bold (need to view this source to see the difference there) as well as code blocks and probably more. Same is true for many markup formats such as HTML where If I am understanding your implementation, that information is lost in a round trip to DraftJS model and back to markdown. Maybe this is not a big deal, if your intent is to normalize the user's input into some well-formed canonical representation (like what Prettier does for my code). But, this may seem quirky to the user in the context of composing messages. You might consider doing what Github does, which is store the original text the user typed, either in addition to or in place of the parsed model. For Github, you can see that by typing some text in a comment here, then going back to edit it. Your original text will always populate the editor, even if you forgot to close a code block. I believe it's the same in chat programs (can verify with Hangouts Chat, although defo don't base your design choices on that product 😂). Thoughts? |
I generally 100% agree and I'd love to do it that way, but in our situation right now it's not feasible to spend that much time on engineering a perfect editing experience—it just has to be good enough™️! |
The |
Perfect, thank you so much @sstur! Latest commit upgrades to that version 💪 @brianlovin this is ready for another review. Going to branch off of this and start work on the plaintext editor! |
Deploying to alpha! |
Deployed to alpha, feels pretty good 😎 I think we should alias this to prod! |
This is live in production, and I've also posted release notes! 🎉 https://spectrum.chat/spectrum/general/spectrum-v2-6-0-a-brand-new-chat-input~84352ff4-9feb-4cce-ab05-575617ad5176 |
@mxstbr I saw a handful of logs come in that indicate we might not be properly handling the backend supporting old draftjs messages being sent. Did you see these? |
Status
Deploy after merge (delete what needn't be deployed)
Testing whether switching to a plaintext editing experience could be viable.