Keep a job pill's status in sight at every width
Ruling R26: a ready or done pill no longer hides its status beside its link on a narrow chat. The title is cut short first; the status keeps its whole width up to half the pill (shrinking by even a sliver drew an ellipsis), and only then is cut short. TestAskJobStatusStaysVisible checks the default desktop and a 390px phone: the status is drawn, the title is cut first, measured to the fraction of a pixel.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+71
−10
docs/copy-pending.md+1 −1internal/browsertest/cards_test.go+62 −0internal/look/static/app.css+8 −9
diff --git a/docs/copy-pending.md b/docs/copy-pending.md| index 752a620..7c165f7 100644 |
| --- a/docs/copy-pending.md |
| +++ b/docs/copy-pending.md |
| @@ -376,4 +376,4 @@ Pending review (Task 18, job pills): a job shows as a pill in the chat. Its titl |
| | File | Context | Text | |
| |---|---|---| |
| | partials/chat.html, ask.js | PENDING: a job's pill, between the job's title and its status (drawn by the stylesheet, app.css) | {title} · {status} | |
| -| partials/chat.html, ask.js | PENDING: the pill's name for screen readers, which also says the status when a narrow chat hides it beside the link | {title}, {status} | |
| +| partials/chat.html, ask.js | PENDING: the pill's name for screen readers | {title}, {status} | |
diff --git a/internal/browsertest/cards_test.go b/internal/browsertest/cards_test.go| index 0078b20..008d596 100644 |
| --- a/internal/browsertest/cards_test.go |
| +++ b/internal/browsertest/cards_test.go |
| @@ -216,3 +216,65 @@ func TestAskJobKeepsItsCards(t *testing.T) { |
| t.Errorf("the thread: %s", got) |
| } |
| } |
| + |
| +// statusShownJS checks the pill of job id: its status is drawn (a box with |
| +// width, neither display:none nor visibility:hidden) and its title is cut |
| +// short with an ellipsis before the status is; "" when both hold. |
| +func statusShownJS(id string) string { |
| + return `(() => { const j = document.querySelector('#ask-panel li.job[data-job="` + id + `"]'); |
| + if (!j) return "no job"; |
| + const s = j.querySelector(".pill-stage"), t = j.querySelector(".pill-title"), cs = getComputedStyle(s), p = []; |
| + if (cs.display === "none" || cs.visibility === "hidden" || s.getBoundingClientRect().width < 1 || !s.checkVisibility({ visibilityProperty: true })) p.push("the status is not drawn"); |
| + if (t.scrollWidth <= t.clientWidth) p.push("the title is not cut short"); |
| + // The status is cut short only once the title is down to its least |
| + // (measured to the fraction of a pixel: a sliver less already draws |
| + // an ellipsis). |
| + const drawn = s.getBoundingClientRect().width; |
| + s.style.flex = "none"; |
| + const whole = s.getBoundingClientRect().width; |
| + s.style.flex = ""; |
| + if (whole - drawn > 0.01 && t.getBoundingClientRect().width > parseFloat(getComputedStyle(t).minWidth) + 1) p.push("the status is cut short before the title: " + drawn + "px of " + whole); |
| + if (!j.querySelector(".pill-link")) p.push("no link"); |
| + const pill = j.querySelector(".pill").getBoundingClientRect(), log = document.querySelector("#ask-panel .thread").getBoundingClientRect(); |
| + if (pill.right > log.right + 0.5) p.push("the pill overflows the chat"); |
| + return p.join("; "); })()` |
| +} |
| + |
| +// Ruling R26: a ready or done pill keeps its status in sight at every |
| +// width, beside its link: on the default desktop's docked chat and on a |
| +// phone, a long title is cut short first. |
| +func TestAskJobStatusStaysVisible(t *testing.T) { |
| + const title = "Building a website about disability benefits in Ireland now" |
| + for _, view := range []struct { |
| + name string |
| + act chromedp.Action[chromedp.Void] |
| + }{ |
| + {"desktop", nil}, |
| + {"phone", chromedp.EmulateViewport(390, 844, chromedp.EmulateMobile, chromedp.EmulateScale(3))}, |
| + } { |
| + t.Run(view.name, func(t *testing.T) { |
| + rig, f, _ := askBaseOn(t, nil, view.act) |
| + if view.act == nil { |
| + openPanel(t, rig) |
| + } else { |
| + // On a phone the chat opens full screen from the field on Home. |
| + drive(t, rig, chromedp.Navigate(rig.Origin+"/"), chromedp.WaitVisible(chromedp.CSS("a.ask-field")), |
| + chromedp.Click(chromedp.CSS("a.ask-field")), chromedp.WaitVisible(chromedp.CSS(`#ask-panel textarea`)), |
| + chromedp.Poll[chromedp.Void](readJS, chromedp.WithPollingTimeout(5*time.Second))) |
| + } |
| + id := f.AskJob(title) |
| + for _, st := range []struct{ state, result, label string }{{"ready", "Ready to try", "Try it"}, {"done", "Done", "Open your site"}} { |
| + f.SetJob(id, st.state, st.result, "One sentence more.", equipo.Link{Label: st.label, URL: "https://site.example.test/"}) |
| + drive(t, rig, chromedp.Poll[chromedp.Void](`document.querySelector('#ask-panel li.job')?.dataset.state === "`+st.state+`"`, |
| + chromedp.WithPollingTimeout(10*time.Second))) |
| + // Measured in the page's own font, once it has loaded. |
| + drive(t, rig, chromedp.Poll[chromedp.Void](`document.fonts.status === "loaded"`, chromedp.WithPollingTimeout(10*time.Second)), |
| + chromedp.Sleep(100*time.Millisecond)) |
| + if got := harness.Evaluate[string](rig, statusShownJS(id)); got != "" { |
| + t.Errorf("%s, %s: %s", view.name, st.state, got) |
| + } |
| + mobileShot(t, rig, "job-"+st.state+"-"+view.name) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/look/static/app.css b/internal/look/static/app.css| index c76e981..724a61d 100644 |
| --- a/internal/look/static/app.css |
| +++ b/internal/look/static/app.css |
| @@ -519,8 +519,9 @@ aside.ask-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; widt |
| /* A job: a compact pill in the conversation, updated in place. A capsule, |
| not a bubble: its own surface and edge, a lift, a state mark on the left |
| and the state's colour washed in behind it. One line: when space runs |
| - short the status gives way first (down to a few letters), then the |
| - title; the link beside it never does. */ |
| + short the title is cut short first (down to a few letters), then the |
| + status; the status never goes, and the link beside it never shrinks |
| + (ruling R26). */ |
| .job { align-self: flex-start; max-width: 100%; display: flex; flex-direction: column; gap: 6px; } |
| .job[data-state="working"], .job[data-state="ready"], .job[data-state="done"] { --st: var(--signal); } |
| .job[data-state="asking"] { --st: var(--st-ask); } |
| @@ -534,17 +535,15 @@ aside.ask-panel { position: absolute; top: 16px; right: 16px; bottom: 16px; widt |
| list-style: none; cursor: pointer; font-size: 13.5px; line-height: 20px; white-space: nowrap; } |
| .pill-main::-webkit-details-marker { display: none; } |
| .pill-main:focus-visible { outline-offset: 2px; } |
| -.pill-title { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; } |
| -.pill-stage { flex: 0 1000 auto; min-width: 4.5em; overflow: hidden; text-overflow: ellipsis; color: var(--haze); font-size: 13px; } |
| +.pill-title { flex: 0 1 auto; min-width: 3em; overflow: hidden; text-overflow: ellipsis; font-weight: 600; } |
| +/* The status keeps its whole width (a share that shrinks by a sliver |
| + already draws an ellipsis) up to half the pill; only a longer one is |
| + cut short. */ |
| +.pill-stage { flex: none; min-width: 3em; max-width: 50%; overflow: hidden; text-overflow: ellipsis; color: var(--haze); font-size: 13px; } |
| .pill-stage::before { content: "·"; margin: 0 6px 0 0; } |
| .pill-link { flex: none; align-self: stretch; display: flex; align-items: center; margin-left: -5px; padding: 0 14px 0 10px; border-radius: 0 999px 999px 0; |
| font-size: 13.5px; font-weight: 600; color: var(--focus); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; |
| box-shadow: inset 1px 0 0 var(--pill-edge); } |
| -/* A narrow chat (the docked chat at its narrowest, small phones): when the |
| - pill carries a link, the link says the status ("Try it"), so the status |
| - steps out. It stays in the pill's accessible name. */ |
| -.thread { container-type: inline-size; } |
| -@container (max-width: 364px) { .pill:has(.pill-link) .pill-stage { display: none; } } |
| /* The state mark: a disc. Working is a slow arc round a breathing dot; the |
| rest are still icons on the state's colour. */ |
| .state-mark { flex: none; position: relative; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--on-signal); } |