<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Roy J. Wignarajah</title>
    <description>The latest articles on DEV Community by Roy J. Wignarajah (@rjwignar).</description>
    <link>https://dev.to/rjwignar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1158846%2Fe3320609-671b-409a-a0ab-24e70c0e06de.png</url>
      <title>DEV Community: Roy J. Wignarajah</title>
      <link>https://dev.to/rjwignar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rjwignar"/>
    <language>en</language>
    <item>
      <title>ChatCraft Advenures #14: ChakraUI Troubles, My First Revert, and Final Recap</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sat, 20 Apr 2024 01:53:55 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-advenures-14-chakraui-troubles-my-first-revert-and-final-recap-1iko</link>
      <guid>https://dev.to/rjwignar/chatcraft-advenures-14-chakraui-troubles-my-first-revert-and-final-recap-1iko</guid>
      <description>&lt;h1&gt;
  
  
  ChatCraft Release 2.0
&lt;/h1&gt;

&lt;p&gt;ChatCraft Release 2.0 is available &lt;a href="https://github.com/tarasglek/chatcraft.org/releases/tag/v2.0.0" rel="noopener noreferrer"&gt;here&lt;/a&gt;. It was a pleasure working with everyone during this semester. It's amazing to see how many new features, enhancements, and bugfixes have been added with each weekly milestone. I encourage everyone reading to check out &lt;a href="https://chatcraft.org/" rel="noopener noreferrer"&gt;ChatCraft&lt;/a&gt; yourself if you haven't already. No API key is required! You can use &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/498" rel="noopener noreferrer"&gt;free providers on ChatCraft&lt;/a&gt; today!&lt;/p&gt;

&lt;h1&gt;
  
  
  Pull Requests
&lt;/h1&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/595" rel="noopener noreferrer"&gt;My first code reversion&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;In last week's &lt;a href="https://dev.to/rjwignar/chatcraft-adventures-13-ui-changes-3jig"&gt;blog post&lt;/a&gt;, I wrote about a &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/577" rel="noopener noreferrer"&gt;Pull Request&lt;/a&gt; I made to fix a &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/569" rel="noopener noreferrer"&gt;toast error bug on ChatCraft mobile&lt;/a&gt;. It turns out my code in that PR introduced a number of bugs described in &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/586" rel="noopener noreferrer"&gt;this Issue&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/593" rel="noopener noreferrer"&gt;initially tried adding new code to fix this Issue&lt;/a&gt;, but there were a number of bugs my code introduced, so I figured the best move was to revert the commit.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to revert a commit
&lt;/h3&gt;

&lt;p&gt;You can revert a commit in two ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;from the GitHub UI&lt;/li&gt;
&lt;li&gt;from the command line&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Reverting a commit from the GitHub UI is straight-forward, and is what I ended up doing. However, my class instructor, &lt;a href="https://github.com/humphd" rel="noopener noreferrer"&gt;Dave&lt;/a&gt;, taught me how to do it from the command line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout main
git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; &amp;lt;topic-branch-name&amp;gt;
git revert &amp;lt;git-sha&amp;gt;
git push origin &amp;lt;topic-branch-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then make a Pull Request for &lt;code&gt;&amp;lt;topic-branch-name&amp;gt;&lt;/code&gt;, noting that it's a &lt;strong&gt;Revert&lt;/strong&gt; PR along with an explanation.&lt;/p&gt;

&lt;p&gt;The reversion is done in &lt;a href="https://git-scm.com/docs/git-revert" rel="noopener noreferrer"&gt;git revert&lt;/a&gt;, which inverses a commit's diff:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;removes&lt;/strong&gt; &lt;em&gt;added&lt;/em&gt; lines&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;adds&lt;/strong&gt; &lt;em&gt;removed&lt;/em&gt; lines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Doing this from a topic branch (non-main branch) isn't necessary but it is strongly recommended. This is because while projects will let you land changes directly on the main branch, doing so will often skip any CI (Continuous Integration).&lt;/p&gt;

&lt;p&gt;My reversion was simple, but I think that's because of a few reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;my changes were small (affected only 1 file)&lt;/li&gt;
&lt;li&gt;my PR commit(s) was/were squashed into one commit&lt;/li&gt;
&lt;li&gt;the reversion was made before additional changes to the file were made&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have a feeling that if any of these things were not the case, I would have had a harder time reverting my changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Backing out a change
&lt;/h3&gt;

&lt;p&gt;This is the first time I've reverted code from a project. Dave tells me that in software projects, this is often referred to as "backing out a change". It sounds a lot more strategic than "reverting a PR", but I think that's because it really is. If the code remained, ChatCraft would produce a lot of bugs in production, and would affect users and developers. In fact, it was better to revert the code now than later when new code is added to the file.&lt;/p&gt;

&lt;p&gt;Reverting a commit is not the end of the world. You can always re-implement a fix or feature later, which is what I ended up doing. Just don't forget to provide an explanation for the revert in your PR, and don't forget to re-open any issues that the revert will affect.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/601" rel="noopener noreferrer"&gt;Add mobile-specific error toast custom width&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;This is a version of &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/577" rel="noopener noreferrer"&gt;my original implementation&lt;/a&gt; that doesn't introduce any of the &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/586" rel="noopener noreferrer"&gt;bugs the original introduced&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It's essentially the same code I initially added, a custom containerStyle property for &lt;a href="https://v2.chakra-ui.com/docs/components/toast" rel="noopener noreferrer"&gt;ChakraUI's Toast component&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;    &lt;span class="nx"&gt;containerStyle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;isMobile&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;90vw&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;initial&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Location, location, location
&lt;/h3&gt;

&lt;p&gt;Here's what that code looked like in my &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/577/files" rel="noopener noreferrer"&gt;initial PR&lt;/a&gt; (introduced bugs):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;useAlert&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;isMobile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMobileBreakpoint&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useToast&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;containerStyle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;isMobile&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;90vw&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;initial&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here's how that code looks in my &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/601/files" rel="noopener noreferrer"&gt;new PR&lt;/a&gt; (no bugs introduced):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;AlertArguments&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
      &lt;span class="nf"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="c1"&gt;// ...&lt;/span&gt;
        &lt;span class="na"&gt;containerStyle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;isMobile&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;90vw&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;initial&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;}),&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isMobile&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;useToast()&lt;/strong&gt; vs &lt;strong&gt;toast()&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In the &lt;a href="https://github.com/tarasglek/chatcraft.org/blob/73da47cf8d7023d2645ec7cb702c8a1b69dbe809/src/hooks/use-alert.ts" rel="noopener noreferrer"&gt;use-alert.ts&lt;/a&gt; file, the properties for each toast message (info, error, success, warning) is defined in their individual &lt;code&gt;useCallback&lt;/code&gt;'s. In my original PR, I added the containerStyle code to the &lt;strong&gt;useToast()&lt;/strong&gt; call instead because I wanted to avoid duplicate code. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I haven't figured out why&lt;/strong&gt;, but adding the containerStyle code in the &lt;strong&gt;useToast()&lt;/strong&gt; call introduced various bugs, while adding it in the &lt;strong&gt;toast()&lt;/strong&gt; call within the &lt;code&gt;error&lt;/code&gt; &lt;strong&gt;useCallback&lt;/strong&gt; didn't introduce any bugs.&lt;/p&gt;

&lt;p&gt;I hope any &lt;a href="https://v2.chakra-ui.com/" rel="noopener noreferrer"&gt;ChakraUI&lt;/a&gt; experts reading can help me understand what's happening.&lt;/p&gt;

&lt;h1&gt;
  
  
  Issues
&lt;/h1&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/605" rel="noopener noreferrer"&gt;/import fails on YouTube videos with no captions&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;ChatCraft has a cool &lt;strong&gt;/import&lt;/strong&gt; command, which will take a URL and import text. One way you can use the &lt;strong&gt;/import&lt;/strong&gt; command is to use it with a YouTube video URL, and if the video has captions, ChatCraft will return the captions in a message:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7c32snocef6plx8fev56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7c32snocef6plx8fev56.png" alt="Image description" width="800" height="787"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chatcraft.org/api/share/rjwignar/DpM9a1q9FdvTRvWLaM1A2" rel="noopener noreferrer"&gt;Shared Chat Available here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, I once tried it with a music video with no lyrics, like &lt;a href="https://www.youtube.com/watch?v=TKfS5zVfGBc" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=TKfS5zVfGBc&lt;/a&gt; and saw this error toast:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feoxc20re2bdkop1qtx8o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feoxc20re2bdkop1qtx8o.png" alt="Image description" width="558" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When testing the command locally, I found this error in the backend:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvoypmlrufwgzr1akdqbw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvoypmlrufwgzr1akdqbw.png" alt="Image description" width="800" height="55"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I found a similar error when trying the &lt;strong&gt;/import&lt;/strong&gt; command on another music video with non-English captions available:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7nuxxxx5f9eivxusjcen.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7nuxxxx5f9eivxusjcen.png" alt="Image description" width="800" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we know what the issues are, I think I can make error toast message more descriptive for these edge cases.&lt;/p&gt;

&lt;h1&gt;
  
  
  OSD700 Recap
&lt;/h1&gt;

&lt;p&gt;Below is a recap of my experience working on ChatCraft and my experience taking OSD700 at Seneca Polytechnic (formerly Seneca College) this semester.&lt;/p&gt;

&lt;h2&gt;
  
  
  Comparison to Previous Open Source Work
&lt;/h2&gt;

&lt;p&gt;Having finished this course, I noticed a number of differences between my past open source work and contributing to ChatCraft. Some of these are differences in experience, while others are things unique to ChatCraft or unique to my open source class.&lt;/p&gt;

&lt;h3&gt;
  
  
  1-2 PRs in other projects vs multiple PRs in ChatCraft
&lt;/h3&gt;

&lt;p&gt;In my previous open source class, I made 1-2 Pull Requests to various open source projects. Though I was able to contribute code, my understanding of these codebases was limited to the pieces of code I worked on.&lt;/p&gt;

&lt;p&gt;In this class, I devoted all of my attention to ChatCraft, and understood more of the codebase by making multiple contributions. Of course, I don't completely understand the entire codebase. There are still many parts of the codebase I either haven't read or don't understand. However, I noticed that by focusing on one project, I naturally read various parts of the code to understand the code I would modify or build upon.&lt;/p&gt;

&lt;h3&gt;
  
  
  Working on an active project
&lt;/h3&gt;

&lt;p&gt;With my classmates, Dave, and ChatCraft creator &lt;a href="https://github.com/tarasglek" rel="noopener noreferrer"&gt;Taras&lt;/a&gt; also working on ChatCraft, the project became very active, with multiple Pull Requests being made every week. Reviewing Pull Requests was not only another opportunity to read various parts of the codebase, but also an exercise in reading new code. &lt;/p&gt;

&lt;p&gt;I found working on such an active project to be a fun experience.&lt;br&gt;
In our last triage meeting, my Dave mentioned how much of a difference it makes to work on an active project. A project with lots of activity gives out a certain kind of energy that encourages people to use and even contribute to the project. There's always new code being added, and the community around the project grows. &lt;/p&gt;

&lt;p&gt;I noticed this when working on ChatCraft this semester. With each milestone new features were added that improved the app. As the weeks went by our work attracted more users, and by the end of the semester, developers outside the course began contributing to ChatCraft as well.&lt;/p&gt;

&lt;h3&gt;
  
  
  Instant vs. non-instant communication
&lt;/h3&gt;

&lt;p&gt;In past projects I've contributed to, the best way to contact the maintainers was often through GitHub, which is non-instant. For ChatCraft, we've been using Discord - an instant messaging app -  alongside GitHub. GitHub was still the primary method of communication when reading issues or making/reviewing Pull Requests, but having instant messaging available, through Discord or otherwise, turned out to be a reliable way to reach out to colleagues.&lt;/p&gt;

&lt;h3&gt;
  
  
  Triage meetings
&lt;/h3&gt;

&lt;p&gt;This is something unique to my open-source class. Every week, the class ran a triage meeting where we discussed showstopper issues/features, confirmed details on sprint/milestone deadlines and feasibility, and made plans for the next sprint/milestone. These meetings would take the entire class time (~2 hours) but in that time we solved a lot of things logistically.&lt;/p&gt;

&lt;p&gt;Just over a year ago, I did a co-op placement (internship) in the IT space, albeit in a non-developer role. I remember having daily standup meetings for certain projects, but I don't remember feeling very accomplished during those meetings. Maybe I'd have a different experience as a full-timer, but based on my experience attending triage meetings I think that longer, weekly meetings would be more meaningful than multiple shorter meetings throughout the week.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sheriff duty
&lt;/h3&gt;

