Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 117 additions & 9 deletions src/components/chat/ContextTray.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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.<class>` (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;
Expand All @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -552,15 +560,71 @@ 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);
}

/* 36px tall, the same as the reference chips beside it: 31px read cramped
against the text line below, and the extended hit area (::before) takes the
tap target to 44px, Apple's minimum. The remove button lives inside the
pill's right end (padding-right) instead of hanging over its corner. */
:global(body.is-phone) .context-tray .attachment-tile.is-document:not(.has-preview) button.attachment-tile-body {
flex-direction: row;
align-items: center;
gap: 8px;
min-height: 36px;
padding: 0 34px 0 10px;
overflow: visible;
}

:global(body.is-phone) .context-tray .attachment-tile.is-document:not(.has-preview) button.attachment-tile-body::before {
content: "";
position: absolute;
inset: -4px 0;
}

: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;
font-size: var(--font-ui-small);
}

/* The corner badge only exists to overhang a thumbnail; on the one-row pill
the whole 34px right end is the remove target, and nothing overhangs. */
:global(body.is-phone) .context-tray .attachment-tile.is-document:not(.has-preview) button.attachment-tile-remove {
top: 0;
right: 0;
width: 34px;
height: 100%;
border: none;
border-radius: 0 min(var(--radius-m), 12px) min(var(--radius-m), 12px) 0;
background: transparent;
}

/* Nothing overhangs a row of pills, so the room kept for the badges goes. */
:global(body.is-phone) .attachment-tiles:not(:has(.has-preview)) {
padding-top: 0;
/* Wide enough for both pills' 4px hit-area extensions (::before), so a
wrapped row's targets never overlap. */
row-gap: 8px;
}

: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;
Expand All @@ -578,7 +642,18 @@ onDestroy(() => {
cursor: var(--cursor);
}

button.attachment-tile-remove:hover {
/* A thumbnail's badge stays 20px to look right, but on a phone its hit area
grows to 34px (the WCAG 2.5.8 minimum is 24px). It grows only down and
left, into its own tile: the badge already overhangs the tile by 6px up
and right, exactly the gap between tiles, so reaching further would land
on the neighbouring tile's area when previews wrap. */
:global(body.is-phone) .context-tray .has-preview button.attachment-tile-remove::after {
content: "";
position: absolute;
inset: 0 0 -14px -14px;
}

.context-tray button.attachment-tile-remove:hover {
color: var(--text-normal);
background: var(--background-modifier-hover);
}
Expand Down Expand Up @@ -724,14 +799,47 @@ onDestroy(() => {
background: var(--s2b-pill-bg-hover);
}

/* Both halves are <button>s, which themes size to the touch target on a
phone (Cupertino: `height: var(--input-height)`, 48px, plus `padding: 0
20px` at (0,2,2)). In the composer that made every reference chip twice
the height of the text line below it. The chip is sized by its content;
the `.context-tray` ancestor lifts these over the theme's button rule. */
.context-tray .s2b-chip button.chip-body,
.context-tray .s2b-chip button.chip-action {
height: auto;
}

/* Vertical padding tracks the compact tray pill above. */
.context-tray .s2b-chip button.chip-action {
padding: 2px 7px 2px 5px;
}

/* On a phone the chips are tap targets: 36px tall like the file pills (the
19px desktop size left the paperclip a 24x19 target), with a slightly
larger label to match. */
:global(body.is-phone) .context-tray .s2b-chip button.chip-body,
:global(body.is-phone) .context-tray .s2b-chip button.chip-action {
min-height: 36px;
}

:global(body.is-phone) .context-tray :global(.s2b-pill) {
padding: 2px 10px;
font-size: var(--font-ui-small);
}

:global(body.is-phone) .context-tray .s2b-chip button.chip-action {
padding: 0 10px;
}

.chip-action {
display: inline-flex;
align-items: center;
/* Match the body's height: the icon is shorter than the label's line box,
which left this half 1-2px short and its border out of line. */
align-self: stretch;
/* Fixed-size target: it must not absorb the squeeze that belongs to the
label when the chip hits its width cap. */
flex-shrink: 0;
/* Vertical padding tracks the compact tray pill above. */
padding: 2px 7px 2px 5px;
border: 1px solid var(--s2b-pill-border);
border-left: none;
border-top-right-radius: 999px;
Expand Down
23 changes: 23 additions & 0 deletions src/components/chat/Input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1658,6 +1673,14 @@ function withQuoteDestination(selection: SelectionRef): SelectionRef {
padding-right: 6px;
}

/* With 36px chips in it (ContextTray), the tray needs air on a phone: 8px
below the border and 8px above the text line, not 6px and 2px. Only when
something is in it, so an empty tray adds no height. */
:global(.is-phone) .composer-tray-row:has(:global(.attachment-tile, .s2b-chip)) {
padding-top: 4px;
margin-bottom: 6px;
}

.chat-input-wrapper:focus-within {
border-color: var(--interactive-accent);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/ModelSuggestModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class ModelSuggestModal extends SuggestModal<HydratedModel> {
onOpen(): void {
void super.onOpen();
this.buildFilterBar();
applyPromptSafeArea(this.modalEl);
applyPromptSafeArea(this.modalEl, this.filterBarEl);
}

private toClassifiable(model: HydratedModel): UiClassifiableModel {
Expand Down
86 changes: 70 additions & 16 deletions src/components/modal/promptLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<HTMLElement>(".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);
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
}

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) {
Expand Down
6 changes: 6 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading
Loading