diff --git a/docs/UI_SPEC.md b/docs/UI_SPEC.md index f2b920f..6d6a12f 100644 --- a/docs/UI_SPEC.md +++ b/docs/UI_SPEC.md @@ -67,7 +67,7 @@ For a draft in the cloud, on a server that can publish (`githubPublish` in `/api - **Top bar:** one row from 640px (it wraps onto a second row only when the window is too narrow for everything). Left to right: drafts toggle (phones) · wordmark link with the release (`v0.2.0`, from package.json; hidden below 640px) and current title · target-profile Select (GFM extended, Strict CommonMark, GFM without HTML, Wiki notes; remembered per device) · view switch (Editor, Split, Preview as three icon buttons; Split hidden on phones) · panel buttons (768 to 1279px only) · Install (only when the browser offers to install the app) · AI writer · Import dropdown (files or a ZIP, or a folder) · **Export** · **Share**. On a phone the Select and the view switch form a second row. - **Export / Publish:** one button. For a draft that is not in the cloud (or on a server that cannot publish) it is **Export**; for a cloud draft on a server that can publish to GitHub it is **Publish**, and its menu starts with a **Publish** section (Publish to GitHub) above the same Markdown, HTML and All drafts sections and the "Normalize on export" switch. Labels show from 1024px; below that only the icons. - **Share:** one button, for cloud drafts only. It opens a "Share this draft" dialog with two choices: **Share for review** (the Share dialog below: a link readers can comment on) and **Edit together** (the invitation dialog below). The drafts menu keeps both as separate items. -- **Account:** the avatar (signed in: the menu with "Choose drafts for the cloud", "Manage images", Account, Settings, Admin dashboard and "Sign out"; signed out: Sign in and create an account, with "Forgot your password?" when the server sends mail and a `/reset-password` page for the emailed link; optional; "Continue with Google" and "Continue with GitHub" when the server has them) sits at the foot of the side strip from 1280px, and at the end of the top bar below that. The drafts list shows "Cloud: n of 5 drafts", a cloud icon on drafts stored in the account, and "Save to cloud" / "Remove from cloud" in each draft's menu. +- **Account:** the avatar (signed in: the menu with "Choose drafts for the cloud", "Manage images", Account, Settings, Admin dashboard and "Sign out"; signed out: Sign in and create an account, with "Forgot your password?" when the server sends mail and a `/reset-password` page for the emailed link; optional; "Continue with Google" and "Continue with GitHub" when the server has them) sits at the foot of the side strip from 768px, and at the end of the top bar on phones. The drafts list shows "Cloud: n of 5 drafts", a cloud icon on drafts stored in the account, and "Save to cloud" / "Remove from cloud" in each draft's menu. - **Top bar, row 2:** target-profile Select (GFM extended, Strict CommonMark, GFM without HTML, Wiki notes; remembered per device) · view toggle (Editor / Split / Preview) · panel buttons on mid-size screens. - **Export dropdown:** Download .md, Copy Markdown, Download self-contained .md and Copy self-contained Markdown (both enabled only when the draft has local images), Copy rendered HTML, Download standalone .html, and the "Normalize on export" switch. - **Drafts sidebar:** New folder and New draft buttons, a search box, tag chips, and a folder tree. Search matches every word in a draft's title or text (a matching line is shown under the title); tag chips come from each draft's front matter `tags` and narrow the list when selected. Folders are labels kept in the library, not in the text: they list first (A to Z, collapsible, drafts indented beneath them with a guide line) and unfiled drafts follow. A draft moves by dragging it onto a folder, or onto the empty part of the list to take it out, and also from its three-dot menu (Rename, Move to folder, Save to cloud or Remove from cloud, then for a cloud draft Share, Publish (where the server can publish to GitHub) and Host images (where the server hosts them and the draft has local images), Duplicate, Delete; no item ends in an ellipsis), which is the route on touch screens. A folder's menu has Rename folder (an inline field with save and cancel; the drafts follow, and a name another folder already has is refused) and Delete folder: an empty one goes at once, one with drafts asks first because the drafts inside are deleted too. A folder also goes when its last draft is deleted (here or on another device); moving the last draft out leaves it. Delete opens a confirmation Dialog. @@ -123,7 +123,7 @@ Only for an admin; anyone else sees the site's 404. Reached from "Admin dashboar ## 6b. Settings: `/settings` -Opened from the Account menu (**Account** opens the Account tab, **Settings** the Editor tab), from the gear in the editor's side strip (and in its top bar below 1280px), and from the gear in the header of the public pages. The app frame (`AppShell`, as the dashboard): a top bar (on the page background, like the public header) with the logo, "/ Settings", a primary "Back to the editor" button and the account menu (its contents line up with the page's content below it), and the sections in a menu on the left (a row of chips on phones), with the open one in the address (`?tab=`). Each section has its title and a line under it, and its rows are grouped in bordered cards: **Account** (signed in only: picture, name and address; Display name, Email and Password rows, each with an Edit button that opens a dialog: the name field, the new address with the current password (a link is emailed to it and the address changes when it is opened; disabled for an account with no password, which sets one first), or the current and the new password (an account that signs in with GitHub or Google has no current one and sees Set password); changing the password signs the other devices out), then **Sign in with GitHub** and **Sign in with Google** rows (when the server has them) with Link, which leaves for the provider and comes back with a toast, or Unlink, disabled with an explanation while it is the only way to sign in). The profile sits in its own card, the sign-ins under a "Sign-in methods" heading., **Editor** (theme as a System | Light | Dark switch, target platform, Normalize on export, a button for the writing-check rules and one for keyboard shortcuts; all kept on this device), **AI** (opens the AI integrations dialog) and **Connections** (cloud drafts, hosted images when the server has them, and GitHub publishing with Connect or Disconnect; signed in only). A signed-out visitor sees only Editor and AI and cannot reach the others by address. The rules, shortcuts, AI, cloud-drafts and images dialogs are the same ones the editor opens, so they stay where they are used mid-task. noindex. +Opened from the Account menu (**Account** opens the Account tab, **Settings** the Editor tab), from the gear in the editor's side strip (and in its top bar on phones), and from the gear in the header of the public pages. The app frame (`AppShell`, as the dashboard): a top bar (on the page background, like the public header) with the logo, "/ Settings", a primary "Back to the editor" button and the account menu (its contents line up with the page's content below it), and the sections in a menu on the left (a row of chips on phones), with the open one in the address (`?tab=`). Each section has its title and a line under it, and its rows are grouped in bordered cards: **Account** (signed in only: picture, name and address; Display name, Email and Password rows, each with an Edit button that opens a dialog: the name field, the new address with the current password (a link is emailed to it and the address changes when it is opened; disabled for an account with no password, which sets one first), or the current and the new password (an account that signs in with GitHub or Google has no current one and sees Set password); changing the password signs the other devices out), then **Sign in with GitHub** and **Sign in with Google** rows (when the server has them) with Link, which leaves for the provider and comes back with a toast, or Unlink, disabled with an explanation while it is the only way to sign in). The profile sits in its own card, the sign-ins under a "Sign-in methods" heading., **Editor** (theme as a System | Light | Dark switch, target platform, Normalize on export, a button for the writing-check rules and one for keyboard shortcuts; all kept on this device), **AI** (the integrations listed in the card, each with its provider, Ready or Key needed, an Update button that opens the dialog on its form and a Remove button; an Add integration button opens the dialog on a blank form; the dialog closes after saving) and **Connections** (cloud drafts, hosted images when the server has them, and GitHub publishing with Connect or Disconnect; signed in only). A signed-out visitor sees only Editor and AI and cannot reach the others by address. The rules, shortcuts, AI, cloud-drafts and images dialogs are the same ones the editor opens, so they stay where they are used mid-task. noindex. ## 6b-2. Standalone screens and 404 @@ -136,8 +136,8 @@ A dialog for finding anything, on every page: Ctrl/⌘ Shift P anywhere, Ctrl/ ## 7. Small screens — `06_mobile_editor_view.png`, `07_mobile_preview_view.png` - **Below 768px** the studio is a single pane: the view toggle offers Editor and Preview only, and the panel buttons move to a bottom navigation bar. -- **Below 1280px** the drafts list and Checks, Outline, Front matter, History and Comments open as a sheet from the left, sharing the same components as the docked pane. -- **At 1280px and above** a Drafts button and the panel buttons (Checks, Outline, Front matter, History, Comments) sit in a 48px column at the left edge, with Search, the theme button and Settings at its foot (below 1280px they stay in the top bar), and beside them one docked pane that the drafts and the panels share: a panel takes the pane, pressing its button again closes it and gives the pane back to the drafts, and the Drafts button there (or the one in the top bar) shows or hides the list. There is no panel column on the right. The pane defaults to 288px and can be dragged (or resized with the arrow keys, Home and End; double-click resets) between 240px and 480px; the width is remembered. The drafts show first; Checks opens from its button. +- **Below 1280px** the drafts list and Checks, Outline, Front matter, History and Comments open as a sheet from the left (from the side strip, or on phones from the top bar's drafts button and the bottom bar), sharing the same components as the docked pane. +- **From 768px** (everything but phones) a Drafts button and the panel buttons (Checks, Outline, Front matter, History, Comments) sit in a 48px column at the left edge, with Search, the theme button, Settings and the account at its foot. **At 1280px and above**, beside them, one docked pane that the drafts and the panels share: a panel takes the pane, pressing its button again closes it and gives the pane back to the drafts, and the Drafts button there shows or hides the list (the top bar's drafts toggle exists only on phones). There is no panel column on the right. The pane defaults to 288px and can be dragged (or resized with the arrow keys, Home and End; double-click resets) between 240px and 480px; the width is remembered. The drafts show first; Checks opens from its button. ## Interactions diff --git a/e2e/collab-comments.spec.ts b/e2e/collab-comments.spec.ts index 69c046a..70a8c3b 100644 --- a/e2e/collab-comments.spec.ts +++ b/e2e/collab-comments.spec.ts @@ -106,7 +106,10 @@ test("stopping editing together keeps the open comments in the draft's History", await expect(panel(a).getByText("Please expand this")).toBeVisible(); // the panel shares the left pane with the drafts, whose menu has Share - await a.getByRole("banner").getByRole("button", { name: "Toggle drafts" }).click(); + await a + .getByRole("navigation", { name: "Panels" }) + .getByRole("button", { name: "Drafts" }) + .click(); const dialog = await openDialog(a); await expect( dialog.getByText(/Comments and suggestions end with editing together/), diff --git a/e2e/settings.spec.ts b/e2e/settings.spec.ts index 1f8c093..4239a20 100644 --- a/e2e/settings.spec.ts +++ b/e2e/settings.spec.ts @@ -129,3 +129,34 @@ test("the settings menu and content sit together in the middle of the page", asy expect(content.x).toBeGreaterThan(menu.x + menu.width); expect(Math.abs(menu.x - (1440 - (content.x + content.width)))).toBeLessThan(8); }); + +test("the AI tab lists the integrations, adds one from a dialog, and updates or removes it", async ({ + page, +}) => { + await page.goto("/settings?tab=ai"); + const section = page.getByRole("region", { name: "AI" }); + await expect(section.getByText("No integrations yet")).toBeVisible(); + await expect(section.getByRole("button", { name: "Manage" })).toHaveCount(0); + + // add one: the dialog opens on a blank form and closes once it is saved + await section.getByRole("button", { name: "Add integration" }).click(); + const dialog = page.getByRole("dialog", { name: "AI integrations" }); + await dialog.getByLabel("AI provider").click(); + await page.getByRole("option", { name: /Ollama/ }).click(); + await dialog.getByLabel("Model IDs").fill("llama3.2"); + await dialog.getByRole("button", { name: "Add integration" }).click(); + await expect(dialog).toBeHidden(); + await expect(section.getByText("No integrations yet")).toBeHidden(); + await expect(section.getByRole("listitem")).toHaveCount(1); + await expect(section.getByRole("listitem")).toContainText("Ollama"); + + // update it: straight to its form, and back to the page after saving + await section.getByRole("button", { name: "Update Ollama" }).click(); + await dialog.getByLabel("Name (optional)").fill("My local"); + await dialog.getByRole("button", { name: "Save" }).click(); + await expect(dialog).toBeHidden(); + await expect(section.getByRole("listitem")).toContainText("My local"); + + await section.getByRole("button", { name: "Remove My local" }).click(); + await expect(section.getByText("No integrations yet")).toBeVisible(); +}); diff --git a/e2e/studio.spec.ts b/e2e/studio.spec.ts index 61ceee7..c7a2260 100644 --- a/e2e/studio.spec.ts +++ b/e2e/studio.spec.ts @@ -196,7 +196,9 @@ test("the drafts and the panels share the pane on the left", async ({ page }) => await open(page); const panels = page.getByRole("navigation", { name: "Panels" }); const drafts = page.getByRole("complementary").getByRole("navigation", { name: "Drafts" }); - const toggle = page.getByRole("banner").getByRole("button", { name: "Toggle drafts" }); + const toggle = page + .getByRole("navigation", { name: "Panels" }) + .getByRole("button", { name: "Drafts" }); // the drafts show first, with the panel buttons to their left await expect(drafts).toBeVisible(); await expect(checks).toBeHidden(); @@ -1135,7 +1137,9 @@ test("in focus mode the drafts button opens the list as a panel and focus mode s }) => { await open(page); const focus = page.getByRole("toolbar").getByRole("button", { name: "Focus mode" }); - const toggle = page.getByRole("banner").getByRole("button", { name: "Toggle drafts" }); + const toggle = page + .getByRole("navigation", { name: "Panels" }) + .getByRole("button", { name: "Drafts" }); const sidebar = page.getByRole("complementary").getByRole("navigation", { name: "Drafts" }); // normal mode: the button still opens and closes the sidebar in place @@ -1242,14 +1246,25 @@ test("one button for what leaves the studio: Export for a local draft, with the await expect(bar.getByRole("button", { name: "preview view" })).toBeVisible(); }); -test("the account sits in the side strip from 1280px, and in the top bar below it", async ({ +test("the account sits in the side strip from 768px, and in the top bar on a phone", async ({ page, }) => { await page.setViewportSize({ width: 1440, height: 900 }); await open(page); - const strip = page.getByRole("navigation", { name: "Panels" }); + const strip = page.getByRole("navigation", { name: "Panels", exact: true }); + const bar = page.getByRole("banner"); await expect(strip.getByRole("button", { name: "Sign in" })).toBeVisible(); - await expect(page.getByRole("banner").getByRole("button", { name: "Sign in" })).toHaveCount(0); + await expect(bar.getByRole("button", { name: "Sign in" })).toHaveCount(0); + await expect(bar.getByRole("button", { name: "Toggle drafts" })).toHaveCount(0); + // a narrower window keeps the strip, with the search, theme and account in it await page.setViewportSize({ width: 1000, height: 800 }); - await expect(page.getByRole("banner").getByRole("button", { name: "Sign in" })).toBeVisible(); + await expect(strip.getByRole("button", { name: "Sign in" })).toBeVisible(); + await expect(strip.getByRole("button", { name: "Drafts" })).toBeVisible(); + await expect(bar.getByRole("button", { name: "Sign in" })).toHaveCount(0); + await expect(bar.getByRole("button", { name: "Toggle drafts" })).toHaveCount(0); + // only a phone drops the strip, and then the top bar has the account and the drafts toggle + await page.setViewportSize({ width: 600, height: 800 }); + await expect(strip).toBeHidden(); + await expect(bar.getByRole("button", { name: "Sign in" })).toBeVisible(); + await expect(bar.getByRole("button", { name: "Toggle drafts" })).toBeVisible(); }); diff --git a/src/components/PageLoader.tsx b/src/components/PageLoader.tsx new file mode 100644 index 0000000..8fe44b7 --- /dev/null +++ b/src/components/PageLoader.tsx @@ -0,0 +1,60 @@ +import { cn } from "@/lib/utils"; +import { Wordmark } from "@/components/Logo"; + +/** + * What a page shows while it loads: the mark, drawn stroke by stroke (the source page, the rendered + * page, then its lines) on a loop, with the name under it. Fills the space it is given. + */ +export function PageLoader({ + label = "Loading", + className, +}: { + label?: string; + className?: string; +}) { + return ( +
+ {state.cloud === "loading" ? "Loading your integrations" : "No integrations yet."} +
+ ) : ( +