<?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: Karl Djansi</title>
    <description>The latest articles on DEV Community by Karl Djansi (@karldjansi123).</description>
    <link>https://dev.to/karldjansi123</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F99mvlsfu5tfj9m7ku25d.png</url>
      <title>DEV Community: Karl Djansi</title>
      <link>https://dev.to/karldjansi123</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karldjansi123"/>
    <language>en</language>
    <item>
      <title>Designing an Honest Loading State for AI UI Generation</title>
      <dc:creator>Karl Djansi</dc:creator>
      <pubDate>Mon, 26 Oct 2026 02:21:56 +0000</pubDate>
      <link>https://dev.to/karldjansi123/designing-an-honest-loading-state-for-ai-ui-generation-264j</link>
      <guid>https://dev.to/karldjansi123/designing-an-honest-loading-state-for-ai-ui-generation-264j</guid>
      <description>&lt;p&gt;A model taking a while is a backend problem. Making the whole editor look frozen while it waits is a product problem too.&lt;/p&gt;

&lt;p&gt;In Napkin, users describe a UI idea or upload a sketch and ask the app to generate a responsive HTML draft. When Gemini took close to two minutes, the existing draft stayed safe—but the feedback was a generic spinner over the editor. It obscured the workspace without showing where the result would appear.&lt;/p&gt;

&lt;h2&gt;
  
  
  Put the wait where the result will be
&lt;/h2&gt;

&lt;p&gt;For the first generation, the empty preview canvas now changes into a small animated mockup: a header, a feature card, and text blocks draw in while a subtle sweep passes over the frame. The animation lives inside the “Your idea goes here” canvas, not across the editor. A brief status label explains what is happening, and the existing draft remains visible during regeneration.&lt;/p&gt;

&lt;p&gt;The key idea is contextual feedback: make the loading state resemble the outcome, rather than covering the product with an unrelated spinner. The motion is CSS-based and the app already disables animation for users who prefer reduced motion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make the request bounded, not magical
&lt;/h2&gt;

&lt;p&gt;I also tightened the Gemini prompt, capped output at 8,192 tokens, and shortened the request timeout to 45 seconds. These changes constrain work and make a stalled request fail sooner; they do &lt;strong&gt;not&lt;/strong&gt; guarantee the model will return within that time. The client only replaces the current draft after a complete successful response, so a timeout does not erase work. This route still waits for the full response rather than streaming partial HTML.&lt;/p&gt;

&lt;p&gt;The relevant request settings are intentionally small:&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="nx"&gt;generationConfig&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;temperature&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;maxOutputTokens&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8192&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="nx"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AbortSignal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;45&lt;/span&gt;&lt;span class="nx"&gt;_000&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A good loading state improves the wait, but it cannot make a slow provider fast. Keep the timeout message honest, preserve recoverable work, and measure actual provider latency separately from perceived responsiveness.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further reading
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;⚡ &lt;a href="https://dev.to/vectorchi/better-loading-states-for-ai-apps-3f0i"&gt;Better Loading States for AI Apps&lt;/a&gt; by &lt;a href="https://dev.to/vectorchi"&gt;@vectorchi&lt;/a&gt; argues that open-ended model waits need more useful feedback than a spinner.&lt;/li&gt;
&lt;li&gt;⏱️ &lt;a href="https://dev.to/rverwey/the-cost-of-a-pause-designing-for-the-doherty-threshold-4n2e"&gt;The Cost of a Pause: Designing for the Doherty Threshold&lt;/a&gt; by &lt;a href="https://dev.to/rverwey"&gt;@rverwey&lt;/a&gt; frames response feedback as part of the interaction, not merely a backend metric.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Napkin is open source: &lt;a href="https://github.com/nonydev27/napkin" rel="noopener noreferrer"&gt;nonydev27/napkin&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>react</category>
    </item>
  </channel>
</rss>
