diff --git a/app/assets/fonts/OFL.txt b/app/assets/fonts/OFL.txt deleted file mode 100644 index 8e7df338..00000000 --- a/app/assets/fonts/OFL.txt +++ /dev/null @@ -1,93 +0,0 @@ -Copyright 2015 The Roboto Mono Project Authors (https://github.com/googlefonts/robotomono) - -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -https://openfontlicense.org - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/app/assets/fonts/RobotoMono.ttf b/app/assets/fonts/RobotoMono.ttf deleted file mode 100644 index f21d1d71..00000000 Binary files a/app/assets/fonts/RobotoMono.ttf and /dev/null differ diff --git a/app/lib/features/changes/widgets/capture_section.dart b/app/lib/features/changes/widgets/capture_section.dart index 5759f851..f82d2988 100644 --- a/app/lib/features/changes/widgets/capture_section.dart +++ b/app/lib/features/changes/widgets/capture_section.dart @@ -113,7 +113,7 @@ class _FileRow extends StatelessWidget { @override Widget build(BuildContext context) { - final mono = monospaceText(DefaultTextStyle.of(context).style); + final mono = nativeDiffText(DefaultTextStyle.of(context).style); final cupertino = usesCupertino(context); final leading = Icon(_kindIcon(context, file.kind)); final title = Text(file.path, style: mono); diff --git a/app/lib/features/changes/widgets/change_style.dart b/app/lib/features/changes/widgets/change_style.dart index 9705047a..a3f12ffd 100644 --- a/app/lib/features/changes/widgets/change_style.dart +++ b/app/lib/features/changes/widgets/change_style.dart @@ -6,12 +6,6 @@ import '../domain/unified_patch.dart'; /// Which form of a recorded patch the viewer is showing. enum DiffForm { rendered, raw } -/// The bundled code face (`assets/fonts/RobotoMono.ttf`, SIL OFL 1.1). Flutter -/// web cannot resolve a system monospace family, so the app carries one and -/// every target renders patch text the same way. The fallbacks are only for -/// hosts that cannot load the asset. -const codeFontFamily = 'RobotoMono'; - /// The app's established platform switch: Material for Android/desktop/web, /// Cupertino for iOS and macOS. Feature widgets stay portable across all three /// targets instead of hard-coding one control set. @@ -20,38 +14,29 @@ bool usesCupertino(BuildContext context) { return platform == TargetPlatform.iOS || platform == TargetPlatform.macOS; } -/// The app's code face for patch text. The size, weight and text scaler come -/// from the caller's theme style, so code follows the operator's text size. -TextStyle monospaceText(TextStyle base) => base.copyWith( - fontFamily: codeFontFamily, - fontFamilyFallback: const ['Menlo', 'Consolas', 'Courier New', 'monospace'], -); +/// Patch text inherits the host's typography, including its font and scaler. +/// A diff is not an exception to the native-defaults requirement. +TextStyle nativeDiffText(TextStyle base) => base; -/// The distinguishable success/removal colours shared by the stat line and the -/// diff rows. A theme-aware green/red pair, never two shades of the same hue: -/// the light Material containers alone made additions and removals read alike. +/// Native semantic colours, never a bespoke diff palette. The recorded +/- +/// markers carry meaning independently of colour. No background tint is added. ({Color text, Color? background}) diffLineColors( BuildContext context, ChangeLineKind kind, ) { - final dark = usesCupertino(context) - ? CupertinoTheme.of(context).brightness == Brightness.dark - : Theme.of(context).brightness == Brightness.dark; return switch (kind) { - ChangeLineKind.add => - dark - ? (text: const Color(0xFF7FE0A8), background: const Color(0x297FE0A8)) - : ( - text: const Color(0xFF116B33), - background: const Color(0xFFE3F3E7), - ), - ChangeLineKind.remove => - dark - ? (text: const Color(0xFFFF9E9E), background: const Color(0x29FF9E9E)) - : ( - text: const Color(0xFFB3261E), - background: const Color(0xFFFBE7E5), - ), + ChangeLineKind.add => ( + text: usesCupertino(context) + ? CupertinoColors.systemGreen.resolveFrom(context) + : Theme.of(context).colorScheme.primary, + background: null, + ), + ChangeLineKind.remove => ( + text: usesCupertino(context) + ? CupertinoColors.destructiveRed.resolveFrom(context) + : Theme.of(context).colorScheme.error, + background: null, + ), ChangeLineKind.context => (text: labelColor(context), background: null), }; } diff --git a/app/lib/features/changes/widgets/file_diff_viewer.dart b/app/lib/features/changes/widgets/file_diff_viewer.dart index ccc62b06..1e05c54e 100644 --- a/app/lib/features/changes/widgets/file_diff_viewer.dart +++ b/app/lib/features/changes/widgets/file_diff_viewer.dart @@ -64,7 +64,7 @@ class _FileDiffViewerState extends State { final file = widget.file; final cupertino = usesCupertino(context); final base = DefaultTextStyle.of(context).style; - final mono = monospaceText(base); + final mono = nativeDiffText(base); final stat = changeStat(file.added, file.removed); final tags = changeEntryTags(file); return ConstrainedBox( diff --git a/app/lib/features/changes/widgets/patch_view.dart b/app/lib/features/changes/widgets/patch_view.dart index 08c5d765..dc4039bb 100644 --- a/app/lib/features/changes/widgets/patch_view.dart +++ b/app/lib/features/changes/widgets/patch_view.dart @@ -17,7 +17,7 @@ class PatchView extends StatelessWidget { @override Widget build(BuildContext context) { final parsed = file.parsedPatch; - final base = monospaceText(DefaultTextStyle.of(context).style); + final base = nativeDiffText(DefaultTextStyle.of(context).style); final stat = changeStat(parsed.added, parsed.removed); return Semantics( container: true, @@ -106,7 +106,7 @@ class _HunkView extends StatelessWidget { @override Widget build(BuildContext context) { - final base = monospaceText(DefaultTextStyle.of(context).style); + final base = nativeDiffText(DefaultTextStyle.of(context).style); final width = gutterWidth(hunk); return Column( crossAxisAlignment: CrossAxisAlignment.stretch, diff --git a/app/notes/D1.md b/app/notes/D1.md index 0fcdd597..4dc83394 100644 --- a/app/notes/D1.md +++ b/app/notes/D1.md @@ -1,8 +1,22 @@ # D1 — run changes and the file diff viewer -New feature under `lib/features/changes/` plus a bundled code font. The only -tracked-file change is `pubspec.yaml` (the font family/assets declaration that -Flutter web needs); no server, web or Android changes. +New feature under `lib/features/changes/`; no server, legacy web/Android or +pubspec changes remain after manager acceptance corrections. + +## Current manager acceptance (supersedes earlier presentation evidence below) + +The pipeline's bundled font and fixed green/red palette were rejected against +the user's native-defaults requirement. Manager removed both and the font assets +without changing raw patch, capture or visit semantics. Typography inherits the +host; colours use native semantic roles and no row tint. The original candidate +and its review evidence remain referenced at15cca17; later font/palette evidence +in this note is historical, NOT evidence for the final native-defaults patch. + +Updated regressions failed against the original overrides, then all47 focused +tests passed after correction; analyzer clean. Fresh fixture web build and +changes_probe passed (including absence of custom font), producing18 new captures +under approved temp/native-diff-manager-captures. Manager inspected both native +phone2x rendered views. Preview/shell integration and mobile remain unverified. ## Public API @@ -105,13 +119,12 @@ The manager owns shell/run-detail registration; this item does not edit them. keeps each recorded line on one line and scrolls sideways, like the web's `white-space: pre` pane, so a wrapped continuation can never be mistaken for a new patch line. -- Code text uses **Roboto Mono**, bundled as `assets/fonts/RobotoMono.ttf` and - declared in `pubspec.yaml`. Flutter web's CanvasKit cannot resolve a system - `monospace` family, so before the bundle the browser diff rendered in a - proportional face. The font is SIL OFL 1.1; its licence ships beside it as - `assets/fonts/OFL.txt`. The size, weight and text scaler come from the theme - style, so code follows the operator's text size; no fixed content - width/height. +- Patch/path text inherits the native host typography without a font-family, + size or weight override. Manager removed the candidate's bundled code font: + a previous visual review requested it, but that contradicts the user's + explicit native-defaults requirement, which also applies to diffs. The web + default may be proportional; no monospace guarantee is claimed. Raw patch + bytes are unchanged. No bundled font or pubspec change remains. - Rendered/Raw is a native Material `SegmentedButton` or Cupertino `CupertinoSlidingSegmentedControl`. Copy patch and Close are native Material buttons/icon button or Cupertino buttons with exact labels. @@ -121,12 +134,10 @@ The manager owns shell/run-detail registration; this item does not edit them. - Binary uses the honest binary message; truncated-with-patch shows the note plus the retained text; truncated-without-patch and mode-only show the recorded reason, never an invented empty diff. -- Additions and removals use distinguishable theme-aware hues, never two shades - of one container role: light `#116B33` text on `#E3F3E7` for additions and - `#B3261E` on `#FBE7E5` for removals; dark `#7FE0A8` and `#FF9E9E` on a 16% - wash of the same hue. `+N` and `-M` are separate spans in those hues. Each - changed line paints a tint across the whole hunk content width (at least the - dialog width), so short lines no longer produce short colour bars. +- Add/remove markers and stats use native semantic colours (Material primary/ + error; Cupertino systemGreen/destructiveRed), with no bespoke palette or added + tint. +/- and recorded gutter numbers distinguish changes without colour. + Rows share the hunk width, at least the dialog width. - A Cupertino list row lets its recorded path wrap instead of inheriting the tile's single ellipsized line, and the Cupertino dialog surface is inset from the window edge (16 on phones, 40 on wide windows) so its native rounded diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 5f3a44c4..fa4a079a 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -61,18 +61,6 @@ flutter: # the material Icons class. uses-material-design: true - # The diff viewer's bundled code face. Flutter web has no resolvable system - # monospace family, so the app ships Roboto Mono (SIL OFL 1.1, licence beside - # the font) and the same face is used on every target. - fonts: - - family: RobotoMono - fonts: - - asset: assets/fonts/RobotoMono.ttf - weight: 400 - - assets: - - assets/fonts/OFL.txt - # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg diff --git a/app/test/features/changes/diff_presentation_test.dart b/app/test/features/changes/diff_presentation_test.dart index 8ef28121..77dad873 100644 --- a/app/test/features/changes/diff_presentation_test.dart +++ b/app/test/features/changes/diff_presentation_test.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -18,22 +16,14 @@ const _raggedPatch = '-x\n' ' tail\n'; -double _addGreenMinusRed(Color color) => color.g - color.r; - -double _removeRedMinusGreen(Color color) => color.r - color.g; - void main() { - test('patch text uses the bundled code face, not a web fallback', () { - final style = monospaceText(const TextStyle(fontSize: 12)); - expect(style.fontFamily, codeFontFamily); - expect(style.fontFamilyFallback, contains('Menlo')); - // Flutter web can only render a monospace diff if the build carries one. - expect(File('assets/fonts/RobotoMono.ttf').existsSync(), isTrue); - expect( - File('pubspec.yaml').readAsStringSync(), - contains('family: $codeFontFamily'), - ); - }); + test( + 'patch typography preserves the native host style without overrides', + () { + const native = TextStyle(fontSize: 19, fontFamily: 'host-font'); + expect(nativeDiffText(native), same(native)); + }, + ); testWidgets( 'light and dark themes give additions and removals distinct hues', @@ -45,29 +35,16 @@ void main() { final context = tester.element(find.byType(Scaffold)); final add = diffLineColors(context, ChangeLineKind.add); final remove = diffLineColors(context, ChangeLineKind.remove); - expect(add.background, isNotNull, reason: '$brightness add tint'); - expect(remove.background, isNotNull, reason: '$brightness remove tint'); + expect(add.background, isNull); + expect(remove.background, isNull); expect(add.text, isNot(remove.text), reason: '$brightness text'); - expect( - _addGreenMinusRed(add.background!), - greaterThan(0.02), - reason: '$brightness additions read as green, not another red', - ); - expect( - _removeRedMinusGreen(remove.background!), - greaterThan(0.02), - reason: '$brightness removals read as red, not another green', - ); - expect( - _removeRedMinusGreen(remove.text), - greaterThan(0.02), - reason: '$brightness removal text is a red hue', - ); + expect(add.text, Theme.of(context).colorScheme.primary); + expect(remove.text, Theme.of(context).colorScheme.error); } }, ); - testWidgets('every diff line tint spans the hunk width, not its own text', ( + testWidgets('every diff line shares the hunk width, not its own text width', ( tester, ) async { await tester.pumpWidget( diff --git a/app/tool/changes_probe.mjs b/app/tool/changes_probe.mjs index 75782541..7c2f51c7 100644 --- a/app/tool/changes_probe.mjs +++ b/app/tool/changes_probe.mjs @@ -219,30 +219,15 @@ try { throw new Error(`Root index is not text/html: ${contentType}`); } - // The diff's core content can only be monospaced if the web build ships a - // code face; CanvasKit cannot resolve the system `monospace` family. + // Diff text inherits native host typography; it must not add a custom face. const manifest = await evaluate("fetch('/assets/FontManifest.json').then(r => r.json())"); const codeEntry = (Array.isArray(manifest) ? manifest : []).find( (entry) => entry.family === 'RobotoMono', ); - const codeAsset = codeEntry?.fonts?.[0]?.asset; - if (!codeAsset) { - throw new Error(`FontManifest has no RobotoMono family: ${JSON.stringify(manifest)}`); - } - const fontResponse = await evaluate(`fetch('/assets/${codeAsset}').then(async (r) => ({ - status: r.status, - contentType: r.headers.get('content-type'), - bytes: (await r.arrayBuffer()).byteLength, - }))`); + if (codeEntry) throw new Error('Diff build still overrides native typography'); evidence.checks.push({ - check: 'the web build carries the diff code face', - family: codeEntry.family, - asset: codeAsset, - ...fontResponse, + check: 'the web build does not register a custom diff font', }); - if (fontResponse.status !== 200 || fontResponse.bytes < 10000) { - throw new Error(`Code face did not load: ${JSON.stringify(fontResponse)}`); - } const firstLabels = await labels(); const firstBody = await bodyText();