fix: repair chat playground mobile layout#74
Merged
Conversation
The playground was broken on phones: the route nests section.wrap inside the root main.wrap, so .chat-shell was padded twice and collapsed to ~247px on a 375px screen. The send button was also clipped off-screen — a flex-1 textarea with no min-width:0 refused to shrink below its content width and pushed the button out. - styles.css: claw back one --pad each side of .chat-shell below 768px so the playground uses the full phone width. - PromptInput: add min-w-0 to the textarea; lift its text state to a controlled value/onChange pair. - ChatPlayground: fill the empty message void with a welcome line and three example prompts that pre-fill the input on click.
There was a problem hiding this comment.
Pull request overview
This PR fixes the chat playground’s mobile layout issues by compensating for doubled horizontal padding in the chat route and addressing a flexbox shrink issue in the prompt input, while also improving the empty-state UX with clickable example prompts.
Changes:
- Add a mobile-only negative margin on
.chat-shellto neutralize the double.wrappadding on chat routes. - Convert
PromptInputto a controlled component and addmin-w-0to the textarea so the Send button no longer gets pushed off-screen. - Add an empty-state to
ChatPlaygroundwith example prompts that prefill (but don’t auto-send) the input.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/cockpit-public/src/styles.css | Mobile CSS adjustment to reclaim width lost to nested .wrap padding in chat routes. |
| apps/cockpit-public/src/components/ChatPlayground/PromptInput.tsx | Make input controlled and fix flex shrink behavior on mobile via min-w-0. |
| apps/cockpit-public/src/components/ChatPlayground/ChatPlayground.tsx | Add empty-state UI and wire controlled input state into PromptInput. |
| apps/cockpit-public/tests/components/PromptInput.test.tsx | Update tests to use a state harness matching the new controlled PromptInput API. |
Comments suppressed due to low confidence (1)
apps/cockpit-public/src/components/ChatPlayground/PromptInput.tsx:201
- The Send button is icon-only and currently has no accessible name. Add an
aria-label(or visually-hidden text) so screen readers can announce it and tests can query it by name instead of relying on positional selection.
<button
type="button"
onClick={handleSubmit}
disabled={!canSend}
className="rounded bg-emerald-600 px-4 text-white disabled:opacity-50"
>
<Send size={16} />
</button>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problème
Le playground de chat (
/chat/$owner/$name) était cassé sur mobile : panneaux qui se chevauchent, traits de bordure parasites, bouton d'envoi coupé hors écran.Deux causes :
.wrap— le layout racine enveloppe tout dans<main className="wrap">(padding--pad). La route chat ré-applique.wrapsur sa<section>→ padding compté deux fois. Sur 375 px,.chat-shelltombait à 247 px au lieu de 311 (la page d'accueil annule ça avec unmarginnégatif ; la route chat, non).<textarea>estflex-1sansmin-width: 0: il refuse de rétrécir sous sa largeur de contenu et pousse le bouton d'envoi hors de l'écran.Correctif (périmètre : réparer le mobile + état vide ; desktop inchangé)
styles.css— sous 768 px, marge négative d'un--padde chaque côté sur.chat-shell→ le playground reprend toute la largeur du téléphone (247 → 311 px).PromptInput—min-w-0sur le textarea (le bouton d'envoi reste dans les clous) ; le composant passe en contrôlé (value/onChange) —PromptInput.test.tsxmis à jour avec un harnais d'état.ChatPlayground— le grand vide avant le premier message reçoit un état d'accueil : une ligne + 3 prompts d'exemple cliquables qui pré-remplissent la saisie.Style desktop conservé (Tailwind) conformément au périmètre choisi.
Vérification
biome check+tsc --noEmitOK ·vitest16/16.docScrollW=375(zéro débordement),.chat-shell=311 px, bouton d'envoi dans les bornes.Hors périmètre
Le playground reste en Tailwind générique (slate/emerald), visuellement décorrélé du design system « papier/encre » du reste du site —
styles.csscontient pourtant déjà un jeu de classes.chat-banner/.msg/.chat-inputinutilisé. Recâbler le composant dessus serait l'amélioration esthétique de fond, à planifier séparément.