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
11 changes: 11 additions & 0 deletions .memory/chat-width-setting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Chat width setting (T3 #11594)

- `AppearanceConfig.chatWidth`: `narrow | default | wide | full`, default `default`. `CHAT_WIDTH_OPTIONS` / `chatContentMaxWidth()` in `renderer/shared/appearance.ts` map these to 44rem / 52rem / 64rem / `none`.
- `applyAppearanceConfig` sets `--chat-content-max-width` inline on `<html>` and sets `data-chat-width`. The `:root` 52rem in `styles.css` is only the pre-hydration fallback.
- The field is optional in `parseAppearanceConfig`, so legacy v1 settings and exports load. A supplied invalid value throws "Chat width is unsupported."
- UI: an Appearance "Chat width" section (`ChatWidthPicker`, a radiogroup labelled by its h2) that uses the same roving-radio helper as the theme pickers.
- The chat `ScrollArea` measures any reserved classic-scrollbar gutter and narrows its fixed footer to the scrollport's usable width. This keeps Full-width messages centered with the composer on Linux without overflowing or clipping the transcript; overlay-scrollbar platforms measure zero. Keep this opt-in for the main chat surface because other scroll areas do not share the footer geometry.
- Desktop only. Mobile clients keep their own local appearance and do not read this field, and the Remote protocol is unchanged.
- Covered by e2e `settings-unification.spec.ts` "chat width setting…", which measures geometry at 1800px and checks the value after a relaunch, and by unit tests in `appearance.test.ts`.

Linux follow-up: the synthetic gutter fixture measured the initial thin scrollbar before switching to auto, double-counting the width increase and causing a 2px center mismatch. It now resets any previous override, applies the final style, then measures the native gutter before adding compensation. Production layout code is unchanged by this fixture correction.
1 change: 1 addition & 0 deletions docs/plans/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This directory is the source of truth for Aiden's implementation plans. The engi
| Plan | Status | Current state |
| -------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Aiden CLI](aiden-cli-plan.md) | Active | Phases 0–5 implementation complete; macOS/Linux CLI (57 tests each), Linux native helpers, complete shared subagent suites, root TypeScript/lint, and Android client checks pass. Physical iPhone acceptance is pending an unlocked device. Phase 6 adds QR remote pairing, scheduled-run notifications (mobile push + desktop), shared desktop memory, daemon autostart, and prebuilt binaries; see the [checklist](aiden-cli-parity-checklist.md). |
| Chat width setting (T3 #11594) | Implemented for review | Appearance → **Chat width** (Narrow 44rem / Default 52rem / Wide 64rem / Full) persists as `AppearanceConfig.chatWidth` and drives `--chat-content-max-width`, so the transcript, approvals, and composer resize together. The main chat footer matches the scrollport's usable width when a classic scrollbar reserves space, so Full remains aligned without horizontal overflow. Desktop only; older settings migrate to Default. No plan doc. |
| [Web Search API key pool](web-search-key-pool-plan.md) | Implemented for review | Tavily accepts up to 8 encrypted keys with ordered or round-robin use. Rejected keys (401/403) and quota-limited keys (429/432/433) cool down in memory with backoff and fail over to the next key. When every key is cooling, no request is sent and automatic routing falls back. Settings can add, remove, reorder and retry keys, and the renderer never sees a key. Other providers and CLI parity remain. |
| [Timed ask-user waits](timed-ask-user-plan.md) | Implemented for review | Optional `timeoutSeconds` on `ask_user_question`; unattended (Remote) runs always expire within 5 min and resolve with an explicit best-judgement result. Late desktop answers become a Send/Queue follow-up offer; Remote `expiresAt` carries the real deadline; iOS/Android say when a question expired. PR CI pending. |
| [Rich link previews for Chats and Bots](rich-link-previews-plan.md) | Implemented for review | Shared regular Chat and Bot transcripts now show provider-aware inline icons and bounded hover/focus cards. User HTTP(S) text is autolinked, assistant streaming and persisted Markdown share the opt-in renderer, and URL-derived previews perform no network requests. |
Expand Down
4 changes: 4 additions & 0 deletions docs/settings-design-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ Model Pad measures the actual scrollport and remaining column. Axis captions and

Duplicate workspace names receive a short stable ID suffix in both visible and accessible names. Worktree branches and folderless workspace identity remain available when paths are hidden. Destructive confirmation and permission-scope review still identify their exact filesystem target.

## Chat width

`AppearanceConfig.chatWidth` (`narrow`, `default`, `wide`, or `full`; default `default`) is the one Appearance layout preference. `applyAppearanceConfig` writes it to `--chat-content-max-width` (44rem, 52rem, 64rem, or `none`) and `data-chat-width` on the root. Every `.chat-content-column` surface shares that token, so the transcript, pending approvals, and composer stay aligned. The dock inset still reserves the floating Aiden mark's gutter at Full. Older v1 settings and exports without the field load as Default, and strict parsing rejects unknown values. The control is a four-option radio card group: selection is the label's list-selection fill, never a border, and keyboard focus uses the neutral focus ring. Below 540px of content width it reflows to two columns. `settings-unification.spec.ts` measures the rendered transcript and composer widths for every option and checks that the choice survives a relaunch.

## Icons and illustrations

Use `MemoryCardIcon`, an SD-card silhouette, for Memory. Do not introduce brain glyphs or brain illustrations. The existing onboarding artwork is outside this Settings change.
Expand Down
40 changes: 39 additions & 1 deletion renderer/components/settings/appearance-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
type AppliedAppearance,
} from "../../lib/appearance-runtime";
import {
CHAT_WIDTH_OPTIONS,
THEME_PRESETS,
createDefaultAppearanceConfig,
getPresetVariant,
Expand All @@ -35,6 +36,7 @@ import {
type AppearanceConfig,
type AppearanceMode,
type AppearanceScheme,
type ChatWidthPreference,
type ThemePresetId,
type ThemeVariantConfig,
} from "../../shared/appearance";
Expand Down Expand Up @@ -122,6 +124,31 @@ function ThemeModePicker({ value, config, disabled, onChange }: { value: Appeara
);
}

function ChatWidthPicker({ value, onChange }: { value: ChatWidthPreference; onChange: (width: ChatWidthPreference) => void }) {
const options = CHAT_WIDTH_OPTIONS.map((option) => ({ value: option.id, label: option.label }));
return (
<div className="appearance-width-picker" role="radiogroup" aria-labelledby="appearance-chat-width-title">
{options.map((option, index) => (
<button
key={option.value}
type="button"
role="radio"
aria-checked={value === option.value}
tabIndex={value === option.value ? 0 : -1}
className="appearance-width-option"
onClick={() => onChange(option.value)}
onKeyDown={(event) => handleRadioNavigation(event, index, options, onChange)}
>
<span className="appearance-width-preview" data-chat-width={option.value} aria-hidden="true">
<span className="appearance-width-preview-column"><i /><i /><i /></span>
</span>
<span className="appearance-width-option-label">{option.label}</span>
</button>
))}
</div>
);
}

function previewStyle(variant: ThemeVariantConfig, scheme: AppearanceScheme): CssProperties {
const tokens = resolveThemeTokens(variant, scheme);
return {
Expand Down Expand Up @@ -441,6 +468,11 @@ export function AppearanceSettings() {
}));
};