&lt;p&gt;During this semester I was also a 'Code Sheriff' for a couple weeks. I've described my first Sheriff experience in &lt;a href="https://dev.to/rjwignar/chatcraft-adventures-4-50o7"&gt;this blog post&lt;/a&gt;, but overall I thought it was a fun leadership experience. In my experience, being a code sheriff didn't mean being an 'on-call' who works on every issue or reviews every pull request (though it's good to provide a review when needed). It just meant helping shepherd new code into the project by providing a resource (e.g, finding reviewers for a Pull Request, putting classmates in contact with someone who can help them with a feature or technology).&lt;/p&gt;

&lt;h3&gt;
  
  
  Secrets management using &lt;a href="https://github.com/getsops/sops" rel="noopener noreferrer"&gt;sops&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;One thing unique to working on ChatCraft was how we managed secrets (mostly API keys). &lt;a href="https://github.com/tarasglek/chatcraft.org/blob/main/README.sops.md" rel="noopener noreferrer"&gt;ChatCraft uses sops to share secrets&lt;/a&gt;, and getting access to secrets was a fun experience I wrote about in &lt;a href="https://dev.to/rjwignar/more-adventures-in-open-source-development-chatcraft-1f39"&gt;this blog post&lt;/a&gt;. There's still a lot I need to learn about sops, but once I figure out enough I'd like to implement it in my own projects!&lt;/p&gt;

&lt;h2&gt;
  
  
  My contributions
&lt;/h2&gt;

&lt;p&gt;When I started working on ChatCraft, I wasn't very confident in my web development skills. I took web development courses in school but the concepts didn't stick well. I just enjoyed writing programs in C++ and writing scripts. Because of this, I devoted most of my focus to making bug fixes and enhancements to various parts of the codebase.&lt;/p&gt;

&lt;p&gt;I found that with each enhancement or bug fix I did, I understood more of the codebase, and by the third month I was able to add a couple new features. I've listed all of my bug fixes, enhancements, and features below:&lt;/p&gt;

&lt;h3&gt;
  
  
  Bug Fixes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/529" rel="noopener noreferrer"&gt;Vite Config - Provide Null navigateFallback URL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/567" rel="noopener noreferrer"&gt;Update Slash Command Criteria&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/506" rel="noopener noreferrer"&gt;Fix Shared Chat Accessibility from UI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/408" rel="noopener noreferrer"&gt;Fix iframe auto-resize&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/376" rel="noopener noreferrer"&gt;Fix margin between HTML preview button and content&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Enhancements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/375" rel="noopener noreferrer"&gt;Don't show hints when editing on mobile&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/459" rel="noopener noreferrer"&gt;Add Twitter Card metadata to shared chats&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/448" rel="noopener noreferrer"&gt;Search bar placeholder text&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/601" rel="noopener noreferrer"&gt;Custom width for error toasts on mobile&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/579" rel="noopener noreferrer"&gt;Add Eye ReactIcons to API Key field&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/482" rel="noopener noreferrer"&gt;Update ChatCraft System Prompt for inline KaTeX&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/527" rel="noopener noreferrer"&gt;'/' Keyboard Shortcut&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/526" rel="noopener noreferrer"&gt;Add Nomnoml Renderer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Packaged &lt;a href="https://github.com/tarasglek/github-to-sops" rel="noopener noreferrer"&gt;github-to-sops&lt;/a&gt; to &lt;a href="https://pypi.org/project/github-to-sops/" rel="noopener noreferrer"&gt;PyPI&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Regrets
&lt;/h3&gt;

&lt;p&gt;One regret I have is that I didn't take more risk by trying to implement more features. When doing this course I played it safe and mostly contributed to bug fixes and code enhancements. There were some features at the time that I wanted to implement, but I wasn't confident enough to try because I didn't feel familiar enough with the codebase. It was only until halfway through the semester that I felt confident enough to implement larger features, but by then, there weren't enough weeks to fully flesh out a larger feature.&lt;/p&gt;

&lt;p&gt;I try not to compare myself to others, but when I look at all the cool features my classmates added, I can't help but feel I should have tried adding at least a couple larger features, instead of seeking comfort in small bugfixes and enhancements. As someone still learning web development, I'm nonetheless proud of the work I did. However, in the future I want to be less risk-averse when it comes to implementing larger features.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I used ChatCraft
&lt;/h2&gt;

&lt;p&gt;Throughout the course, I mainly used ChatCraft to help me develop ChatCraft. I've listed three use cases, with shared chats, demonstrating how I've used ChatCraft for various aspects of ChatCraft development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://chatcraft.org/c/rjwignar/HKR_-4W4BJpqqNzL8-GBr" rel="noopener noreferrer"&gt;Fixing Syntax Errors&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;I'm still re-learning React Hooks, and the syntax often eludes me. Here I used ChatCraft to help me wrap part of a &lt;a href="https://react.dev/reference/react/useCallback" rel="noopener noreferrer"&gt;useCallBack&lt;/a&gt; in an &lt;code&gt;if&lt;/code&gt; conditional. &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;a href="https://chatcraft.org/c/rjwignar/oOes55CNAXukfvwrofjxL" rel="noopener noreferrer"&gt;Finding Enhancements&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In an enhancement I made for the search bar, I used ChatCraft's image input feature to send a picture of the ChatCraft search bar to OpenAI's &lt;a href="https://platform.openai.com/docs/guides/vision" rel="noopener noreferrer"&gt;gpt-4-vision-preview&lt;/a&gt; model for suggestions on improving the search bar's visibility. For this use case, I even modified the System Prompt to tell the LLM it's an expert in UX/UI design:
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpa3ix7rgz1gc5c2gq80m.png" alt="Image description" width="472" height="186"&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;a href="https://chatcraft.org/c/rjwignar/u24TDFXzFFn2KrLx53rYB" rel="noopener noreferrer"&gt;Reviewing Pull Requests&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In this example, I have a shared chat I made when reviewing the UI changes of the Image Input feature.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;I've also used ChatCraft to help me learn how to integrate the &lt;a href="https://platform.openai.com/docs/introduction" rel="noopener noreferrer"&gt;OpenAI API&lt;/a&gt; with the frontend of a class project I'm working on. I'll even be using ChatCraft to help me develop future projects. &lt;/p&gt;

&lt;p&gt;With all the new features added, there are a bunch more clever ways you can use ChatCraft. I highly encourage those reading to use &lt;a href="https://chatcraft.org/" rel="noopener noreferrer"&gt;ChatCraft&lt;/a&gt; today!&lt;/p&gt;

&lt;h2&gt;
  
  
  My thoughts on OSD700 (Open Source Development II)
&lt;/h2&gt;

&lt;p&gt;OSD700 is course I've been contributing to ChatCraft for, and it's is one of the best courses I've taken, if not the best course in Computer Programming and Analysis at Seneca. The previous courses I've taken in this program gave me the foundation needed to work on ChatCraft, but those courses weren't exciting, and I just wasn't motivated to keep learning. In this course we were given the freedom to help build an actual project that people use, and the tools to figure out how to do it. Before taking the Open Source classes, I wasn't confident enough in my skills to contribute anything. However, after taking OSD600 and OSD700 I've become confident enough to contribute code. Even if there's something I can't fix or implement, I know I'll always be able to find where I can learn something, or find someone who can help. In fact, taking this course has motivated me to give web development another try.&lt;/p&gt;

&lt;h3&gt;
  
  
  By a stroke of luck
&lt;/h3&gt;

&lt;p&gt;I originally wasn't supposed to take the open source classes.&lt;br&gt;
When I wanted to enroll for the first open source class in Fall, it was full. However, during the first week of that semester I kept looking for open spots, and on a Saturday morning I found an open spot. It was by a stroke of luck I was able to take the open source classes. &lt;/p&gt;

&lt;p&gt;From these courses I learned/gained the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;proficiency with git&lt;/li&gt;
&lt;li&gt;how to write good issues and make good pull requests&lt;/li&gt;
&lt;li&gt;how to review pull requests&lt;/li&gt;
&lt;li&gt;the 'open source' workflow&lt;/li&gt;
&lt;li&gt;how to make good code contributions (adding to code vs. rewriting someone's code 'your way')&lt;/li&gt;
&lt;li&gt;the confidence to contribute to open source&lt;/li&gt;
&lt;li&gt;code reading skills (reading new codebases, reading new code someone's adding)&lt;/li&gt;
&lt;li&gt;the importance of blogging and building 'in the open'&lt;/li&gt;
&lt;li&gt;a newfound interest in web development&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I honestly believe I would be in a very different place, skill-wise, if I didn't take these courses.&lt;/p&gt;

&lt;p&gt;Though it's too soon to tell, I'm confident my experiences from these courses will make a lot of difference in my career and personal development. I'd like to thank &lt;a href="https://github.com/tarasglek" rel="noopener noreferrer"&gt;Taras&lt;/a&gt; for letting us contribute to ChatCraft, and &lt;a href="https://github.com/humphd" rel="noopener noreferrer"&gt;Dave&lt;/a&gt; for being a great instructor and mentor. I've learned a lot from working with you both on ChatCraft and related projects, and I hope to work with you in the future.&lt;/p&gt;

&lt;h1&gt;
  
  
  Next Steps
&lt;/h1&gt;

&lt;p&gt;With this blog post, I've finished my last course of the semester and the last semester of my studies. I'll be taking a short break, but after today I'll be on the hunt for software developer jobs. &lt;/p&gt;

&lt;p&gt;It's been a little over three years since I went back to school to study software development. Before then I studied to become a chemist, but a number of factors led me to pivot towards software development. Perhaps I can find a career that combines the two, but after my experience this semester, a career in web development sounds exciting.&lt;/p&gt;

&lt;h2&gt;
  
  
  ChatCraft
&lt;/h2&gt;

&lt;p&gt;As for ChatCraft, I have some Issues I want to close within the next month. I'll have to balance my work on ChatCraft with work on my own projects, my job search, and life, but I think I'll be able to contribute a little while longer. There are some personal projects I want to start working on after I've had some rest, and I think ChatCraft will be very helpful. &lt;/p&gt;

&lt;h2&gt;
  
  
  Thank you
&lt;/h2&gt;

&lt;p&gt;I think I'll also be blogging for just a while longer, be it about ChatCraft or other projects. Until then, thank you for reading. See you soon.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>ChatCraft Adventures #13, UI Changes</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sat, 13 Apr 2024 04:21:02 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-adventures-13-ui-changes-3jig</link>
      <guid>https://dev.to/rjwignar/chatcraft-adventures-13-ui-changes-3jig</guid>
      <description>&lt;p&gt;&lt;a href="https://chatcraft.org/" rel="noopener noreferrer"&gt;ChatCraft&lt;/a&gt; Release 1.9 is available &lt;a href="https://github.com/tarasglek/chatcraft.org/releases/tag/v1.9.0" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  ChatCraft Week 13 Recap
&lt;/h1&gt;

&lt;p&gt;This week, I worked on addressing more technical debt in ChatCraft. Here's the work I've done.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pull Requests
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/577" rel="noopener noreferrer"&gt;Adjust Toast Message Width for Mobile Experience&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This Pull Request fixes a bug my class instructor, Dave, &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/569" rel="noopener noreferrer"&gt;noticed when using ChatCraft on mobile&lt;/a&gt;:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F52p2521lm82lt1spcrlu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F52p2521lm82lt1spcrlu.png" alt="Image description" width="472" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this issue, error messages with a lot of text content are too wide on mobile. To ensure users are aware of any errors, ChatCraft error messages can only be closed manually by the user. However, on mobile, these error messages can be so wide that the close button is inaccessible.&lt;/p&gt;
&lt;h4&gt;
  
  
  Solution
&lt;/h4&gt;

&lt;p&gt;In a &lt;a href="https://dev.to/rjwignar/chatcraft-adventures-4-50o7"&gt;previous blog post&lt;/a&gt;, I described how I fixed a &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/289" rel="noopener noreferrer"&gt;similar issue&lt;/a&gt; by using the &lt;a href="https://github.com/tarasglek/chatcraft.org/blob/main/src/hooks/use-mobile-breakpoint.ts" rel="noopener noreferrer"&gt;useMediaQuery react hook&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In my Pull Request, I used the &lt;code&gt;useMobileBreakpoint()&lt;/code&gt; to define a different set of behaviours for Toast messages to follow when on mobile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import useMobileBreakpoint from "../hooks/use-mobile-breakpoint";

// ...

export function useAlert() {
  const isMobile = useMobileBreakpoint();
  const toast = useToast({
    containerStyle: {
      width: isMobile ? "90vw" : "initial",
    },
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ChatCraft uses the &lt;a href="https://v2.chakra-ui.com/" rel="noopener noreferrer"&gt;ChakraUI&lt;/a&gt; component library, and one of these components is the &lt;a href="https://v2.chakra-ui.com/docs/components/toast/usage" rel="noopener noreferrer"&gt;Toast component&lt;/a&gt; which provides user feedback using messages that pop up, as though coming out of a toaster:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhgrvcirq0ulei7gk2a2z.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhgrvcirq0ulei7gk2a2z.gif" alt="Image description" width="372" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Toast component has &lt;a href="https://v2.chakra-ui.com/docs/components/toast/props" rel="noopener noreferrer"&gt;props&lt;/a&gt;, or properties that can define custom behaviours. In this PR, I modify the &lt;code&gt;containerStyle&lt;/code&gt; prop depending on whether the user is on mobile (a device with a screen width &amp;lt;= 480px). If the user is on a mobile device, all toast messages will have a width that is 90% of the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Viewport_concepts" rel="noopener noreferrer"&gt;viewport's width&lt;/a&gt;. Otherwise, toast messages will retain their initial width. Before using the &lt;code&gt;initial&lt;/code&gt; value, I had trouble getting this PR to work. I have to thank my classmate &lt;a href="https://dev.to/amnish04"&gt;Amnish&lt;/a&gt; for this suggestion.&lt;/p&gt;

&lt;p&gt;Sometime after this PR was merged, my classmate, &lt;a href="https://dev.to/katiel"&gt;Katie&lt;/a&gt;, reported a &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/586" rel="noopener noreferrer"&gt;bug&lt;/a&gt; that traces back to this PR. I hope to investigate and solve this bug soon.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/579" rel="noopener noreferrer"&gt;Replaced Show/Hide button with Eye ReactIcons&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This Pull Request is a small enhancement of my Katie's feature that &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/530" rel="noopener noreferrer"&gt;adds support for Custom Providers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Previously, the Custom Providers menu controlled API key visibility using a Show/Hide button:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9p1difaae7wklmahju0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9p1difaae7wklmahju0.png" alt="Image description" width="590" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following feedback from Amnish, changing the Show/Hide button to eye &lt;a href="https://v2.chakra-ui.com/docs/components/icon-button/usage" rel="noopener noreferrer"&gt;IconButtons&lt;/a&gt; was a proposed enhancement.&lt;/p&gt;
&lt;h4&gt;
  
  
  Solution
&lt;/h4&gt;

&lt;p&gt;My solution implementation involved replacing the pre-existing Button component with an IconButton that uses eye icons:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;IconButton&lt;/span&gt;
          &lt;span class="na"&gt;variant&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"ghost"&lt;/span&gt;
          &lt;span class="na"&gt;h&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"1.75rem"&lt;/span&gt;
          &lt;span class="na"&gt;size&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;buttonSize&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;icon&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;show&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;IoMdEyeOff&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;IoMdEye&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setShow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;show&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;aria-label&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;show&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hide&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Show&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
          &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;show&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hide&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Show&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have to thank Amnish again for providing valuable help and feedback for this PR. As someone still learning a lot about web development, I appreciate the opportunity to work on this issue and to learn about new components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Issues
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/587" rel="noopener noreferrer"&gt;Re-asking Human message duplicates message&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This is a bug I noticed recently, when using ChatCraft to help me debug other code I'm working on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3b4kc321qw0h7jn4m93.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3b4kc321qw0h7jn4m93.gif" alt="Image description" width="1899" height="846"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I haven't been able to locate the bug yet but it produces funny results. I'm hoping to solve it for next Release.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/585" rel="noopener noreferrer"&gt;Add Markdown Renderer&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This is an Issue I opened up for a potential feature. A couple weeks ago, I added &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/526" rel="noopener noreferrer"&gt;nomnoml support&lt;/a&gt; to ChatCraft. ChatCraft renders previews for &lt;a href="https://mermaid.js.org/" rel="noopener noreferrer"&gt;Mermaid&lt;/a&gt; and &lt;a href="https://www.nomnoml.com/" rel="noopener noreferrer"&gt;Nomnoml&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When working with Markdown in ChatCraft I noticed that Markdown isn't rendered in a preview like Mermaid and Nomnoml:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhunp90igbzsekf86z9qv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhunp90igbzsekf86z9qv.png" alt="Image description" width="800" height="786"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Chat available &lt;a href="https://chatcraft.org/c/rjwignar/9Dkbq_a17U4Grso2WQutb" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I don't know whether this is something the community wants, but I opened the issue in case. My classmate, &lt;a href="https://dev.to/mingming-ma"&gt;Mingming&lt;/a&gt;, suggested we might be able to implement this by adjusting our &lt;a href="https://github.com/remarkjs/react-markdown?tab=readme-ov-file#react-markdown" rel="noopener noreferrer"&gt;react-markdown&lt;/a&gt;. This sounds more involved than the code I added for Nomnoml rendering, but I suppose I wouldn't mind giving it a shot.&lt;/p&gt;

&lt;h3&gt;
  
  
  Remaining Plans
&lt;/h3&gt;

&lt;p&gt;There is now one more week remaining in my Open Source class. I already had some issues planned, but with the recent bugs I popped up I will be devoting my remaining time to fixing them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/issues/586" rel="noopener noreferrer"&gt;Error Alert Toast Bug&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/issues/587" rel="noopener noreferrer"&gt;Re-asking Human message duplicates message&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If time permits, I hope to work on and possibly solve these issues as well:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/issues/544" rel="noopener noreferrer"&gt;Don't show 'free mode' banner when multiple providers set&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/issues/451" rel="noopener noreferrer"&gt;Add share_target support&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>opensource</category>
    </item>
    <item>
      <title>ChatCraft Adventures #12, Slash Commands</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sat, 06 Apr 2024 04:56:55 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-adventures-12-slash-commands-1928</link>
      <guid>https://dev.to/rjwignar/chatcraft-adventures-12-slash-commands-1928</guid>
      <description>&lt;p&gt;&lt;a href="https://chatcraft.org/" rel="noopener noreferrer"&gt;ChatCraft&lt;/a&gt; Release 1.8 is available &lt;a href="https://github.com/tarasglek/chatcraft.org" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  ChatCraft Week 12 Recap
&lt;/h1&gt;

&lt;p&gt;This week I started addressing some of the technical debt my classmates and I accrued during the past semester. I have quite a few code enhancements/bug fixes I plan to fix in April, but I've made a slow start.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sheriff Duty 2: Electric Boogaloo
&lt;/h3&gt;

&lt;p&gt;This week I also wear my Sheriff's hat for a second and final time. I described my first Sheriff duty experience &lt;a href="https://dev.to/rjwignar/chatcraft-adventures-4-50o7"&gt;earlier in this series&lt;/a&gt;, and it was nice to try it again this week. The largest portion of Sheriff duty is leading the weekly triage meeting, and I feel I did a better job than I did the first time around. Many of the Issues we planned to close in this milestone were completed, though I think I should have helped review more Pull Requests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pull Requests
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/567" rel="noopener noreferrer"&gt;Update Slash Command Handling&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;ChatCraft has a cool feature we call "slash commands", which start with a forward slash (/). Here's a list of current slash commands:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0zp1gz531wxn6vgcak2l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0zp1gz531wxn6vgcak2l.png" alt="Image description" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Typically, when you try to use a slash command that doesn't exist, like &lt;code&gt;/invalidcommand&lt;/code&gt;, you receive a message telling you that command is invalid and showing you the list of valid commands:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkau7hkkb7lr78lcmex2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flkau7hkkb7lr78lcmex2.png" alt="Image description" width="800" height="554"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What if you want to send something that isn't a slash command, but it starts with a forward slash?&lt;/p&gt;

&lt;p&gt;ChatCraft creator Taras &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/500" rel="noopener noreferrer"&gt;reported&lt;/a&gt; how his ChatCraft Chat crashed when he pasted the following block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/workspaces/DeepStructure/misc/getsetup/add-to-notion.ts:181
        throw new Error(`Notion API call failed: ${await response.text()}`);
              ^


Error: Notion API call failed: {"object":"error","status":400,"code":"validation_error","message":"body failed validation: body.children[0].heading_1.rich_text should be defined, instead was `undefined`.","request_id":"f73a1254-1204-4610-9820-76f6890821dc"}
    at notionApiCall (/workspaces/DeepStructure/misc/getsetup/add-to-notion.ts:181:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at createHeadingWithText (/workspaces/DeepStructure/misc/getsetup/add-to-notion.ts:137:5)
    at updateOrAppendAiSummary (/workspaces/DeepStructure/misc/getsetup/add-to-notion.ts:113:5)
    at main (/workspaces/DeepStructure/misc/getsetup/add-to-notion.ts:192:5)

Node.js v20.8.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  My investigation
&lt;/h4&gt;

&lt;p&gt;My first instinct was to replicate this error myself and to read the error. After replicating, I found this error using my browser's &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/Tools_and_setup/What_are_browser_developer_tools" rel="noopener noreferrer"&gt;developer tools&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Femjiycue8a5rz6z3zr92.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Femjiycue8a5rz6z3zr92.png" alt="Image description" width="716" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From this error, it was clear that a function called &lt;code&gt;parseCommand&lt;/code&gt; was throwing an error. To determine where &lt;code&gt;parseCommand&lt;/code&gt; was called, I used git grep&lt;br&gt;
&lt;a href="https://git-scm.com/docs/git-grep" rel="noopener noreferrer"&gt;git grep&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpsv2ig9sq1pr6qmpv5cf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpsv2ig9sq1pr6qmpv5cf.png" alt="Image description" width="800" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding some &lt;a href="https://www.w3schools.com/jsref/met_console_log.asp" rel="noopener noreferrer"&gt;console.log()&lt;/a&gt; calls and replicating the error a few more times, I was able to locate the bug to parseCommand() returning null because although the above block starts with a forward slash, it fails the slash command check (it contains a non-word character - special characters like &lt;code&gt;;&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;@&lt;/code&gt; - after the [/command] block) in parseCommand:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7du19v7btqkaip33mbo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw7du19v7btqkaip33mbo.png" alt="Image description" width="800" height="124"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  My solution
&lt;/h4&gt;

&lt;p&gt;Though the error is thrown by parseCommand(), the main issue is that ChatCraft &lt;a href="https://github.com/tarasglek/chatcraft.org/blob/f7b28038b3820d617a14b346536377977f4379d0/src/lib/ChatCraftCommand.ts#L19-L21" rel="noopener noreferrer"&gt;interpreted every prompt that starts with a forward slash as a potential slash command&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9jba5sr1soebjcowpnuk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9jba5sr1soebjcowpnuk.png" alt="Image description" width="492" height="67"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since the above error block starts off with a forward slash, if it is pasted by itself in a ChatCraft chat, it would be treated as a potential slash command, and throwing the error Taras observed.&lt;/p&gt;

&lt;p&gt;I'll admit I took a while to figure out a good solution to this issue. Before this PR, routine for handling potential slash commands is as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If prompt is a potential slash command (starts with forward slash)

&lt;ul&gt;
&lt;li&gt;If the slash command exists attempt to run it&lt;/li&gt;
&lt;li&gt;Else, parse the invalid command using parseCommand then send a relevant message&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Else, Pass prompt to LLM&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Although the above error block starts with a forward slash, we don't want to treat it as a potential slash command, and instead, pass it directly the LLM. But how do we do that?&lt;/p&gt;
&lt;h5&gt;
  
  
  Initial Implementation
&lt;/h5&gt;

&lt;p&gt;My solution was to update the isCommand() method to use stricter criteria for determining a potential slash command. I figured a good start was to reuse the RegEx used in parseCommand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;  &lt;span class="c1"&gt;// Checks if a string is a command.&lt;/span&gt;
  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;isCommand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Check if there's something resembling a command (no non-word characters in the portion after forward slash)&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;match&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;\/(\w&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;)(?:\s&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;.*&lt;/span&gt;&lt;span class="se"&gt;))?&lt;/span&gt;&lt;span class="sr"&gt;$/&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="nx"&gt;match&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Final Implementation
&lt;/h5&gt;

&lt;p&gt;Though this implementation worked, I felt I could do the same in one line, but I wasn't sure how. Fortunately, my class instructor Dave suggested a concise way to do this using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test" rel="noopener noreferrer"&gt;RegExp.prototype.test()&lt;/a&gt;, which became my final implementation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;  &lt;span class="c1"&gt;// Checks if a string is a command.&lt;/span&gt;
  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;isCommand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Check if there's something resembling a command (no non-word characters in the portion after forward slash)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;\/(\w&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;)(?:\s&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;.*&lt;/span&gt;&lt;span class="se"&gt;))?&lt;/span&gt;&lt;span class="sr"&gt;$/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Aftermath
&lt;/h4&gt;

&lt;p&gt;These changes to isCommand() preserve the functionality of current (as they still satisfy the RegEx check in isCommand()), while allowing things like error blocks (that start with a forward slash) to be directly pasted into a ChatCraft message and sent to the LLM.&lt;/p&gt;

&lt;p&gt;However, my update isn't perfect. If a user were to enter something like &lt;code&gt;/badcommand@&lt;/code&gt;, instead of the website returning a message saying "badcommand@ is not a valid command", this is sent to the LLM as a message:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4cjefmrvfps1tf994jcq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4cjefmrvfps1tf994jcq.png" alt="Image description" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope I, or someone else can determine a more robust RegEx to use in isCommand().&lt;/p&gt;

&lt;h3&gt;
  
  
  Remaining Plans
&lt;/h3&gt;

&lt;p&gt;With two weeks left, I hope to complete more code enhancement/bug-fix related issues.&lt;br&gt;
Here are some issues I have planned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/issues/552" rel="noopener noreferrer"&gt;Adding an eye icon to supplement API key hide/show state&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/issues/544" rel="noopener noreferrer"&gt;Don't show "free mode" banner when multiple providers set&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tarasglek/chatcraft.org/issues/451" rel="noopener noreferrer"&gt;Add share_target support&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>opensource</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>ChatCraft Adventures Week #11, Vite Precaching, Keyboard Shortcuts, Nomnoml Rendering</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sun, 31 Mar 2024 05:17:21 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-adventures-week-11-vite-precaching-keyboard-shortcuts-nomnoml-rendering-2h16</link>
      <guid>https://dev.to/rjwignar/chatcraft-adventures-week-11-vite-precaching-keyboard-shortcuts-nomnoml-rendering-2h16</guid>
      <description>&lt;p&gt;&lt;a href="https://chatcraft.org/" rel="noopener noreferrer"&gt;ChatCraft&lt;/a&gt; Release 1.7 is available &lt;a href="https://github.com/tarasglek/chatcraft.org/releases/tag/v1.7.0" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I had a pretty productive week. I made three Pull Requests, and added a couple cool features I'd like to share with you today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pull Requests
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/526" rel="noopener noreferrer"&gt;Nomnoml Rendering Support&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This is a Pull Request I started last week, but completed this week. This PR adds &lt;a href="https://github.com/skanaar/nomnoml" rel="noopener noreferrer"&gt;skanaar/nomnoml&lt;/a&gt; to let ChatCraft render &lt;a href="https://nomnoml.com/" rel="noopener noreferrer"&gt;nomnoml&lt;/a&gt; code in a preview.&lt;/p&gt;

&lt;p&gt;You can try this feature yourself! On ChatCraft, just request a Nomnoml diagram from your selected LLM. You can also see the feature in action in &lt;a href="https://chatcraft.org/api/share/rjwignar/Qwt7SVDTKsfWFMFtcMKiu" rel="noopener noreferrer"&gt;this chat&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One thing I noticed is that depending on the LLM, you may receive nomnoml with syntax errors. When implementing this, I also noticed the nomnoml library doesn't provide options for a default theme. It would be really cool if I could change the default stylings for dark mode!&lt;/p&gt;

&lt;p&gt;I'm proud of this feature. For a while I've been adding bug fixes and code enhancements, but until this PR I never added a feature. I can't take all the credit though. ChatCraft already renders Mermaid diagrams, so my strategy for this PR was to model my implementation off the already exiting Mermaid preview rendering feature. &lt;br&gt;
Viewing the history of the &lt;a href="https://github.com/tarasglek/chatcraft.org/commits/main/src/components/MermaidPreview.tsx" rel="noopener noreferrer"&gt;MermaidPreview.tsx component&lt;/a&gt; took me to this &lt;a href="https://github.com/tarasglek/chatcraft.org/commit/78069da57dbe4d20e6e2dddc3f2bc909e98666cb" rel="noopener noreferrer"&gt;commit&lt;/a&gt; that my class instructor, Dave, added last year. This commit helped inform how I should implement nomnoml preview rendering - what files to add, what files to make changes to and what changes to make.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/527" rel="noopener noreferrer"&gt;/ Keyboard Shortcut to focus Chat Input&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This is another cool feature I started last week and was able to complete this week. This feature adds a new keyboard shortcut that activates your current Chat's prompt input. If you want to quickly focus your prompt input, just press the forward slash key, &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This feature is common on websites like YouTube and GitHub, but I never knew about it until this feature was &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/511" rel="noopener noreferrer"&gt;requested&lt;/a&gt; for ChatCraft.&lt;/p&gt;

&lt;p&gt;When implementing this feature, I originally wanted to make use of this &lt;a href="https://github.com/tarasglek/chatcraft.org/blob/main/src/hooks/use-key-down-handler.ts" rel="noopener noreferrer"&gt;handler for keyboard inputs&lt;/a&gt;. However, my initial implementation didn't seem to work, so I added this keyboard shortcut as a &lt;a href="https://react.dev/reference/react/useEffect" rel="noopener noreferrer"&gt;useEffect React Hook&lt;/a&gt;. Where to place this useEffect was a challenge. I wanted to place it such that the keyboard shortcut would work anywhere on the page, so added it to what I believed was the entire chat window component, &lt;a href="https://github.com/tarasglek/chatcraft.org/blob/e8e55c53d39445b4096701fc5774961239d31183/src/Chat/ChatBase.tsx" rel="noopener noreferrer"&gt;ChatBase&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm pretty happy with this feature. I've never added keyboard shortcuts, so figuring out and learning how to do it was a fun experience.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/529" rel="noopener noreferrer"&gt;Bug Fix: Non Precached Url&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;For a while, I noticed this error when opening my browser's developer tools on ChatCraft:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3u1jznh0gh0cgkrmqcc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3u1jznh0gh0cgkrmqcc.png" alt="Image description" width="800" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I made an &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/528" rel="noopener noreferrer"&gt;Issue&lt;/a&gt; for it and began investigating.&lt;/p&gt;

&lt;p&gt;I can't say exactly how long I've seen this error, but even with this error present ChatCraft works just fine.&lt;br&gt;
My investigation involved searching the error message on Google:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Uncaught (in promise) non-precached-url: non-precached-url
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My search led me to this &lt;a href="https://github.com/vite-pwa/vite-plugin-pwa/issues/120" rel="noopener noreferrer"&gt;discussion&lt;/a&gt;, and then to this &lt;a href="https://github.com/vite-pwa/vite-plugin-pwa/issues/120#issuecomment-1202579983" rel="noopener noreferrer"&gt;comment&lt;/a&gt; that contained the changes I had to make to fix this issue.&lt;/p&gt;

&lt;h4&gt;
  
  
  Explanation
&lt;/h4&gt;

&lt;p&gt;I discussed this PR with my classmates earlier this week, and Dave helped me understand what this error was about.&lt;/p&gt;

&lt;p&gt;ChatCraft uses &lt;a href="https://github.com/vite-pwa/vite-plugin-pwa" rel="noopener noreferrer"&gt;vite-plugin-pwa&lt;/a&gt; to make ChatCraft a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Guides/What_is_a_progressive_web_app" rel="noopener noreferrer"&gt;Progressive Web App&lt;/a&gt; (PWA). I don't exactly know what a PWA isFrom what I understand, making ChatCraft a PWA allows it to work and provide value even if the user's device isn't connected to the internet.&lt;/p&gt;

&lt;p&gt;The error I fixed is related to workbox settings, located in a vite.config.ts. I'm still learning what workbox is, but for now I can say that in our case, the workbox configurations we have define what assets will be pre-cached.&lt;/p&gt;

&lt;p&gt;The error was due to these settings expecting ChatCraft's index.html to be pre-cached. Though we precache some assets, we don't precache index.html. The changes I made tells the workbox not to expect index.html to be pre-cached, so the error no longer appears.&lt;/p&gt;

&lt;h3&gt;
  
  
  Plans for April
&lt;/h3&gt;

&lt;p&gt;Any new code added is more code that must be maintained, whether through refactoring or bug fixes. This is often referred to as &lt;a href="https://en.wikipedia.org/wiki/Technical_debt" rel="noopener noreferrer"&gt;technical debt&lt;/a&gt;. There are three more weeks in my semester. In those remaining weeks I plan to help manage as much technical debt as I can. &lt;/p&gt;

</description>
      <category>opensource</category>
      <category>webdev</category>
    </item>
    <item>
      <title>ChatCraft Adventures #10</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sat, 23 Mar 2024 03:42:08 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-adventures-10-3da3</link>
      <guid>https://dev.to/rjwignar/chatcraft-adventures-10-3da3</guid>
      <description>&lt;h2&gt;
  
  
  ChatCraft Release 1.6
&lt;/h2&gt;

&lt;p&gt;This week in &lt;a href="https://chatcraft.org/" rel="noopener noreferrer"&gt;ChatCraft&lt;/a&gt;, Release 1.6 has been released and is available &lt;a href="https://github.com/tarasglek/chatcraft.org/releases/tag/v1.6.0" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pull Requests
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/506" rel="noopener noreferrer"&gt;Make Shared Chats Accessible from UI Again&lt;/a&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Recap
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://dev.to/rjwignar/chatcraft-adventures-9-troubleshooting-with-git-grep-48pg"&gt;Last week&lt;/a&gt;, I described a bug that prevented users from accessing their Shared Chats directly from the ChatCraft UI, and described my initial fix for the issue affecting how Shared Chats would be created.&lt;/p&gt;

&lt;p&gt;In short, when shared chats are created, they have two URLs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a "/c"-style URL

&lt;ul&gt;
&lt;li&gt;e.g. &lt;code&gt;https://chatcraft.org/c/user/chatId&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;an "/api/share"-style URL

&lt;ul&gt;
&lt;li&gt;e.g. - &lt;code&gt;https://chatcraft.org/api/share/user/chatId&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h4&gt;
  
  
  404 Error
&lt;/h4&gt;

&lt;p&gt;The "/api/share"-style URL is directly given to a Shared Chat and rendered by the ChatCraft frontend. When pasted into your browser's address bar, it redirects to the "/c"-style URL. However, when opening this link from the ChatCraft frontend you get a 404 error stating the route can't be found:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqo24o2g28c9ot0yy2y3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqo24o2g28c9ot0yy2y3.gif" alt="Image description" width="800" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  My original solution
&lt;/h4&gt;

&lt;p&gt;We don't know the exact cause for this error, but we believe it has something to do with how the "/api/share"-style URL works with &lt;a href="https://www.npmjs.com/package/react-router-dom" rel="noopener noreferrer"&gt;react-router-dom&lt;/a&gt;, as react-router-dom is mentioned in the error call stacks.&lt;/p&gt;

&lt;p&gt;My original fix involved giving new created Shared Chats the "/c"-style URL so it would be rendered by the UI instead of the "/api/share"-style URL. However, this fix ignored all the current Shared Chats that have an "/api/share"-style URL rendered in the UI.&lt;/p&gt;

&lt;h4&gt;
  
  
  My new solution
&lt;/h4&gt;

&lt;p&gt;After discussing with my classmates and instructor, we thought of two possible solutions to make Shared Chats with that "/api/share"-style URL accessible again:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Render the Shared Chat's "/c"-style URL instead of the "/api/share"-style URL&lt;/li&gt;
&lt;li&gt;Use window.location to bypass react-router-dom and redirect to the Shared Chats' "/c"-style URL&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I opted to implement the first solution, as I believed it would be less invasive. To do this, I added a method called &lt;code&gt;convertToShareUrl&lt;/code&gt; to convert any "/api/share"-style URL to a "/c"-style URL before it is rendered by the frontend:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="cm"&gt;/**
 * Converts "/api/share"-style URLs before passing it to UI
 * This is done to avoid react-router-dom issue involving "/api/share"-style URLs
 * @param url
 * @returns url
 */&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;convertToShareUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/share&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/api/share&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because this change fixes the issue of Shared Chats with "/api/share"-style URLs, I ended up removing my original changes as they were no longer required to fix/prevent this bug. This new fix is a huge improvement over my initial fix, and I'm happy I was able to figure out and fix this bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current Work
&lt;/h2&gt;

&lt;p&gt;This week, I've also been working on a couple issues. They haven't been made into Pull Requests yet, but I'd like to share what I've done so far.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/466" rel="noopener noreferrer"&gt;Add nomnoml renderer&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Currently, ChatCraft supports &lt;a href="https://mermaid.js.org/" rel="noopener noreferrer"&gt;Mermaid&lt;/a&gt; rendering. This feature request involves adding support for &lt;a href="https://nomnoml.com/" rel="noopener noreferrer"&gt;nomnoml&lt;/a&gt; rendering. Nomnoml is similar to Mermaid, in that they're both used in generating &lt;a href="https://en.wikipedia.org/wiki/Unified_Modeling_Language" rel="noopener noreferrer"&gt;uml diagrams&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Current progress
&lt;/h4&gt;

&lt;p&gt;When working on this feature, I tried to mirror the files required for the Mermaid rendering feature. By doing this, I've been able to get a rudimentary version of Nomnoml support working. Here's what it looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbur51v7atyu12na3jqdi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbur51v7atyu12na3jqdi.png" alt="Image description" width="800" height="626"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To support nomnoml rendering, I am using the &lt;a href="https://github.com/skanaar/nomnoml" rel="noopener noreferrer"&gt;skanaar/nomnoml&lt;/a&gt; library.&lt;br&gt;
However, my feature is not perfect. For one, sometimes the LLM can return bad nomnoml syntax (at least when using GPT-3.5). Other times, the nomnoml render does not fit within the React Card:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqak8ozprzfs69ckccskf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqak8ozprzfs69ckccskf.png" alt="Image description" width="800" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, as far as I'm aware, the current nomnoml library is missing some features present in the mermaid library, such as custom-theme support. If this is true, then it means all rendered nomnoml will appear in a beige theme.&lt;/p&gt;

&lt;p&gt;In the coming days I hope to fully flesh out this feature.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/511" rel="noopener noreferrer"&gt;&lt;code&gt;/&lt;/code&gt; Keyboard Shortcut to focus input bar&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This is another cool feature I've been working on. Many websites, like Google search, Youtube, and GitHub have a keyboard shortcut to focus the input bar, typically the forward slash key: &lt;code&gt;/&lt;/code&gt;. It would be cool to add this feature to ChatCraft so users can press the &lt;code&gt;/&lt;/code&gt; key to quickly enter their current chat's input window.&lt;/p&gt;

&lt;p&gt;I never really noticed this feature until I saw this feature request. However, once I learned about this feature I could not un-see it. The next time you're browsing the web, see if any websites you browse have this feature.&lt;/p&gt;

&lt;p&gt;My current version of this feature is a little buggy. I think it has to deal with which component I'm adding this feature to. I hope to figure it out in the next week.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next week in ChatCraft
&lt;/h2&gt;

&lt;p&gt;In ChatCraft Release 1.7, I hope to finish these two features I'm working on.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>ChatCraft Adventures #9 - Troubleshooting Bugs with git grep</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sat, 16 Mar 2024 04:12:58 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-adventures-9-troubleshooting-with-git-grep-48pg</link>
      <guid>https://dev.to/rjwignar/chatcraft-adventures-9-troubleshooting-with-git-grep-48pg</guid>
      <description>&lt;h3&gt;
  
  
  This week in ChatCraft
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Release 1.5
&lt;/h2&gt;

&lt;p&gt;This week in &lt;a href="https://chatcraft.org/" rel="noopener noreferrer"&gt;ChatCraft&lt;/a&gt;, Release 1.5 has been released and is available &lt;a href="https://github.com/tarasglek/chatcraft.org/releases/tag/v1.5.0" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pull Requests
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/482" rel="noopener noreferrer"&gt;Prompt Updating&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;I'm happy to share that this week, I was able to extract and get a version of my updated system merged. My change isn't perfect, but it's able to get GPT-3.5-Turbo to return inline math Markdown in &lt;a href="https://katex.org/" rel="noopener noreferrer"&gt;KaTeX syntax&lt;/a&gt; instead of &lt;a href="https://www1.cmc.edu/pages/faculty/aaksoy/latex/latexthree.html" rel="noopener noreferrer"&gt;LaTeX Math mode&lt;/a&gt;. One concern we have with this merge is that it might encourage/cause an LLM to add KaTeX syntax into generated code, such as if it's writing code to do any math, but we'll be monitoring this in the coming weeks. The good thing about Open Source is that you can always iterate on and improve code. One thing I learned in my earlier Open Source class is that pursuing perfection often gets in the way of achieving any results at all, or in other words, &lt;a href="https://en.wikipedia.org/wiki/Perfect_is_the_enemy_of_good" rel="noopener noreferrer"&gt;perfect is the enemy of good&lt;/a&gt;. This current change may not be perfect, but it's good enough, and getting it merged means I can finally work on other issues and features.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/506" rel="noopener noreferrer"&gt;Cannot Access Shared Bugs - Naive Fix&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://dev.to/rjwignar/chatcraft-adventures-6-407d"&gt;In a previous blog post&lt;/a&gt;, I reported an issue in which &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/446" rel="noopener noreferrer"&gt;shared chats could no longer be accessed&lt;/a&gt;. Though a later Pull Request was able to fix the issue at first, some people in the team still had issues accessing their shared Chats. In a meeting this week, we were able to determine that these "broken" shared Chats would redirect to a link with this url pattern:&lt;br&gt;
&lt;code&gt;[website-url]/api/share/{user}/{id}&lt;/code&gt;,&lt;br&gt;
where {user} is the username of the user who created the chat, and {id} is the chat id.&lt;/p&gt;

&lt;p&gt;These redirect url is accessed when the user clicks on one of their shared chats on the ChatCraft UI:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F39e90axmfmo3hhdmyyr8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F39e90axmfmo3hhdmyyr8.png" alt="Image description" width="800" height="198"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Attempting to access a chat this way returns a 404 error saying the route can't be found:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqo24o2g28c9ot0yy2y3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frqo24o2g28c9ot0yy2y3.gif" alt="Image description" width="800" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq4ojo59mmx2gb5dnftqr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq4ojo59mmx2gb5dnftqr.png" alt="Image description" width="800" height="47"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But the weird thing is, the chat exists, and can be accessed through this link if you enter it directly into your address bar:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu4c3q92gsbxgfndzuv2g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu4c3q92gsbxgfndzuv2g.gif" alt="Image description" width="800" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This also showed us that the &lt;code&gt;[website-url]/api/share/{user}/{id}&lt;/code&gt;-style URLs redirect to another url format, &lt;code&gt;[website-url]/c/{user}/{id}}&lt;/code&gt;, which contains the actual chat.&lt;/p&gt;

&lt;h3&gt;
  
  
  My Investigation
&lt;/h3&gt;

&lt;p&gt;I found the redirect behaviour of the &lt;code&gt;[website-url]/api/share/{user}/{id}&lt;/code&gt;-style URL (the "api/share/" URL) to the &lt;code&gt;[website-url]/c/{user}/{id}}&lt;/code&gt;-style URL (the "/c/" URL) interesting. Over the past couple of days, I decided to investigate this behaviour.&lt;/p&gt;

&lt;p&gt;My first thought was to look at earlier versions of ChatCraft, before we encountered this bug. Luckily, the ChatCraft repo has a workflow that builds and deploys a preview of all branches. Using this feature I was able to find and access an earlier version of ChatCraft I could study.&lt;/p&gt;

&lt;p&gt;I noticed that in earlier visions of ChatCraft, created Shared Chats wouldn't redirect to a "api/share/" URL, but rather directly to a "/c/" URL:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvri660nwii69if7uhqi0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvri660nwii69if7uhqi0.png" alt="Image description" width="800" height="124"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once I figured this out, I spent the last couple days studying how this happened. I knew that both the "api/share/" and "/c/" URLs were both valid, leading me to investigate the API methods written for these routes. The &lt;a href="https://git-scm.com/docs/git-grep" rel="noopener noreferrer"&gt;git grep&lt;/a&gt;  command was useful in showing me this code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foxdi2xph57usj5lkl8bn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foxdi2xph57usj5lkl8bn.png" alt="Image description" width="800" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  A quick note on &lt;code&gt;git grep&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;I can't stress enough how useful &lt;code&gt;git grep&lt;/code&gt; was not just for this issue, but most of my open source work. Whenever I'm investigating an bug, I'm able to find clues like routes (such as the "/api/share" and "/c/" route patterns) or keywords to lookup using &lt;code&gt;git grep&lt;/code&gt;. If not for this command I would have spent a lot more time investigating this issue.&lt;/p&gt;

&lt;p&gt;However, beyond this point my investigation methods became inefficient. I began littering the codebase with console.log() statements wherever the "api/share" and "/c/" routes were being fetched. I also ended up switching between two branches - one where the bug was present and one where it wasn't - to observe the differences between them. After a day and a half of doing this I was able to figure out the issue, but I wish I knew a better way to do this.&lt;/p&gt;

&lt;h3&gt;
  
  
  The issue - Chats created with a new url
&lt;/h3&gt;

&lt;p&gt;Eventually, my investigation revealed to me that around a month ago, a PR was merged that changed Shared Chats would be created. Shared Chats created after this PR would be given the "api/share"-style URL in the UI, while those created before the PR were given a "/c/"-style URL.&lt;/p&gt;

&lt;p&gt;After some more investigation, I discovered this was due to a new method, createDataShareUrl():&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwiak74cqi24qcmgygfd8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwiak74cqi24qcmgygfd8.png" alt="Image description" width="549" height="62"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Within this method is another method, createShareUrl(), that returns a "/c/"-style URL:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa2jlo1m5awh5lcxo9wrw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa2jlo1m5awh5lcxo9wrw.png" alt="Image description" width="562" height="66"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the PR, calls to createShareUrl() (when creating a Shared Chat) were replaced with createDataShareUrl():&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft9o0dsua4w7c4p8d3d41.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft9o0dsua4w7c4p8d3d41.png" alt="Image description" width="800" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This turned out to be why some users observed this issue while others haven't: Those who observed the issue were trying to access Shared Chats made after this PR (with the "/api/share" URL), and those who didn't were accessing old Shared Chats made before this PR (with the "/c/" URL).&lt;/p&gt;

&lt;h3&gt;
  
  
  An imperfect solution
&lt;/h3&gt;

&lt;p&gt;With this in mind, I was able to come up with a fix that uses createShareUrl() to give Shared Chats a "/c/"-style URL as before. However, I don't think it's the best fix. This is because it's only a partial fix. If this PR is merged, new Shared Chats created afterwards will be directly accessible via the UI again, but what about the Shared Chats that already have a "api/share"-style URL? Those still can't be accessed from the UI.&lt;/p&gt;

&lt;h3&gt;
  
  
  My ideal solution
&lt;/h3&gt;

&lt;p&gt;My ideal solution to this issue would be to figure out why "api/share"-style URLs don't work when accessed through the UI and to fix that issue directly, so that both "api/share" and "/c/"-style URLs work from the UI.&lt;/p&gt;

&lt;p&gt;I hope to take another look at this issue in the future, but I'd also like to work on adding new features to ChatCraft. &lt;/p&gt;

&lt;h2&gt;
  
  
  Next week in ChatCraft
&lt;/h2&gt;

&lt;p&gt;In ChatCraft release 1.6, I hope to add a new feature related to adding Images, or action a better fix for the Shared Chats issue if   it's not as difficult as I think.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>ChatCraft Adventures #8</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sat, 09 Mar 2024 02:59:59 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-adventures-7-167b</link>
      <guid>https://dev.to/rjwignar/chatcraft-adventures-7-167b</guid>
      <description>&lt;p&gt;This week in ChatCraft&lt;/p&gt;

&lt;h2&gt;
  
  
  Release 1.4
&lt;/h2&gt;

&lt;p&gt;After a short hiatus, ChatCraft release 1.4 has been released and is available &lt;a href="https://github.com/tarasglek/chatcraft.org/releases/tag/v1.4.0" rel="noopener noreferrer"&gt;here&lt;/a&gt;:&lt;br&gt;
This week has been slow for me. I've been stuck on my Pull Requests described in &lt;a href="https://dev.to/rjwignar/chatcraft-adventures-7-492i"&gt;my previous blog post&lt;/a&gt;, and I haven't been able to contribute PR reviews or find new issues. I'm hoping to have these resolved quickly before they go stale, so I can devote more time to larger issues and features.&lt;/p&gt;
&lt;h2&gt;
  
  
  Pull Requests
&lt;/h2&gt;
&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/482" rel="noopener noreferrer"&gt;Prompt Updating&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;In this Pull Request, I've updated the ChatCraft system prompt to return inline math in &lt;a href="https://katex.org/" rel="noopener noreferrer"&gt;KaTeX&lt;/a&gt;, like it currently does with math markdown in its own block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;When&lt;/span&gt; &lt;span class="nx"&gt;responding&lt;/span&gt; &lt;span class="kd"&gt;with&lt;/span&gt; &lt;span class="nx"&gt;math&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;inline&lt;/span&gt; &lt;span class="nx"&gt;or&lt;/span&gt; &lt;span class="nx"&gt;otherwise&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;I&lt;/span&gt; &lt;span class="nx"&gt;ALWAYS&lt;/span&gt; &lt;span class="nx"&gt;use&lt;/span&gt; &lt;span class="nx"&gt;KaTeX&lt;/span&gt; &lt;span class="nx"&gt;syntax&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;math&lt;/span&gt; &lt;span class="nx"&gt;Markdown&lt;/span&gt; &lt;span class="nx"&gt;by&lt;/span&gt; &lt;span class="nx"&gt;enclosing&lt;/span&gt; &lt;span class="nx"&gt;EVERY&lt;/span&gt; &lt;span class="nx"&gt;mathematical&lt;/span&gt; &lt;span class="nx"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;equation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;variable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;and&lt;/span&gt; &lt;span class="nx"&gt;formula&lt;/span&gt; &lt;span class="kd"&gt;with&lt;/span&gt; &lt;span class="nx"&gt;double&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;dollar&lt;/span&gt; &lt;span class="nx"&gt;signs&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="s2"&gt;`($$)&lt;/span&gt;&lt;span class="se"&gt;\`&lt;/span&gt;&lt;span class="s2"&gt;, for example: $$O(n&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;log n)$$, $$1024 * 1024 = 1048576$$, $$1024^2$$, $$X$$
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This updated is meant to solve the issue of ChatCraft returning inline math expressions in &lt;a href="https://www.overleaf.com/learn/latex/Mathematical_expressions" rel="noopener noreferrer"&gt;LaTeX Math mode syntax&lt;/a&gt;:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwqna6rkeczx0uxkb92ee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwqna6rkeczx0uxkb92ee.png" alt="Image description" width="800" height="215"&gt;&lt;/a&gt; (like &lt;code&gt;\(2^{20}\)&lt;/code&gt; instead of &lt;code&gt;$$2^{20}$$&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;With the new prompt, the GPT-3.5-turbo LLM seems to prefer returning inline math markdown as KaTeX, as seen in this &lt;a href="https://issue-460.console-overthinker-dev.pages.dev/api/share/chatcraft_dev/Q5gq6_wbAfMeZeWvJ6Ab-" rel="noopener noreferrer"&gt;conversation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;However, before this can be merged, we're worried that my updated prompt might instruct the LLM to use KaTeX syntax when returning code, which we don't want. We want the prompt to instruct the LLM to use KaTeX only when returning math markdown, and not to mix KaTeX syntax when returning code. I've tried to mitigate this by including the clause "When responding with math..." to the rule, but whether an LLM will properly follow these instructions can be hard to test. I'm hoping to receive feedback from my instructor or even the open source community. &lt;/p&gt;

&lt;p&gt;Until working on this issue I never really considered using ChatCraft or ChatGPT for math, but I see the utility now.&lt;br&gt;
I found that the updated prompt can address in-line Math Markdown, but it can fail when asking ChatCraft to describe scientific formulas, like the &lt;a href="https://issue-460.console-overthinker-dev.pages.dev/api/share/chatcraft_dev/kHyRkBnSlCfxC3tyUjGTG" rel="noopener noreferrer"&gt;gas laws&lt;/a&gt; or the &lt;a href="https://issue-460.console-overthinker-dev.pages.dev/api/share/chatcraft_dev/XX-K1VWmOtdQCW75S0RRy" rel="noopener noreferrer"&gt;Michaelis-Menten formula&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;In these conversations, ChatCraft fails to return individual variables in KaTeX syntax:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6fm65389jbfx0a7kqlxr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6fm65389jbfx0a7kqlxr.png" alt="Image description" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I originally had a second rule that fixes this issue:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;I&lt;/span&gt; &lt;span class="nx"&gt;NEVER&lt;/span&gt; &lt;span class="nx"&gt;wrap&lt;/span&gt; &lt;span class="nx"&gt;mathematical&lt;/span&gt; &lt;span class="nx"&gt;expressions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;equations&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;variables&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;or&lt;/span&gt; &lt;span class="nx"&gt;formulas&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;round&lt;/span&gt; &lt;span class="nx"&gt;brackets&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="s2"&gt;`(&lt;/span&gt;&lt;span class="se"&gt;\`&lt;/span&gt;&lt;span class="s2"&gt;, &lt;/span&gt;&lt;span class="se"&gt;\`&lt;/span&gt;&lt;span class="s2"&gt;)&lt;/span&gt;&lt;span class="se"&gt;\`&lt;/span&gt;&lt;span class="s2"&gt;. For example, instead of responding with (V_{max}), I would respond with $$V_{max}$$
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...but I removed it because I was worried about introducing new ways for the LLM to give improper responses.&lt;br&gt;
I'll need to clarify with the community whether this rule should be added back.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/488" rel="noopener noreferrer"&gt;Dynamic Imports&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This Pull Request involves dynamically importing a few large dependencies to reduce bundle size:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;elkjs (for Mermaid)&lt;/li&gt;
&lt;li&gt;cytoscape (for Mermaid)&lt;/li&gt;
&lt;li&gt;katex (for Math rendering)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In an older PR, I tried dynamically importing the modules that use these dependencies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mermaid&lt;/li&gt;
&lt;li&gt;rehype-katex&lt;/li&gt;
&lt;li&gt;remark-math&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;... but I found that dynamically importing rehype-katex and remark-math &lt;a href="https://rjwignar-issue-365.console-overthinker-dev.pages.dev/" rel="noopener noreferrer"&gt;crashes my preview app&lt;/a&gt; due to a workbox error:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs5qhvs1vmu3lhxfeddsk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs5qhvs1vmu3lhxfeddsk.png" alt="Image description" width="800" height="63"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the new PR, I was able to dynamically import mermaid, but the problem is mermaid is almost always needed, so dynamically importing it doesn't help much. elkjs and cytoscape are never directly called in the source code (at least according to &lt;code&gt;git grep&lt;/code&gt;), and are only invoked through mermaid (as dependencies). I'm not sure if there's another way to dynamically import only these dependencies of mermaid.&lt;/p&gt;

&lt;p&gt;I'll need some help dynamically importing rehype-katex and remark-math.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plans for Release 1.5
&lt;/h2&gt;

&lt;p&gt;In release 1.5, I hope to have these PRs revised and merged.&lt;br&gt;
I'm actually thinking about postponing these PRs further so I can focus on a new feature I'd like to add, adding files to a ChatCraft conversation.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>opensource</category>
      <category>openai</category>
      <category>webdev</category>
    </item>
    <item>
      <title>ChatCraft Adventures #7</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sat, 24 Feb 2024 04:42:25 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-adventures-7-492i</link>
      <guid>https://dev.to/rjwignar/chatcraft-adventures-7-492i</guid>
      <description>&lt;h2&gt;
  
  
  This week in ChatCraft
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Release 1.4
&lt;/h3&gt;

&lt;p&gt;ChatCraft release 1.4 has been delayed. However, my classmates and I have been working on bug fixes, enhancements and new features.&lt;/p&gt;

&lt;p&gt;This week has been slow compared to previous weeks. So far I've made &lt;br&gt;
two Pull Requests&lt;/p&gt;

&lt;h2&gt;
  
  
  Pull Requests
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/482" rel="noopener noreferrer"&gt;Prompt Updating for inline KaTeX&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;ChatCraft can render math using the &lt;a href="https://www.npmjs.com/package/rehype-katex" rel="noopener noreferrer"&gt;rehype-katex&lt;/a&gt; package, which renders &lt;a href="https://katex.org/" rel="noopener noreferrer"&gt;KaTeX&lt;/a&gt; syntax. In most cases, the queried LLM will render Math in KaTeX, but &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/460" rel="noopener noreferrer"&gt;sometimes inline elements do not&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;My Pull Request involves a slight adjustment to the default prompt that instructs the LLM to also render any inline mathematical expressions as KaTeX by wrapping the expressions in double dollar signs.&lt;/p&gt;

&lt;p&gt;This Pull Request still needs review and hasn't been merged, but I found it fun to work on. I'm using the OpenAI API for my college capstone project, so I've had some experience fine-tuning my prompts so the LLM (typically &lt;code&gt;gpt-3.5-turbo&lt;/code&gt;) to respond as required.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/472" rel="noopener noreferrer"&gt;Add Dynamic Imports for Mermaid and Math Rendering&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Some packages/modules used in ChatCraft are large, and we'd like to import them &lt;a href="https://vitejs.dev/guide/features#dynamic-import" rel="noopener noreferrer"&gt;dynamically&lt;/a&gt;. The focus of this PR was to dynamically import a few packages used for Math and &lt;a href="https://mermaid.js.org/" rel="noopener noreferrer"&gt;Mermaid&lt;/a&gt; rendering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/remark-math" rel="noopener noreferrer"&gt;remarkMath&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/rehype-katex" rel="noopener noreferrer"&gt;rehypeKatex&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/mermaid" rel="noopener noreferrer"&gt;mermaid&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Locally, my changes work, but when I pushed my branch to GitHub and tested my preview, ChatCraft doesn't load. This is something I hope to investigate and solve next week.&lt;/p&gt;

&lt;h2&gt;
  
  
  Plans for next week and, rest of the semester
&lt;/h2&gt;

&lt;p&gt;This is the halfway point of my semester. At this point, I've been able to contribute small changes to ChatCraft. However, in the remainder of the semester I hope to contribute new code and features to ChatCraft. Some things I'd like to work on include WASM, and the ability to attach files to a chat.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>openai</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>ChatCraft Adventures #6</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sat, 17 Feb 2024 04:59:17 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-adventures-6-407d</link>
      <guid>https://dev.to/rjwignar/chatcraft-adventures-6-407d</guid>
      <description>&lt;h2&gt;
  
  
  This week in ChatCraft
&lt;/h2&gt;

&lt;p&gt;This week in ChatCraft, Release 1.3 has been completed, and is available &lt;a href="https://github.com/tarasglek/chatcraft.org/releases/tag/v1.3.0" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This has been a busy week for in terms of classes. Due to having to meet other deadlines, my PRs involved small code changes. However, I've been able to also discover issues and contribute reviews.&lt;/p&gt;

&lt;h2&gt;
  
  
  Issues
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Searchbar Improvements
&lt;/h3&gt;

&lt;p&gt;After provisioning my own &lt;a href="https://openai.com/blog/openai-api" rel="noopener noreferrer"&gt;OpenAI API&lt;/a&gt; key, I've been using ChatCraft a lot, perhaps too much:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2tiyxjy640x0zcw1aufc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2tiyxjy640x0zcw1aufc.png" alt="Image description" width="298" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With over 70 chats I was wondering how I'd quickly find previous chats. After asking in the Discord server, I was informed there was a search bar, but I couldn't find it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4iult8hddmcfyv1hr07l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4iult8hddmcfyv1hr07l.png" alt="Image description" width="800" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The search bar might be easy for readers to find, but it took me a while to notice it. It was from this experience I looked for ways to make the search bar more visible/noticeable.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/442" rel="noopener noreferrer"&gt;ChatCraft page moves up&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;After a recent Pull Request, I noticed that accessing saved chats pushes up the page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7tqd01q5wnwquzkbg0c1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7tqd01q5wnwquzkbg0c1.png" alt="Image description" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Luckily, my classmate &lt;a href="https://github.com/Amnish04" rel="noopener noreferrer"&gt;Amnish&lt;/a&gt; recognized the cause, as he researched and fixed a very similar issue for &lt;a href="https://dev.to/amnish04/no-backing-away-when-hacking-away-2h27"&gt;ChatCraft during Hacktoberfest 2023&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://github.com/tarasglek/chatcraft.org/pull/445" rel="noopener noreferrer"&gt;https://github.com/tarasglek/chatcraft.org/pull/445&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In short, the cause was a new &lt;a href="https://chakra-ui.com/docs/components/menu" rel="noopener noreferrer"&gt;ChakraUI Menu&lt;/a&gt; that was missing the &lt;code&gt;fixed&lt;/code&gt; CSS positioning strategy (from &lt;a href="https://v1.chakra-ui.com/docs/components/overlay/menu" rel="noopener noreferrer"&gt;https://v1.chakra-ui.com/docs/components/overlay/menu&lt;/a&gt;).&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/446" rel="noopener noreferrer"&gt;Cannot access shared chats&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;After the same Pull Request, I noticed that ChatCraft crashes when accessing shared chats and using the search bar. Due to other commitments, I didn't have the bandwidth to investigate and solve the issue. Luckily, &lt;a href="https://github.com/humphd" rel="noopener noreferrer"&gt;Dave&lt;/a&gt;, my class instructor, figured out the cause and made a &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/469" rel="noopener noreferrer"&gt;PR&lt;/a&gt; that fixes the issue.&lt;/p&gt;
&lt;h2&gt;
  
  
  Reviews
&lt;/h2&gt;
&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/445#pullrequestreview-1876787728" rel="noopener noreferrer"&gt;Page Moves Up Solution&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;I had the pleasure of reviewing Amnish's fix for &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/442" rel="noopener noreferrer"&gt;Issue 442&lt;/a&gt;, and reading the explanation for the fix on his blog.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/403#pullrequestreview-1881446322" rel="noopener noreferrer"&gt;Enable remote JS/TS execution using val.town endpoint&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This Pull Request by Dave involved using the &lt;a href="https://www.val.town/" rel="noopener noreferrer"&gt;val.town&lt;/a&gt; &lt;a href="https://docs.val.town/api/eval/" rel="noopener noreferrer"&gt;/eval endpoint &lt;/a&gt; to run JavaScript/TypeScript remotely. I'm still learning about val.town so I don't know much at the moment, but it seems like a cool integration.&lt;/p&gt;
&lt;h2&gt;
  
  
  Pull Requests
&lt;/h2&gt;

&lt;p&gt;This week, I've made two pull requests to ChatCraft&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/448" rel="noopener noreferrer"&gt;Search Bar Placeholder&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Following up on the search bar issue I brought up earlier, I added placeholder text to the ChatCraft search bar. I'm not a UI/UX expert, but I figured ChatCraft would have a better idea. In a new ChatCraft conversation, I modified the system prompt to make ChatCraft an expert in UI/UX:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46flkq6emi6ab2mwkjav.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46flkq6emi6ab2mwkjav.png" alt="Image description" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And then &lt;a href="https://chatcraft.org/c/rjwignar/oOes55CNAXukfvwrofjxL" rel="noopener noreferrer"&gt;I asked ChatCraft&lt;/a&gt; (using &lt;code&gt;gpt-4-vision-preview&lt;/code&gt; via the new Image Input feature) to make recommendations for improvement, one of which was adding placeholder text.&lt;/p&gt;

&lt;p&gt;ChatCraft made other suggestions that would improve the overall search functionality and overall experience, although most of them (besides placeholder text) wouldn't necessarily improve the search bar's visibility. Perhaps I could specifically ask for suggestions for improving visibility.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/459" rel="noopener noreferrer"&gt;Adding Twitter Card Metadata to ChatCraft.org&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Previously, ChatCraft links posted on Twitter wouldn't be rendered into a &lt;a href="https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/abouts-cards" rel="noopener noreferrer"&gt;Twitter Card&lt;/a&gt;. The ChatCraft page already contained &lt;a href="https://ogp.me/" rel="noopener noreferrer"&gt;OpenGraph&lt;/a&gt; metadata but it wasn't enough for Twitter to render a Summary Card (it was missing an &lt;code&gt;og:type&lt;/code&gt; property):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1l3sp2hayrtnfhj0fbq4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1l3sp2hayrtnfhj0fbq4.png" alt="Image description" width="800" height="165"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I initially added an &lt;code&gt;og:type&lt;/code&gt; meta tag, but ultimately also added the required Twitter Tags for robustness:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"twitter:card"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"summary_large_image"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"twitter:title"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"chatcraft.org"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"twitter:description"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"Web-based AI Assistant for Software Developers"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"twitter:image"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"https://chatcraft.org/favicon-32x32.png"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I also added these new meta tags to the share logic, so shared chats can also be rendered into Summary Cards:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="nf"&gt;setMetaContent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;clonedDocument&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;twitter:card&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;summary_large_image&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;setMetaContent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;clonedDocument&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;twitter:title&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;chatcraft.org&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;setMetaContent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;clonedDocument&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;twitter:description&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;setMetaContent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;clonedDocument&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;twitter:image&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://chatcraft.org/favicon-32x32.png&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now ChatCraft can be rendered in a Twitter Card:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgnxicfnqc0jubcif18ap.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgnxicfnqc0jubcif18ap.png" alt="Image description" width="596" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Missing Image
&lt;/h3&gt;

&lt;p&gt;You'll notice the Twitter Card is missing an image.&lt;br&gt;
This is &lt;strong&gt;not&lt;/strong&gt; a complete fix, as there's no image in the Twitter Card. I originally wanted to use a Summary Card with the ChatCraft logo as an image, but it doesn't meet the minimum image size requirments.&lt;/p&gt;

&lt;p&gt;In future work, we're looking into using a screenshot of the final message as the card image.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next week in ChatCraft
&lt;/h2&gt;

&lt;p&gt;Next week, I hope to have more time to make larger contributions to ChatCraft.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>opensource</category>
      <category>openai</category>
    </item>
    <item>
      <title>ChatCraft Adventures #5</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sat, 10 Feb 2024 00:07:39 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-adventures-5-2hb</link>
      <guid>https://dev.to/rjwignar/chatcraft-adventures-5-2hb</guid>
      <description>&lt;h2&gt;
  
  
  This week in ChatCraft
&lt;/h2&gt;

&lt;p&gt;This week in ChatCraft, Release 1.2 is complete, and is available &lt;a href="https://github.com/tarasglek/chatcraft.org/releases/tag/v1.2.0" rel="noopener noreferrer"&gt;here&lt;/a&gt; for those interested.&lt;br&gt;
The ChatCraft community has worked hard to push many changes and an awesome new feature to ChatCraft second release.&lt;/p&gt;

&lt;h3&gt;
  
  
  New Feature - Image Input
&lt;/h3&gt;

&lt;p&gt;One new feature I'm excited to share with you today &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/286" rel="noopener noreferrer"&gt;Image Input&lt;/a&gt;, prepared by my classmate &lt;a href="https://github.com/mingming-ma" rel="noopener noreferrer"&gt;Mingming&lt;/a&gt;. Since November 2023, Mingming has been working hard to polish and push this feature into ChatCraft, and his hard work has paid off.&lt;/p&gt;

&lt;p&gt;This feature uses &lt;a href="https://platform.openai.com/docs/guides/vision" rel="noopener noreferrer"&gt;GPT-4 with Vision&lt;/a&gt; (model name &lt;code&gt;gpt-4-vision-preview&lt;/code&gt;) to allow the model to analyze and discuss input images:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdhhy6r4kz18sgll99ksw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdhhy6r4kz18sgll99ksw.png" alt="Image description" width="800" height="904"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can attach images to the prompt either by clicking on the paperclip icon or by pasting it into the prompt window using &lt;code&gt;Ctrl+V&lt;/code&gt;. For a better idea, please take a look at the &lt;a href="https://chatcraft.org/api/share/rjwignar/sXIHj-eLoiam6NEFM2rOB" rel="noopener noreferrer"&gt;conversation&lt;/a&gt; I screenshotted above.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sheriff Duties
&lt;/h2&gt;

&lt;p&gt;In my last &lt;a href="https://dev.to/rjwignar/chatcraft-adventures-4-50o7"&gt;blog post&lt;/a&gt;, I briefly discussed Sheriff duties and my first Sheriff duty experience. This week, I have relinquished and passed on my Sheriff duties to my classmate &lt;a href="https://github.com/Rachit1313" rel="noopener noreferrer"&gt;Rachit&lt;/a&gt;. With my duties passed on, this week was more relaxing for me, although I still try to remain available on the Discord server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pull Requests
&lt;/h2&gt;

&lt;p&gt;For this week, I've contributed two Pull Requests to ChatCraft: a UI fix and a packaging task.&lt;/p&gt;

&lt;h3&gt;
  
  
  UI Fix: &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/379" rel="noopener noreferrer"&gt;Broken Iframe Autoresize&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;You can ask ChatCraft to generate HTML files for you, and ChatCraft will render and preview those HTML files to you (conversation available &lt;a href="https://chatcraft.org/api/share/rjwignar/OhTT7enSHfxMSwb_OuEyA" rel="noopener noreferrer"&gt;here&lt;/a&gt;):&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7yi6vtfeqa48203n4uq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7yi6vtfeqa48203n4uq.png" alt="Image description" width="800" height="695"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The HTML preview is contained in an &lt;a href="https://github.com/davidjbradshaw/iframe-resizer-react" rel="noopener noreferrer"&gt;IframeResizer&lt;/a&gt;, which we want to automatically resize to fit HTML previews content.&lt;/p&gt;

&lt;p&gt;The issue here was the last line that could fit in a preview would be cut off:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2nmu73rc3l14a53okou7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2nmu73rc3l14a53okou7.png" alt="Image description" width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/408" rel="noopener noreferrer"&gt;My solution&lt;/a&gt;
&lt;/h4&gt;

&lt;p&gt;The IframeResizer &lt;a href="https://github.com/davidjbradshaw/iframe-resizer/blob/master/docs/parent_page/options.md#heightcalculationmethod" rel="noopener noreferrer"&gt;heightCalculationMethod&lt;/a&gt; option calculates the iFrame height by converting the body margin to px then adding the top and bottom figures to the body tag's offSetHeight (bodyOffSet).&lt;/p&gt;

&lt;p&gt;There are four main possible values for &lt;code&gt;heightCalculationMethod&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;(default) bodyOffset&lt;/strong&gt; uses &lt;code&gt;document.body.offsetHeight&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;bodyScroll&lt;/strong&gt; uses &lt;code&gt;document.body.scrollHeight&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;documentElementOffset&lt;/strong&gt; uses &lt;code&gt;document.documentElement.offsetHeight&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;documentElementScroll&lt;/strong&gt; uses &lt;code&gt;document.documentElement.scrollHeight&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is also a &lt;code&gt;heightCalculationMethod&lt;/code&gt; value of &lt;strong&gt;max&lt;/strong&gt;, which uses the largest value of the above 4. I found that using a &lt;code&gt;heightCalculationMethod&lt;/code&gt; value of &lt;strong&gt;max&lt;/strong&gt; fixes the issue by rendering the entire content. Rendering the entire content eliminates the need of a scrollbar in these preview renders, so I removed the scrollbar as well.&lt;/p&gt;

&lt;h3&gt;
  
  
  Publishing Task: &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/324" rel="noopener noreferrer"&gt;Package and Publish github-to-sops to PyPI&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This task isn't exactly a ChatCraft feature, but it's an important part of our secrets management. ChatCraft uses &lt;a href="https://github.com/getsops/sops" rel="noopener noreferrer"&gt;sops&lt;/a&gt; to manage and share secrets, and the owner, &lt;a href="https://github.com/tarasglek" rel="noopener noreferrer"&gt;Taras&lt;/a&gt; wrote &lt;a href="https://github.com/tarasglek/github-to-sops" rel="noopener noreferrer"&gt;github-to-sops&lt;/a&gt; to make working with sops easier.&lt;/p&gt;

&lt;p&gt;You can clone and use &lt;code&gt;github-to-sops&lt;/code&gt; on your local machine, but wouldn't it be better to install it with &lt;a href="https://pypi.org/project/pip/" rel="noopener noreferrer"&gt;pip&lt;/a&gt; instead? With my &lt;a href="https://github.com/tarasglek/github-to-sops/pull/3" rel="noopener noreferrer"&gt;Pull Request&lt;/a&gt;, I was able to package and ship &lt;code&gt;github-to-sops&lt;/code&gt; to the &lt;a href="https://pypi.org/" rel="noopener noreferrer"&gt;Python Package Index (PyPI)&lt;/a&gt;. You can see its entry &lt;a href="https://pypi.org/project/github-to-sops/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  How I packaged a Python Package for the first time
&lt;/h4&gt;

&lt;p&gt;Packaging Python packages for PyPI requires a specific kind of project directory structure that &lt;code&gt;github-to-sops&lt;/code&gt; didn't have at the time. Before I could publish &lt;code&gt;github-to-sops&lt;/code&gt; to PyPI I had to first modify its directory structure. I don't often write programs in Python, so this task would've been very difficult to do on my own. This would end up being the first Python Package I've published, and ironically it's not one I developed myself.&lt;/p&gt;

&lt;h4&gt;
  
  
  Publishing to PyPI with Simonw's CookieCutter Template
&lt;/h4&gt;

&lt;p&gt;Luckily, &lt;a href="https://github.com/simonw" rel="noopener noreferrer"&gt;Simon Willison&lt;/a&gt; (&lt;a href="https://www.djangoproject.com/" rel="noopener noreferrer"&gt;django&lt;/a&gt; co-creator) created a &lt;a href="https://github.com/simonw/python-lib-template-repository" rel="noopener noreferrer"&gt;cookiecutter template&lt;/a&gt; that creates a Python project with a suitable directory structure and all files required to publish a Python project to PyPI. The template even generates two workflow files - one for unit tests and &lt;a href="https://github.com/simonw/python-lib-template-repository/blob/main/.github/workflows/publish.yml" rel="noopener noreferrer"&gt;another one that publishes GitHub releases&lt;/a&gt; to PyPI. Simon wrote more details on his template in &lt;a href="https://simonwillison.net/2024/Jan/16/python-lib-pypi/" rel="noopener noreferrer"&gt;this blog post&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;This template provided two important things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An appropriate package directory structure&lt;/li&gt;
&lt;li&gt;A publishing workflow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The publishing workflow was especially helpful, as it automatically publishes new GitHub releases. Thanks, Simon!&lt;/p&gt;

&lt;p&gt;To package &lt;code&gt;github-to-sops&lt;/code&gt;, I used Simon's &lt;a href="https://github.com/simonw/python-lib-template-repository" rel="noopener noreferrer"&gt;template&lt;/a&gt; to generate a sample GitHub project, and then I copied appropriate files and mimicked the directory structure in &lt;code&gt;github-to-sops&lt;/code&gt;. One thing &lt;code&gt;github-to-sops&lt;/code&gt; doesn't require at the moment is unit tests (though it'd be nice to have!), so testing-related artifacts were not copied over. This also required removing the &lt;code&gt;test&lt;/code&gt; step in the publish workflow.&lt;/p&gt;

&lt;h4&gt;
  
  
  Iterating on initial releases
&lt;/h4&gt;

&lt;p&gt;Using Simon's template, I was able to successfully package and publish &lt;code&gt;github-to-sops&lt;/code&gt; to PyPI, but version 1.0.0 had a major issue: it was published as a &lt;a href="https://packaging.python.org/en/latest/guides/packaging-namespace-packages/" rel="noopener noreferrer"&gt;namespace package&lt;/a&gt; that you would import in Python code. This wasn't ideal, as &lt;code&gt;github-to-sops&lt;/code&gt; is a command-line tool.&lt;/p&gt;

&lt;p&gt;To fix this, I would have to somehow package &lt;code&gt;github-to-sops&lt;/code&gt; as a command-line tool. Simon's template brought me far enough, it was time for me to research and experiment the rest of the way. Ultimately, it was a combination of &lt;a href="https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html" rel="noopener noreferrer"&gt;documentation&lt;/a&gt; and conversations with &lt;a href="https://chatcraft.org/api/share/rjwignar/sJ0JkX4jaEgkJrSM2APns" rel="noopener noreferrer"&gt;ChatCraft&lt;/a&gt; that helped me figure it out.&lt;/p&gt;

&lt;p&gt;After &lt;a href="https://github.com/tarasglek/github-to-sops/pull/8" rel="noopener noreferrer"&gt;renaming folders&lt;/a&gt; and properly &lt;a href="https://github.com/tarasglek/github-to-sops/pull/10/files" rel="noopener noreferrer"&gt;setting up custom discovery&lt;/a&gt; I was able to get &lt;code&gt;github-to-sops&lt;/code&gt; packaged to PyPI as a command-line tool (&lt;strong&gt;version 1.1.4&lt;/strong&gt;):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsipqwivzsb0ybevx77on.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsipqwivzsb0ybevx77on.png" alt="Image description" width="800" height="130"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I must admit that this process was frustrating at times, but the sense of accomplishment I felt after pulling it off was well worth it, and I now have a better idea of packaging and publishing to PyPI, thanks to Simon and ChatCraft.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next week in ChatCraft
&lt;/h2&gt;

&lt;p&gt;Next week, I'll be looking into extending Mingming's Image Input feature with text file inputs. Stay tuned until then.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>beginners</category>
      <category>opensource</category>
      <category>openai</category>
    </item>
    <item>
      <title>ChatCraft Adventures #4</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sat, 03 Feb 2024 04:15:02 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-adventures-4-50o7</link>
      <guid>https://dev.to/rjwignar/chatcraft-adventures-4-50o7</guid>
      <description>&lt;h2&gt;
  
  
  ChatCraft Week 4
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ChatCraft First Release
&lt;/h3&gt;

&lt;p&gt;Today marks the completion of Release 1.1.0 of &lt;a href="https://chatcraft.org/" rel="noopener noreferrer"&gt;ChatCraft&lt;/a&gt;. In this release, my colleagues and I shipped various new features and UI changes. For now, releases mainly serve as project milestones, but it is available &lt;a href="https://github.com/tarasglek/chatcraft.org/releases/tag/v1.1.0" rel="noopener noreferrer"&gt;here&lt;/a&gt; for those interested.&lt;/p&gt;

&lt;p&gt;This week also marks some 'firsts' for me in terms of leadership roles, mainly playing as a project 'Sheriff' and leading triage meetings.&lt;/p&gt;

&lt;h3&gt;
  
  
  My First Sheriff Experience
&lt;/h3&gt;

&lt;p&gt;Each week, someone in my class takes on the role of Sheriff. The Sheriff's role is to steward a project and to help developers get their code shipped to the project cleanly, without breaking any tests, CI or infrastructure. The Sheriff isn't meant to fix every problem, but should help shine a light on problems and coordinate efforts to make fixes and ensure decisions are made quickly.&lt;/p&gt;

&lt;p&gt;This week is the first week Sheriff duties are passed to students, and I ended up volunteering to take on the first week of duties. I still have a few days left of Sheriff duty, but for now I'll write on my duties so far.&lt;/p&gt;

&lt;h3&gt;
  
  
  My First Triage Meeting
&lt;/h3&gt;

&lt;p&gt;It's important to keep a project in an active, healthy state. This includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reviewing list of open issues&lt;/li&gt;
&lt;li&gt;ensuring pull requests are reviewed in a timely manner&lt;/li&gt;
&lt;li&gt;unblocking people from accomplishing tasks&lt;/li&gt;
&lt;li&gt;ensure any stuck issues/pull requests are identified and resourced&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Holding a Triage meeting is one way to fulfilling the above. For my class, each triage meeting is run by the Sheriff for the week. Since I'm the Sheriff for this week, this was my first time running a triage meeting&lt;/p&gt;

&lt;h3&gt;
  
  
  My experience
&lt;/h3&gt;

&lt;p&gt;In past classes, I've passively led group project meetings (led meetings when no one else wanted to). However, this was my first time actively leading a meeting like this.&lt;/p&gt;

&lt;p&gt;When leading the triage meeting, I tried to focus on unblocking people from getting their work done. If people can't finish their pull requests for whatever reason, pull requests can go stale and a project can eventually become inactive. So for this meeting I checked the status of active Pull Requests and tried to assign resources (assign classmates as PR reviewers or provide expertise on a certain topic) to get Pull Requests merged by the end of this milestone.&lt;/p&gt;

&lt;p&gt;Along with running the triage meeting, I also had to keep track of active issues/PRs for this week's release. If an Issue or PR was losing traction, I've been able to ping classmates on Discord or Microsoft Teams for status updates. In one case I reviewed a PR to get conversations started.&lt;/p&gt;

&lt;p&gt;However, one close call occurred on my first day of Sheriff duty. My classmate Amnish added a really cool Text-to-Speech feature to ChatCraft, but a bug was discovered after shipping that caused the text-to-speech to play even when disabled, but I was preparing dinner at the time and didn't think to check the feature after it was merged. I'm fortunate and glad that my colleagues were available to identify and quickly resolve the issue, but I think in that moment I didn't live up to my role as Sheriff. In future Sheriff duties, I will check the repo and Discord server more frequently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Contributions
&lt;/h2&gt;

&lt;p&gt;Apart from my Sheriff duties, this week I contributed some UI fixes to ChatCraft. I chose UI changes because I felt they are good first  issues to contribute to. It's often easy to locate where small changes are required, and if I need help, ChatCraft is available to push me in the right direction.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pull Requests
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Margin correction between button and content
&lt;/h4&gt;

&lt;p&gt;ChatCraft can render previews of HTML code, and there is a button available that lets you open the code in a new window, but the button previously cut into the preview content:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu2kve7942jv69b7aaktf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu2kve7942jv69b7aaktf.png" alt="Image description" width="800" height="575"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/376" rel="noopener noreferrer"&gt;Pull Request&lt;/a&gt; corrected the margin between the button and the preview content:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frq9psdodjyu16n4posle.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frq9psdodjyu16n4posle.png" alt="Image description" width="800" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Remove keyboard hints on mobile edit form
&lt;/h4&gt;

&lt;p&gt;You can edit queries in a ChatCraft conversation. The edit form shows a keyboard shortcut for saving your edited query, but this shortcut will clutter mobile screens:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn51727dso1t9mvi8mu7z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn51727dso1t9mvi8mu7z.png" alt="Image description" width="491" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A &lt;a href="https://github.com/tarasglek/chatcraft.org/blob/main/src/hooks/use-mobile-breakpoint.ts" rel="noopener noreferrer"&gt;React hook was previously implemented&lt;/a&gt; that detects whether the user is on a mobile device (in ChatCraft, mobile devices have a width equal to or below 480px). This hook is already used in other components, so in my &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/375" rel="noopener noreferrer"&gt;Pull Request&lt;/a&gt; I reused the hook to conditionally render the keyboard shortcut on non-mobile devices only:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa83iy6bue0h7it6uwzg6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa83iy6bue0h7it6uwzg6.png" alt="Image description" width="589" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far I've been using ChatCraft exclusively on desktop. However, I think it would be great to provide an amazing mobile experience to users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next week
&lt;/h2&gt;

&lt;p&gt;Next week I hope to contribute another UI fix and to work on slightly larger issues.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>beginners</category>
    </item>
    <item>
      <title>ChatCraft Adventures #3</title>
      <dc:creator>Roy J. Wignarajah</dc:creator>
      <pubDate>Sat, 27 Jan 2024 03:57:00 +0000</pubDate>
      <link>https://dev.to/rjwignar/chatcraft-adventures-3-4lng</link>
      <guid>https://dev.to/rjwignar/chatcraft-adventures-3-4lng</guid>
      <description>&lt;p&gt;This week I've been getting more involved in ChatCraft's development.&lt;br&gt;
This is what I've done so far.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I've been using ChatCraft
&lt;/h2&gt;

&lt;p&gt;To identify improvements or potential new features for ChatCraft I've been playing around with ChatCraft. Sometimes I ask ChatCraft to generate random code, but I've also found it helpful for my classwork.&lt;/p&gt;

&lt;p&gt;For example, in my capstone project I'm making a web app with my group. Part of our first sprint was initializing our app and setting up Customer Identity and Access Management (CIAM) using &lt;a href="https://aws.amazon.com/pm/cognito/" rel="noopener noreferrer"&gt;Amazon Cognito&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In a previous course I've integrated AWS Cognito with a barebones web app (simple HTML pages with no framework). However, my group is using &lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;NextJS&lt;/a&gt; to write our project, which requires different steps for integration. Integration involved using &lt;a href="https://next-auth.js.org/" rel="noopener noreferrer"&gt;NextAuth.js&lt;/a&gt;, which I've never used before.&lt;/p&gt;

&lt;p&gt;I was able to do most of the integration, but in the end I encountered an issue, in which logging out of the web app doesn't actually sign the user out of the Cognito user pool.&lt;/p&gt;

&lt;p&gt;ChatCraft was able to help me figure out the issue, and even suggested the fix for my code. My conversation with ChatCraft is available &lt;a href="https://chatcraft.org/c/rjwignar/V1Y6R3BuEDYVlvTiGbY-N" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pull Request Reviews
&lt;/h2&gt;

&lt;p&gt;My classmates have been working on various feature additions and chores on ChatCraft. I've had to chance to review a couple of them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Text to Speech (TTS) Support
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Speech_synthesis" rel="noopener noreferrer"&gt;Speech synthesis/text-to-speech&lt;/a&gt; produces speech from text, and my classmate Amnish is working on a version of &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/357" rel="noopener noreferrer"&gt;text-to-speech support in ChatCraft&lt;/a&gt;. I wasn't comfortable speaking on the new code, as I wasn't familiar with &lt;a href="https://platform.openai.com/docs/guides/text-to-speech?lang=node" rel="noopener noreferrer"&gt;OpenAI's audio API&lt;/a&gt;. I instead played around with the build and tested the UI and text-to-speech features.&lt;/p&gt;

&lt;h3&gt;
  
  
  Open Code in New Window
&lt;/h3&gt;

&lt;p&gt;Previously, when ChatCraft generates wide code it can be hard to see on ChatCraft:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0i8hed7a6b5yk51qu19.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd0i8hed7a6b5yk51qu19.png" alt="Image description" width="752" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My classmate, Yumei, made a recently-merged PR that adds a button that &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/361" rel="noopener noreferrer"&gt;opens code in a new tab&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo8oyee5gbnqujvtpzobf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo8oyee5gbnqujvtpzobf.png" alt="Image description" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When reviewing this PR, I was able to find a small UI bug. As a dark-mode user, I noticed the new button was missing a dark mode coloring:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifghf9e9p6dgj2l5s3t4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifghf9e9p6dgj2l5s3t4.png" alt="Image description" width="188" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By looking at how the other buttons are coloured in dark mode, I was able to suggest a solution to this bug and become more familiar with ChatCraft's code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Image as Input
&lt;/h3&gt;

&lt;p&gt;This is a really neat feature my classmate Mingming has been working on. It allows you to &lt;a href="https://github.com/tarasglek/chatcraft.org/pull/286" rel="noopener noreferrer"&gt;send images as input to ChatCraft&lt;/a&gt;.&lt;br&gt;
Here's what it looks like in action:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgk7r8du6n9givvny0f4z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgk7r8du6n9givvny0f4z.png" alt="Image description" width="800" height="714"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a really cool feature, although I wasn't comfortable enough to review the code. For now, I've only reviewed the functionalities and UI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Issues
&lt;/h2&gt;

&lt;p&gt;Playing around with ChatCraft has helped me brainstorm potential features or UI changes. For now I've been identify one possible UI change. When ChatCraft generates code like HTML, it also renders a preview that you can open in a new tab. However, I noticed that the &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/367" rel="noopener noreferrer"&gt;button that opens the preview protrudes into it&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fddobadyhdlk9noph4vxi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fddobadyhdlk9noph4vxi.png" alt="Image description" width="800" height="188"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another issue I'm working on is &lt;a href="https://github.com/tarasglek/chatcraft.org/issues/289" rel="noopener noreferrer"&gt;ensuring keyboard hints don't appear on mobile&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I hope to have PRs for these issues submitted this weekend.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
