From f84eea14551c13fa0169590109cf87b77fee6fb5 Mon Sep 17 00:00:00 2001 From: Leo310 Date: Thu, 26 Nov 2026 15:00:17 +0100 Subject: [PATCH 1/6] fix(mobile): drawer chat background and Cupertino prompt layout - A chat docked in a sidebar drawer painted the composer's fade band (and the top fade) in the page colour, a white slab on themes whose drawer uses --mobile-sidebar-background. - applyPromptSafeArea no longer moves a full-bleed theme's prompt down when its results list already pads past the island (Cupertino). The shift counted the inset twice and left an unblurred seam above the prompt. The model picker's filter bar now takes the inset itself, and the results' padding and fade mask are re-anchored below it. - The search modal's inline input drops the backdrop blur Cupertino puts on .prompt-input, which showed as a lighter rectangle inside the field. Co-Authored-By: Claude --- src/components/chat/Input.svelte | 15 ++++ src/components/modal/ModelSuggestModal.ts | 2 +- src/components/modal/promptLayout.ts | 86 ++++++++++++++++++----- src/styles.css | 6 ++ src/views/chat/Chat.svelte | 6 ++ 5 files changed, 98 insertions(+), 17 deletions(-) diff --git a/src/components/chat/Input.svelte b/src/components/chat/Input.svelte index 29a28e09a..4b14bfa6a 100644 --- a/src/components/chat/Input.svelte +++ b/src/components/chat/Input.svelte @@ -1543,6 +1543,21 @@ function withQuoteDestination(selection: SelectionRef): SelectionRef { background: linear-gradient(to bottom, transparent 0%, var(--background-primary) 24px) !important; } + /* A chat docked in a sidebar drawer sits on the drawer's own surface, not the + page: themes paint `.workspace-drawer` with `--mobile-sidebar-background` + (Cupertino: a grey distinct from the white page). The page-coloured band + above showed there as a white slab around the composer (verified + on-device). The composer is portaled straight into the drawer (see + `portalComposer`), so the ancestor selector matches it. */ + :global(.is-mobile .workspace-drawer .s2b-chat-input-container) { + background: linear-gradient( + to bottom, + transparent 0%, + var(--mobile-sidebar-background, var(--background-secondary)) 24px + ) + !important; + } + /* The wrapper's shape and internal rhythm live here, not in utility classes on the element (the markup carries only layout/transition utilities, so this block and the markup can't disagree about the design). All diff --git a/src/components/modal/ModelSuggestModal.ts b/src/components/modal/ModelSuggestModal.ts index 1e5c7fcbc..54613c625 100644 --- a/src/components/modal/ModelSuggestModal.ts +++ b/src/components/modal/ModelSuggestModal.ts @@ -81,7 +81,7 @@ export class ModelSuggestModal extends SuggestModal { onOpen(): void { void super.onOpen(); this.buildFilterBar(); - applyPromptSafeArea(this.modalEl); + applyPromptSafeArea(this.modalEl, this.filterBarEl); } private toClassifiable(model: HydratedModel): UiClassifiableModel { diff --git a/src/components/modal/promptLayout.ts b/src/components/modal/promptLayout.ts index 9875fd00d..65344845f 100644 --- a/src/components/modal/promptLayout.ts +++ b/src/components/modal/promptLayout.ts @@ -8,22 +8,35 @@ import { Platform } from "obsidian"; * `--prompt-top: calc(var(--safe-area-inset-top) + var(--header-height) + ...)`, * which is already correct. Some themes make the phone prompt full-bleed instead * (Cupertino sets `--prompt-top: 0` with `height: 100vh`), which anchors the - * panel at y=0 — so the results list, or an injected filter/action bar, renders - * behind the island. + * panel at y=0. + * + * Such a theme normally clears the island itself, inside the results list: + * Cupertino pads `.prompt-results` by `inset + 16px` and masks that band to a + * fade. Moving the whole prompt down on top of that counted the inset twice (a + * ~140px empty gap above the first row) and, because the prompt carries the + * theme's `backdrop-filter`, left an unblurred strip above it with a hard seam + * at the inset line. Verified on-device (iPhone, Cupertino): leaving the prompt + * where the theme put it lines our results up exactly with core's Quick + * Switcher. + * + * So the prompt is only moved as a fallback, for a full-bleed theme whose + * results list does NOT pad past the inset. When the modal injects a bar above + * the results (`topBar`, the model picker's filter strip), that bar becomes the + * first thing under the island: it takes the inset as its own top padding, and + * the results list gives back the padding the bar now covers. The theme's fade + * mask is anchored to the results box, whose top just moved down by the bar's + * height, so it is shifted back up by the same amount to stay where the theme + * drew it relative to the screen (a no-op for themes without a mask). * * This has to be script rather than CSS. The natural CSS spelling, * `top: max(var(--prompt-top), var(--safe-area-inset-top))`, is invalid whenever * a theme writes a *unitless* `0`: mixing a number with a length makes the whole - * declaration fail and silently fall back to `top: 0` — the exact bug it was - * meant to fix. `calc()` does not rescue it, and a style query cannot be used - * either, since `--prompt-top` is set on `.prompt` itself and style queries - * evaluate an ancestor container, never the element. - * - * Reading the resolved value lets us compare numbers and only override when the - * theme has actually pulled the prompt to the top edge, leaving core and - * well-behaved themes untouched. + * declaration fail and silently fall back to `top: 0`. `calc()` does not rescue + * it, and a style query cannot be used either, since `--prompt-top` is set on + * `.prompt` itself and style queries evaluate an ancestor container, never the + * element. */ -export function applyPromptSafeArea(promptEl: HTMLElement): void { +export function applyPromptSafeArea(promptEl: HTMLElement, topBar?: HTMLElement | null): void { if (!Platform.isPhone) return; const styles = getComputedStyle(promptEl); @@ -35,14 +48,55 @@ export function applyPromptSafeArea(promptEl: HTMLElement): void { const top = Number.parseFloat(styles.top) || 0; if (top >= inset) return; + const results = promptEl.querySelector(".prompt-results"); + const resultsPadding = results ? Number.parseFloat(getComputedStyle(results).paddingTop) || 0 : 0; + + if (topBar && results) { + placeBarUnderInset(promptEl, topBar, results, inset - top, resultsPadding); + return; + } + if (resultsPadding >= inset) return; + + shiftPromptBelowInset(promptEl, styles, inset); +} + +function placeBarUnderInset( + promptEl: HTMLElement, + bar: HTMLElement, + results: HTMLElement, + overlap: number, + resultsPadding: number, +): void { + const barStyles = getComputedStyle(bar); + const padTop = Number.parseFloat(barStyles.paddingTop) || 0; + const minHeight = Number.parseFloat(barStyles.minHeight) || 0; + bar.style.paddingTop = `${overlap + padTop}px`; + if (minHeight > 0) bar.style.minHeight = `${overlap + minHeight}px`; + + // How far the results box now starts below the prompt's top edge: the bar, + // plus anything else the modal stacks above the list. `offsetTop`, not a + // rect: this runs from `onOpen`, while Cupertino is still sliding the list in + // with a `translateY`, and a rect would fold that transform in. + const shift = results.offsetParent === promptEl ? results.offsetTop : 0; + if (shift <= 0) return; + + results.style.paddingTop = `${Math.max(8, resultsPadding - shift)}px`; + for (const prefix of ["", "-webkit-"]) { + results.style.setProperty(`${prefix}mask-position`, `0 -${shift}px`); + results.style.setProperty(`${prefix}mask-size`, `100% calc(100% + ${shift}px)`); + results.style.setProperty(`${prefix}mask-repeat`, "no-repeat"); + } +} + +function shiftPromptBelowInset(promptEl: HTMLElement, styles: CSSStyleDeclaration, inset: number): void { promptEl.style.setProperty("top", `${inset}px`, "important"); // A theme that anchored the prompt at the top edge usually also sized it to - // the full viewport (Cupertino: `height: 100vh`); shifting it down by the - // inset would push its bottom — and the input pinned there — off screen. - // Compensate by the same amount, but only when the box really is full-bleed, - // so a theme that pulled a content-sized panel to the top keeps its height. - // `vh` on purpose, matching the unit such themes use: `dvh` tracks the + // the full viewport (`height: 100vh`); shifting it down by the inset would + // push its bottom — and the input pinned there — off screen. Compensate by + // the same amount, but only when the box really is full-bleed, so a theme + // that pulled a content-sized panel to the top keeps its height. `vh` on + // purpose, matching the unit such themes use: `dvh` tracks the // keyboard-shrunken viewport on iOS and lands the cap mid-screen. const height = Number.parseFloat(styles.height) || 0; if (height >= window.innerHeight - 1) { diff --git a/src/styles.css b/src/styles.css index 9cf7ed348..10d4783ae 100755 --- a/src/styles.css +++ b/src/styles.css @@ -223,6 +223,12 @@ button.s2b-pill--interactive:hover { border: none; border-radius: 0; box-shadow: none; + /* Cupertino puts its frosted-glass pill on `.prompt-input` itself, blur + included. With the fill stripped, the blur alone still showed as a lighter + rectangle inside the field, exactly the input's text box (verified + on-device). */ + backdrop-filter: none; + -webkit-backdrop-filter: none; /* Text dropped ~6px the moment the first character was typed. Mobile core sizes BOTH `.prompt-input-container` and `.prompt-input` to a fixed 52px, diff --git a/src/views/chat/Chat.svelte b/src/views/chat/Chat.svelte index 91494b3d1..db2b2b790 100644 --- a/src/views/chat/Chat.svelte +++ b/src/views/chat/Chat.svelte @@ -581,6 +581,12 @@ function portalComposer(node: HTMLElement) { --chat-bg: var(--background-secondary); } + /* Phones and tablets dock sidebar chats in a `.workspace-drawer` instead of a + split, painted with `--mobile-sidebar-background`. */ + :global(.workspace-drawer .s2b-chat-root) { + --chat-bg: var(--mobile-sidebar-background, var(--background-secondary)); + } + /* Mobile keyboard handling. The composer is moved out of the leaf and re-parented to the workspace From 7e5000d355329e62315b32512432c7287ae15c10 Mon Sep 17 00:00:00 2001 From: Leo310 Date: Thu, 26 Nov 2026 15:17:23 +0100 Subject: [PATCH 2/6] fix(mobile): drawer tab list over the composer, compact tray chips - Host a drawer chat's composer in .workspace-drawer-inner rather than .workspace-drawer. The inner box is its own stacking context (contain: content); as a later sibling of it the composer painted over the drawer's tab dropdown and swallowed its taps. - Context-tray buttons name .context-tray so themes' phone button rules (Cupertino: 48px height, padding 0 20px at (0,2,2)) no longer win: reference chips are content-sized again and the remove button is round. - On a phone a document attachment is one row (icon + ellipsized name) instead of a 56px card that wrapped short names; card radius capped at 12px. - Tests for applyPromptSafeArea's layout paths. Co-Authored-By: Claude --- src/components/chat/ContextTray.svelte | 65 ++++++++-- src/views/chat/Chat.svelte | 11 +- test/components/promptLayout.test.ts | 161 +++++++++++++++++++++++++ 3 files changed, 227 insertions(+), 10 deletions(-) create mode 100644 test/components/promptLayout.test.ts diff --git a/src/components/chat/ContextTray.svelte b/src/components/chat/ContextTray.svelte index d5212f57b..14979f547 100644 --- a/src/components/chat/ContextTray.svelte +++ b/src/components/chat/ContextTray.svelte @@ -478,7 +478,13 @@ onDestroy(() => { width: var(--s2b-tile-size); } - button.attachment-tile-body { + /* Every button rule in this tray names `.context-tray` as well: themes + restyle bare buttons on a phone, and Cupertino's + `body:is(.mod-macos, …).is-phone button:where(…)` (0,2,2) beat a lone + scoped `button.` (0,2,1) — padding `0 20px` squeezed the card's + name and stretched the 20px remove button into an oval (verified + on-device). */ + .context-tray button.attachment-tile-body { position: relative; display: flex; flex-direction: column; @@ -489,7 +495,9 @@ onDestroy(() => { height: 100%; padding: 8px; border: 1px solid var(--background-modifier-border); - border-radius: var(--radius-m); + /* Capped: a theme's `--radius-m` can be large enough (Cupertino: 24px) + to round a short card into a pill. */ + border-radius: min(var(--radius-m), 12px); overflow: hidden; background: var(--background-secondary); color: var(--text-normal); @@ -499,7 +507,7 @@ onDestroy(() => { cursor: var(--cursor); } - .has-preview button.attachment-tile-body { + .context-tray .has-preview button.attachment-tile-body { padding: 0; background: var(--background-modifier-hover); } @@ -552,15 +560,38 @@ onDestroy(() => { font-weight: var(--font-semibold); } - /* On a phone the card is too short for icon + two lines + extension. */ - :global(body.is-phone) .attachment-card-icon, + /* On a phone a document is one row, not a card: icon and name, the name + ellipsized. The 56px card fit only ~8 characters per line there, so even + a short name like `Workout-366.md` broke across two lines (verified + on-device), and a theme with a large `--radius-m` (Cupertino: 24px) turned + the card into a blob. Image and PDF previews keep their square tiles. */ + :global(body.is-phone) .attachment-tile.is-document:not(.has-preview) { + height: auto; + width: auto; + max-width: min(100%, 16rem); + } + + :global(body.is-phone) .context-tray .attachment-tile.is-document:not(.has-preview) button.attachment-tile-body { + flex-direction: row; + align-items: center; + gap: 6px; + padding: 6px 10px; + } + + :global(body.is-phone) .attachment-tile.is-document:not(.has-preview) .attachment-card-name { + display: block; + min-width: 0; + white-space: nowrap; + text-overflow: ellipsis; + } + :global(body.is-phone) .attachment-card-ext { display: none; } /* Always visible, not revealed on hover: mobile has no hover, and an opacity-0 reveal there turns every remove into a double tap. */ - button.attachment-tile-remove { + .context-tray button.attachment-tile-remove { position: absolute; top: -6px; right: -6px; @@ -578,7 +609,7 @@ onDestroy(() => { cursor: var(--cursor); } - button.attachment-tile-remove:hover { + .context-tray button.attachment-tile-remove:hover { color: var(--text-normal); background: var(--background-modifier-hover); } @@ -724,14 +755,30 @@ onDestroy(() => { background: var(--s2b-pill-bg-hover); } + /* Both halves are