downforacross / downforacross.com

Web frontend for downforacross.com -- continuation of stevenhao/crosswordsio
https://downforacrosscom.downforacross1.now.sh
MIT License
220 stars 92 forks source link

Sweep: automatically detect weird encoding and render it correctly when displaying clues (testing) #278

Open stevenhao opened 12 months ago

stevenhao commented 12 months ago

currently some clues render as Très instead of Très or vis-à -vis instead of vis-à-vis. Can you fix it?

sweep-ai[bot] commented 12 months ago

Here's the PR! https://github.com/downforacross/downforacross.com/pull/282.

⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 5 GPT-4 tickets left. For more GPT-4 tickets, visit our payment portal.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/downforacross/downforacross.com/blob/0ddba04a486d8cc4424c49464707d0077c80bf15/src/lib/emojiPacks/default.js#L1-L291 https://github.com/downforacross/downforacross.com/blob/0ddba04a486d8cc4424c49464707d0077c80bf15/src/components/Player/ClueText.js#L1-L44 https://github.com/downforacross/downforacross.com/blob/0ddba04a486d8cc4424c49464707d0077c80bf15/src/components/Toolbar/index.js#L290-L368 https://github.com/downforacross/downforacross.com/blob/0ddba04a486d8cc4424c49464707d0077c80bf15/src/lib/emojiPacks/default.js#L586-L726 https://github.com/downforacross/downforacross.com/blob/0ddba04a486d8cc4424c49464707d0077c80bf15/src/components/Chat/ChatBar.js#L42-L136

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
src/components/Player/ClueText.js Modify the decodeHtml function to correctly decode special characters. Replace the current implementation with the following:
```javascript
function decodeHtml(htmlText) {
let text = document.createElement("textarea");
text.innerHTML = htmlText;
return decodeURIComponent(escape(text.value));
}
`` Add tests for thedecodeHtml` function to ensure that it correctly decodes special characters. For example:
```javascript
test('decodeHtml', () => {
expect(decodeHtml('Très')).toBe('Très');
expect(decodeHtml('vis-Ã -vis')).toBe('vis-à-vis');
});
```

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Fix encoding issue in ClueText component sweep/fix-encoding-issue

Description

This PR fixes the encoding issue in the ClueText component by updating the decodeHtml function to correctly decode special characters.

Changes Made

  • Modified the decodeHtml function in src/components/Player/ClueText.js to use decodeURIComponent and escape functions for decoding.
  • Added tests for the decodeHtml function to ensure correct decoding of special characters.

Testing

  • Added tests for the decodeHtml function to ensure correct decoding of special characters.

Related Issue

Issue #278

Checklist

  • [ ] Tested the changes locally
  • [ ] Added/updated tests
  • [ ] Updated the documentation (if necessary)
  • [ ] Verified the coding style
  • [ ] Assigned the PR to myself

Step 4: ⌨️ Coding

I have finished coding the issue. I am now reviewing it for completeness.


Step 5: 🔁 Code Review

Success! 🚀


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind! Join Our Discord

sweep-ai[bot] commented 12 months ago

Here's the PR! https://github.com/downforacross/downforacross.com/pull/280


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze this snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/downforacross/downforacross.com/blob/0ddba04a486d8cc4424c49464707d0077c80bf15/src/components/Toolbar/index.js#L170-L383 https://github.com/downforacross/downforacross.com/blob/0ddba04a486d8cc4424c49464707d0077c80bf15/src/components/Player/ClueText.js#L1-L44 https://github.com/downforacross/downforacross.com/blob/0ddba04a486d8cc4424c49464707d0077c80bf15/src/lib/emojiPacks/default.js#L1-L240 https://github.com/downforacross/downforacross.com/blob/0ddba04a486d8cc4424c49464707d0077c80bf15/src/components/Chat/Chat.js#L204-L359 https://github.com/downforacross/downforacross.com/blob/0ddba04a486d8cc4424c49464707d0077c80bf15/src/components/Chat/ChatBar.js#L27-L136

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
src/components/Player/ClueText.js Update the decodeHtml function to correctly handle special characters. This could involve using a different method to decode HTML entities, or adding additional handling for special characters.
src/components/Chat/Chat.js Update the renderMessageText function to correctly render special characters. This could involve adding additional handling for special characters, or ensuring that the text is being correctly decoded before it's rendered.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working on executing my plan and coding the required changes to address this issue. Here is the planned pull request:

Fix Special Character Rendering in Clues and Chat sweep/fix-special-char-rendering

This PR addresses the issue of special characters not being rendered correctly in clues and chat messages.

The changes made are as follows:

  • Updated the decodeHtml function in src/components/Player/ClueText.js to correctly handle special characters. This involved using a different method to decode HTML entities and adding additional handling for special characters.
  • Updated the renderMessageText function in src/components/Chat/Chat.js to correctly render special characters. This involved adding additional handling for special characters and ensuring that the text is being correctly decoded before it's rendered.

These changes should ensure that special characters like "Très" and "vis-à-vis" are displayed correctly in both clues and chat messages.


Step 4: ⌨️ Coding

I have finished coding the issue. I am now reviewing it for completeness.


Step 5: 🔁 Code Review

Success! 🚀


I'm a bot that handles simple bugs and feature requests but I might make mistakes. Please be kind! Join Our Discord

kevinlu1248 commented 11 months ago

Hey @stevenhao we made drastic changes since two weeks ago, especially around planning and decision-making.

kevinlu1248 commented 11 months ago

sweep: Retry

stevenhao commented 11 months ago

hey @kevinlu1248 the result is much better! i'm impressed :)

kevinlu1248 commented 11 months ago

Happy to hear! Feel free to keep experimenting and ping us at https://discord.gg/sweep-ai if you have questions or something breaks.