const changeChatWidth = (chatWidth: ChatWidthPreference) => {
if (chatWidth === configRef.current.chatWidth) return;
update((current) => ({ ...current, chatWidth }));
};

const selectedPreset =
config.light.preset !== "custom" && config.light.preset === config.dark.preset
? config.light.preset
Expand All @@ -453,7 +485,7 @@ export function AppearanceSettings() {
<div className="appearance-page" aria-busy={!hydrated} inert={!hydrated ? true : undefined}>
<div className="settings-page-heading appearance-heading">
<h1>Appearance</h1>
<p>Pick a theme and choose when Aiden uses its light or dark look.</p>
<p>Pick a theme, choose when Aiden uses its light or dark look, and set how wide conversations read.</p>
</div>

{saveError ? (
Expand All @@ -480,6 +512,12 @@ export function AppearanceSettings() {
<ThemeTileGrid value={selectedPreset} onChange={changeTheme} />
<p className="appearance-current-theme">Current theme: {currentThemeLabel}</p>
</section>

<section className="appearance-theme-section appearance-layout-section" aria-labelledby="appearance-chat-width-title">
<h2 id="appearance-chat-width-title">Chat width</h2>
<p className="appearance-section-description">Sets how wide messages and the composer can grow in the conversation.</p>
<ChatWidthPicker value={config.chatWidth} onChange={changeChatWidth} />
</section>
</div>
);
}
20 changes: 18 additions & 2 deletions renderer/components/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ export function ScrollArea({
actions,
toolbar,
footer,
alignFooterToScrollContent = false,
autoScrollToBottom,
autoScrollDeps = [],
autoScrollResetKey,
Expand All @@ -836,6 +837,8 @@ export function ScrollArea({
actions?: React.ReactNode;
toolbar?: React.ReactNode;
footer?: React.ReactNode;
/** Keep the fixed footer aligned with the scrollport when classic scrollbars reserve width. */
alignFooterToScrollContent?: boolean;
autoScrollToBottom?: boolean;
autoScrollDeps?: unknown[];
/** Changing this identity re-arms follow and pins to the latest content. */
Expand All @@ -851,6 +854,7 @@ export function ScrollArea({
const footerRef = React.useRef<HTMLDivElement>(null);
const [toolbarHeight, setToolbarHeight] = React.useState(0);
const [footerHeight, setFooterHeight] = React.useState(0);
const [scrollbarGutter, setScrollbarGutter] = React.useState(0);
const footerHeightRef = React.useRef(0);
const [atBottom, setAtBottom] = React.useState(true);
const [atScrollEnd, setAtScrollEnd] = React.useState(true);
Expand Down Expand Up @@ -928,6 +932,13 @@ export function ScrollArea({
const measure = () => {
setToolbarHeight(toolbarRef.current?.getBoundingClientRect().height ?? 0);
const nextFooterHeight = footerRef.current?.getBoundingClientRect().height ?? 0;
if (alignFooterToScrollContent) {
const scrollViewport = viewport.current;
const nextScrollbarGutter = scrollViewport
? Math.max(0, scrollViewport.offsetWidth - scrollViewport.clientWidth)
: 0;
setScrollbarGutter((current) => current === nextScrollbarGutter ? current : nextScrollbarGutter);
}
if (nextFooterHeight !== footerHeightRef.current) {
footerHeightRef.current = nextFooterHeight;
setFooterHeight(nextFooterHeight);
Expand All @@ -936,10 +947,11 @@ export function ScrollArea({
};
measure();
const observer = new ResizeObserver(measure);
if (alignFooterToScrollContent && viewport.current) observer.observe(viewport.current);
if (toolbarRef.current) observer.observe(toolbarRef.current);
if (footerRef.current) observer.observe(footerRef.current);
return () => observer.disconnect();
}, [toolbar, footer, title, leading, actions, scheduleFollowBottom]);
}, [alignFooterToScrollContent, toolbar, footer, title, leading, actions, scheduleFollowBottom]);

React.useLayoutEffect(() => {
scheduleFollowBottom();
Expand Down Expand Up @@ -1042,7 +1054,11 @@ export function ScrollArea({
</Button>
) : null}
{footer ? (
<div ref={footerRef} className="absolute inset-x-0 bottom-0 z-10">
<div
ref={footerRef}
className="absolute inset-x-0 bottom-0 z-10"
style={alignFooterToScrollContent ? { insetInlineEnd: scrollbarGutter } : undefined}
>
{footer}
</div>
) : null}
Expand Down
3 changes: 3 additions & 0 deletions renderer/lib/appearance-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
chatContentMaxWidth,
codeFontStack,
createDefaultAppearanceConfig,
getPresetVariant,
Expand Down Expand Up @@ -225,6 +226,8 @@ export function applyAppearanceConfig(
root.style.setProperty("--font-code-family", codeFontStack(variant.codeFont));
root.style.setProperty("--ui-font-size", `${config.uiFontSize}px`);
root.style.setProperty("--code-font-size", `${config.codeFontSize}px`);
root.dataset.chatWidth = config.chatWidth;
root.style.setProperty("--chat-content-max-width", chatContentMaxWidth(config.chatWidth));
for (const [name, token] of Object.entries(tokens)) root.style.setProperty(name, token);

const themeColor = tokens["--theme-canvas"];
Expand Down
1 change: 1 addition & 0 deletions renderer/main/chat-pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2319,6 +2319,7 @@ export function ChatPane({ chatId }: { chatId: string }) {
<>
<ScrollArea
className="h-full min-h-0"
alignFooterToScrollContent
title={
bot.data ? (
<span className="flex min-w-0 items-center gap-2">
Expand Down
2 changes: 1 addition & 1 deletion renderer/main/settings-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const DESCRIPTIONS: Record<SettingsSection, string> = {
voice: "Set up voice input, transcription, and dictation.",
tts: "Read Aiden’s latest response aloud with Google Gemini.",
shortcut: "Customize the keyboard controls for Aiden and the app.",
appearance: "Pick a theme and choose when Aiden uses its light or dark look.",
appearance: "Pick a theme, choose when Aiden uses its light or dark look, and set how wide conversations read.",
about: "App information, updates, and diagnostics.",
};

Expand Down
25 changes: 25 additions & 0 deletions renderer/shared/appearance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { readFileSync } from "node:fs";
import test from "node:test";
import {
THEME_PRESETS,
chatContentMaxWidth,
colorContrastRatio,
createDefaultAppearanceConfig,
getPresetVariant,
Expand Down Expand Up @@ -333,6 +334,30 @@ test("composer context auto-hide defaults on and preserves explicit saved prefer
assert.throws(() => parseAppearanceConfig({ ...legacy, autoHideComposerContext: "yes" }), /boolean/u);
});

test("chat width defaults to the original column, migrates legacy settings, and rejects unknown widths", () => {
// Existing users keep the 52rem column they had before the preference existed.
assert.equal(createDefaultAppearanceConfig().chatWidth, "default");
assert.equal(chatContentMaxWidth(createDefaultAppearanceConfig().chatWidth), "52rem");

const legacy: Record<string, unknown> = { ...createDefaultAppearanceConfig() };
delete legacy.chatWidth;
assert.equal(parseAppearanceConfig(legacy).chatWidth, "default");

for (const chatWidth of ["narrow", "wide", "full"] as const) {
const stored = { ...createDefaultAppearanceConfig(), chatWidth };
assert.equal(parseAppearanceConfig(JSON.parse(JSON.stringify(stored))).chatWidth, chatWidth);
}

const rem = (value: string) => Number.parseFloat(value);
assert.ok(rem(chatContentMaxWidth("narrow")) < rem(chatContentMaxWidth("default")));
assert.ok(rem(chatContentMaxWidth("default")) < rem(chatContentMaxWidth("wide")));
assert.equal(chatContentMaxWidth("full"), "none");

assert.equal(normalizeAppearanceConfig({ chatWidth: "huge" }).chatWidth, "default");
assert.throws(() => parseAppearanceConfig({ ...legacy, chatWidth: "huge" }), /chat width/i);
assert.throws(() => parseAppearanceConfig({ ...legacy, chatWidth: 900 }), /chat width/i);
});

test("the shared focus treatment separates text entry from non-text keyboard focus", () => {
const styles = readFileSync(new URL("../styles.css", import.meta.url), "utf8");
const ui = readFileSync(new URL("../components/ui.tsx", import.meta.url), "utf8");
Expand Down
34 changes: 34 additions & 0 deletions renderer/shared/appearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type CodeFontId = "sf-mono" | "menlo" | "monaco";
export type ReduceMotionPreference = "system" | "on" | "off";
export type DiffMarkerPreference = "color" | "symbols";
export type DockIconPreference = "aiden" | "monochrome";
export type ChatWidthPreference = "narrow" | "default" | "wide" | "full";

export interface ThemeVariantConfig {
preset: ThemeSelection;
Expand Down Expand Up @@ -43,6 +44,8 @@ export interface AppearanceConfig {
codeFontSize: number;
diffMarkers: DiffMarkerPreference;
fontSmoothing: boolean;
/** Maximum width of the shared transcript/composer column. */
chatWidth: ChatWidthPreference;
}

export interface AppearancePreviewSnapshot {
Expand Down Expand Up @@ -84,6 +87,31 @@ export const CODE_FONT_OPTIONS: ReadonlyArray<{ id: CodeFontId; label: string; p
{ id: "monaco", label: "Monaco", preview: "Monaco, Menlo" },
];

/**
* Chat column widths. `maxWidth` feeds `--chat-content-max-width`, which the
* transcript, pending approvals, and composer all share so they stay aligned.
* "Full" removes the cap; the dock inset still keeps the floating Aiden mark
* clear on both sides.
*/
export const CHAT_WIDTH_OPTIONS: ReadonlyArray<{
id: ChatWidthPreference;
label: string;
maxWidth: string;
}> = [
{ id: "narrow", label: "Narrow", maxWidth: "44rem" },
{ id: "default", label: "Default", maxWidth: "52rem" },
{ id: "wide", label: "Wide", maxWidth: "64rem" },
{ id: "full", label: "Full", maxWidth: "none" },
];

function isChatWidthPreference(value: unknown): value is ChatWidthPreference {
return value === "narrow" || value === "default" || value === "wide" || value === "full";
}

export function chatContentMaxWidth(preference: ChatWidthPreference): string {
return CHAT_WIDTH_OPTIONS.find((option) => option.id === preference)?.maxWidth ?? "52rem";
}

export const THEME_PRESETS: ReadonlyArray<ThemePreset> = [
{
id: "aiden",
Expand Down Expand Up @@ -362,6 +390,7 @@ const DEFAULT_APPEARANCE: AppearanceConfig = {
codeFontSize: 12,
diffMarkers: "symbols",
fontSmoothing: true,
chatWidth: "default",
};

export function createDefaultAppearanceConfig(): AppearanceConfig {
Expand Down Expand Up @@ -466,6 +495,7 @@ export function normalizeAppearanceConfig(value: unknown): AppearanceConfig {
fontSmoothing: typeof value.fontSmoothing === "boolean"
? value.fontSmoothing
: fallback.fontSmoothing,
chatWidth: isChatWidthPreference(value.chatWidth) ? value.chatWidth : fallback.chatWidth,
};
}

Expand Down Expand Up @@ -501,6 +531,10 @@ export function parseAppearanceConfig(value: unknown): AppearanceConfig {
if (value.autoHideComposerContext !== undefined && typeof value.autoHideComposerContext !== "boolean") {
throw new Error("Composer context preference must be a boolean value.");
}
// Older V1 settings and exports predate the chat width preference.
if (value.chatWidth !== undefined && !isChatWidthPreference(value.chatWidth)) {
throw new Error("Chat width is unsupported.");
}
const verifyVariant = (variant: unknown, label: string) => {
if (!isRecord(variant)) throw new Error(`${label} theme must be an object.`);
for (const key of ["accent", "background", "foreground"]) {
Expand Down
2 changes: 1 addition & 1 deletion renderer/shared/settings-section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const SETTINGS_DESTINATIONS: ReadonlyArray<{
id: "appearance",
title: "Appearance",
group: "App",
keywords: ["theme", "light", "dark", "mode", "system"],
keywords: ["theme", "light", "dark", "mode", "system", "chat width", "layout", "wide", "narrow"],
},
{
id: "about",
Expand Down
Loading
Loading