fix(ui): show Draft mode once in new-session composer (#129858)

Co-authored-by: roboclaw-bot <309084314+roboclaw-bot@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
RoboClaw
2026-08-25 21:43:49 -07:00
committed by GitHub
parent 857f470c84
commit 37945f1fdf
3 changed files with 21 additions and 32 deletions
@@ -84,7 +84,7 @@ suite.define(() => {
(text) => text.replace(/\s+/g, " ").trim(),
),
)
.toEqual(["Draft", "3 session overrides"]);
.toEqual(["3 session overrides"]);
await page.locator(".new-session-page__message").fill("prepare the release");
await composer.getByRole("button", { name: "Start session" }).click();
@@ -96,9 +96,8 @@ export function renderNewSessionPlusMenu(
}
export function renderNewSessionSelectionStatus(options: NewSessionComposerCapabilityOptions) {
const draftEnabled = options.visibility === "draft";
const overrideCount = countSessionToolOverrides(options.toolOverrides);
if (!draftEnabled && overrideCount === 0) {
if (overrideCount === 0) {
return nothing;
}
const disabled = options.submitting || options.messageLocked === true;
@@ -108,30 +107,16 @@ export function renderNewSessionSelectionStatus(options: NewSessionComposerCapab
options.requestUpdate();
};
return html`
${draftEnabled
? html`<button
type="button"
class="new-session-page__selection-status"
?disabled=${disabled}
@click=${openMenu}
>
${icons.pencil}${t("newSession.draft")}
</button>`
: nothing}
${overrideCount > 0
? html`<button
type="button"
class="new-session-page__selection-status"
?disabled=${disabled}
@click=${openMenu}
>
${t(
overrideCount === 1
? "chat.composer.overrides.countOne"
: "chat.composer.overrides.count",
{ count: String(overrideCount) },
)}
</button>`
: nothing}
<button
type="button"
class="new-session-page__selection-status"
?disabled=${disabled}
@click=${openMenu}
>
${t(
overrideCount === 1 ? "chat.composer.overrides.countOne" : "chat.composer.overrides.count",
{ count: String(overrideCount) },
)}
</button>
`;
}
+8 -4
View File
@@ -627,20 +627,24 @@ describe("new-session composer attachment drops", () => {
expect(switches).toHaveLength(0);
});
it("lets the draft pill replace page-level incognito", () => {
it("lets one draft pill replace page-level incognito", () => {
const onVisibilityChange = vi.fn();
const { composer } = renderComposer({
draftAvailable: true,
visibility: "incognito",
visibility: "draft",
onVisibilityChange,
});
const draftPill = composer.querySelector<HTMLButtonElement>('[role="switch"]');
const visibleDraftButtons = Array.from(
composer.querySelectorAll<HTMLButtonElement>(".agent-chat__composer-footer button"),
).filter((button) => button.textContent?.trim() === "Draft");
expect(draftPill?.textContent).toContain("Draft");
expect(draftPill?.getAttribute("aria-checked")).toBe("false");
expect(draftPill?.getAttribute("aria-checked")).toBe("true");
expect(visibleDraftButtons).toEqual([draftPill]);
draftPill?.click();
expect(onVisibilityChange).toHaveBeenCalledWith("draft");
expect(onVisibilityChange).toHaveBeenCalledWith("normal");
});
it("adds a dropped file through the shared attachment handling", async () => {