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
28 changes: 19 additions & 9 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ restart buttons. `ui/open_in_editor_buttons.dart` draws them,
absent one.
- **Most of it goes through `open`**, which hands the request to LaunchServices
and so routes it to the copy that is *already running*. Three forms:
- **The folder as a document** — `open -a <bundle> <path>`, for VS Code,
which declares `public.folder` in `CFBundleDocumentTypes`.
- **The folder as a document** — `open -a <bundle> <path>`, for VS Code and
Antigravity, which declare `public.folder` in `CFBundleDocumentTypes`.
- **A deep link** — `open <scheme>://…`, for Claude
(`claude://code/new?folder=`), Codex (`codex://threads/new?path=`) and
OpenCode (`opencode://open-project?directory=`). None of the three takes a
Expand All @@ -474,13 +474,13 @@ restart buttons. `ui/open_in_editor_buttons.dart` draws them,
is why the deep link is preferred over handing it the folder as a document.
No `q`/`prompt` is sent: that would prefill *and* start a task, and the
button only promises to open the project.
- **Antigravity is the one `IdeIntegration` with no button.**
`/Applications/Antigravity.app` is not the IDE — it is a thin Electron shell
around a Go language server, with no `open-file` handler and no
`CFBundleDocumentTypes`, so a folder handed to it is dropped. The editor is a
separate bundle, `Antigravity IDE.app`, and no route into it has been
confirmed. It is out only because no build of it has been seen to open the
folder it was given.
- **Antigravity opens through `Antigravity IDE.app`, never `Antigravity.app`.**
The latter is a thin Electron shell around a Go language server, with no
`open-file` handler and no `CFBundleDocumentTypes`, so a folder handed to it
is dropped and `open` still exits 0. The IDE is a separate bundle, a VS Code
fork, and `open -a` on it was confirmed against 2.5.5: the folder opened, and
a second call reused the running copy. **macOS only** — where the Windows
installer puts the IDE has not been seen, so there is no Windows button.
- **Order is preference order**, and `ProjectStartedDialog` features the first.
OpenCode is last deliberately: it only appears when the box was ticked, but
App Studio already runs it in the Agent tab, so an editor it does *not* have
Expand Down Expand Up @@ -1247,6 +1247,8 @@ install. Sparkle would also catch it, but later and less clearly.
- **Custom widgets read the theme; they do not carry colors.** Use `scheme.*` for color, `theme.radii.{sm,md,lg,full}` for corners and `theme.style.*` for geometry — a literal `Color(0x…)` or `BorderRadius.circular(n)` in a widget is the thing to fix, not to match. Failure states are `scheme.destructive`, never a private red.
- **Success and warning have no shadcn token**, so they ride in the scheme's `custom` map and are read through the `AppColorScheme` extension as `scheme.success` / `scheme.warning`. One value per status, picked to be legible on that brightness's background, covers both the dot and its label.
- **The app icon is `AppIcon.appiconset` on macOS and `windows/runner/resources/app_icon.ico` on Windows** — separate artwork, each from the design's icon set, so neither is generated from the other. `ASSETCATALOG_COMPILER_APPICON_NAME` must name `AppIcon`: an Icon Composer `AppStudio.icon` used to be the one built, which left the asset catalog's PNGs unused, so replacing them changed nothing. macOS 27 draws the flat icon as is, with no grey frame (checked through `NSWorkspace.icon(forFile:)`). After changing the icon, a dev build keeps showing the old one even through `flutter clean` and a Dock restart: macOS caches it per bundle path and a rebuild does not invalidate that. `touch` the built `.app`, then `lsregister -f` it, and relaunch.
- **The Windows `.ico` runs nearly edge to edge, unlike the macOS one.** The design set's own `app_icon.ico` is drawn on Apple's grid: an 800 px plate in a 1024 px canvas with a drop shadow, so on the taskbar it looked a fifth smaller than every other app. It also had no 30, 36, 60, 72 or 80 px frames, so at 125% and 150% scale Windows shrank a larger frame to fit. Build it from the set's `source/windows.svg` instead: drop `filter="url(#wsx)"` (the outer shadow) and crop the viewBox to the plate (`112 112 800 800`). Then render each frame with `rsvg-convert` at the frame size minus a margin of 1/32 of the frame (1 px through 40, 8 px at 256), and centre it on a transparent canvas. Use 16, 20, 24, 30, 32, 36, 40, 48, 60, 64, 72, 80, 96, 128 and 256 px, stored as PNG entries. `rsvg-convert` reproduces the set's 256 px frame almost exactly.
- **The runner sets the window icons per DPI** (`Win32Window::UpdateIcons`). `LoadIcon` returns only the 32 px frame at the system DPI, so the title bar and Alt+Tab icons were rescaled from it. The runner now sends `WM_SETICON` with the frame for 16 and 32 px at the window's DPI, and again on `WM_DPICHANGED`. The Start menu shortcut and the pinned taskbar icon come from the exe's resource, which the shell reads at the size it needs.
- **Layout constants** (`app_theme.dart`): `kPaneHeaderHeight` (36), `kDividerWidth` (1), `paneBorderSide()`, `kSplitHandleWidth` (6).
- **Pane chrome:** headers use `scheme.muted`; content uses `scheme.background`. Use `paneBorderSide()` for all 1px dividers.
- **Segmented controls:** `IconSegmentedControl` / `TextSegmentedControl` share `widgets/segmented_control_theme.dart`, which resolves color and geometry from the theme's **tab** tokens — the strip/segment treatment `ShadTabs` uses — so both follow the style preset like a built-in. Hover moves the *foreground*, not the fill, so no blend has to be invented. `onMutedSurface: true` on muted pane headers swaps track and selection.
Expand Down Expand Up @@ -1937,6 +1939,14 @@ after the other.
- Its second paragraph ("When the app has started, open this project in your AI
editor…") is gone: that is the whole job of the notice that now follows it,
and saying it during a two-minute compile is advice the user cannot act on.
What it says instead is something the user *can* do while waiting: write
down what they want to build, and a **Prompt Generator** button left of
Dismiss opens `kPromptGeneratorUrl` (`serverpod.dev/start-prompt`,
`util/prompt_generator.dart`) in the browser. It leaves the notice up — the
wait is not over. The two buttons share a `Row`: three children under
`spaceBetween` would strand the first mid-row. **Help → Open Prompt
Generator** opens the same page, on both platforms; on macOS it is added to
the stock Help menu by title, as View is.
- **The started notice names one editor and offers one button** —
`featuredEditor`, the first of `ExternalEditorsView.editors`. A row of equally
weighted buttons is a decision; this is a next step. The toolbar carries the
Expand Down
29 changes: 29 additions & 0 deletions lib/platform/macos_app_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import '../session/project_session.dart';
import '../theme/theme_controller.dart';
import '../ui/server_log/log_view_controller.dart';
import '../ui/server_log/server_log_view.dart';
import '../util/open_url.dart';
import '../util/prompt_generator.dart';

/// Adds custom menus to the native macOS menu bar while preserving the
/// standard items from MainMenu.xib.
Expand All @@ -32,6 +34,7 @@ class MacAppMenu {
required this.onCreateAndApplyMigrations,
required this.onCreateRepairMigration,
required this.logView,
this.openLink = openUrl,
}) {
session.addListener(_sync);
themeController.addListener(_sync);
Expand Down Expand Up @@ -82,6 +85,9 @@ class MacAppMenu {
static const _logsLevelMenuId = 'logs_level';
static const _logsAppPrefix = 'logs_source_app_';
static const _logsLevelPrefix = 'logs_level_';
static const _helpMenuId = 'Help';
static const _promptGeneratorId = 'help_prompt_generator';
static const _promptGeneratorIcon = 'sparkles';

final ProjectSession session;
final ServerpodProcessController process;
Expand Down Expand Up @@ -125,6 +131,10 @@ class MacAppMenu {
/// sets, and what its checkmarks follow.
final LogViewController logView;

/// Opens a web page in the user's browser. Injectable so a test can see what
/// Help → Open Prompt Generator asked for without a browser opening.
final Future<void> Function(Uri url) openLink;

/// The Flutter apps the Logs menu lists, by item id, in the runner's order.
/// Rebuilt only when the runner's app list changes: the log notifies on
/// every line, and removing and re-adding items that often would be absurd.
Expand Down Expand Up @@ -170,6 +180,7 @@ class MacAppMenu {
await _installViewMenu();
await _installServerMenu();
await _installLogsMenu();
await _installHelpMenu();
await _installAppMenuItems();

_installed = true;
Expand Down Expand Up @@ -278,6 +289,22 @@ class MacAppMenu {
);
}

/// Help → Open Prompt Generator, at the top of the stock Help menu.
///
/// The menu comes from MainMenu.xib and is addressed by its title, as View
/// is. macOS puts its own search field above the items; that is not an item
/// and does not move the index.
Future<void> _installHelpMenu() async {
final added = await MacMenuBar.addMenuItem(
menuId: _helpMenuId,
itemId: _promptGeneratorId,
title: 'Open Prompt Generator',
index: 0,
systemImage: _promptGeneratorIcon,
);
if (!added) debugPrint('MacAppMenu: could not reach the Help menu');
}

Future<void> _installFileMenu() async {
await MacMenuBar.addSubmenu(
parentMenuId: 'main',
Expand Down Expand Up @@ -619,6 +646,8 @@ class MacAppMenu {
onCheckForUpdates();
case _uninstallId:
onUninstall();
case _promptGeneratorId:
unawaited(openLink(kPromptGeneratorUrl));
case _autoUpdatesId:
// Sparkle owns the value; toggle it and let the sync reflect whatever
// it actually became.
Expand Down
7 changes: 7 additions & 0 deletions lib/platform/windows_app_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import '../session/project_session.dart';
import '../theme/theme_controller.dart';
import '../ui/server_log/log_view_controller.dart';
import '../ui/server_log/server_log_view.dart';
import '../util/open_url.dart';
import '../util/prompt_generator.dart';

/// The Windows counterpart of [MacAppMenu]: the same commands with the same
/// rules for when each is live, as a menu strip across the top of the window
Expand Down Expand Up @@ -459,6 +461,11 @@ class _WindowsAppMenuBarState extends State<WindowsAppMenuBar> {
final canCheck = widget.canCheckForUpdates();
final reason = widget.updatesUnavailableReason();
return [
_item(
'Open Prompt Generator',
onPressed: () => unawaited(openUrl(kPromptGeneratorUrl)),
),
_divider,
_item(
reason == null ? 'Check for Updates...' : 'Check for Updates ($reason)',
enabled: canCheck,
Expand Down
18 changes: 11 additions & 7 deletions lib/session/external_editors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,17 @@ class _EditorCli {
/// that takes a project directory. A CLI does not qualify — there is no window
/// to open a folder in, and "open in …" has to mean something visible.
///
/// **Antigravity is the one absence.** `/Applications/Antigravity.app` is not
/// the IDE: it is a thin Electron shell around a Go language server, with no
/// `open-file` handler and no `CFBundleDocumentTypes`, so a folder handed to it
/// is dropped and `open` still exits 0. The editor is a separate bundle,
/// `Antigravity IDE.app`, and no route into it has been confirmed. It is left
/// out only because no build of it has been seen to open the folder it was
/// given.
/// **Antigravity is `Antigravity IDE.app`, not `Antigravity.app`.** The latter
/// is a thin Electron shell around a Go language server, with no `open-file`
/// handler and no `CFBundleDocumentTypes`, so a folder handed to it is dropped
/// and `open` still exits 0. The IDE is a VS Code fork that declares
/// `public.folder`, so it takes the folder as a document like VS Code does.
/// Verified against Antigravity IDE 2.5.5: `open -a` opened the folder, and a
/// second call reused the running copy and opened the next folder beside it.
const _editorApps = <IdeIntegration, _EditorApp>{
IdeIntegration.cursor: _EditorApp('Cursor', cli: _cursorCli),
IdeIntegration.vscode: _EditorApp('Visual Studio Code'),
IdeIntegration.antigravity: _EditorApp('Antigravity IDE'),
IdeIntegration.claude: _EditorApp('Claude', deepLink: _claudeDeepLink),
IdeIntegration.codex: _EditorApp('Codex', deepLink: _codexDeepLink),
IdeIntegration.opencode: _EditorApp('OpenCode', deepLink: _openCodeDeepLink),
Expand Down Expand Up @@ -185,6 +186,9 @@ final class _WindowsLink extends _WindowsEditor {
final Uri Function(String projectPath) link;
}

/// Antigravity is macOS-only for now: where its Windows installer puts the IDE
/// has not been seen, and the `antigravity` scheme belongs to the agent shell,
/// not the editor.
const _windowsEditors = <IdeIntegration, _WindowsEditor>{
IdeIntegration.cursor: _WindowsCli(userDir: 'cursor', exe: 'Cursor.exe'),
IdeIntegration.vscode: _WindowsCli(
Expand Down
69 changes: 55 additions & 14 deletions lib/ui/project_startup_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:shad/shad.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../process/project_ready_view.dart';
import '../theme/app_theme.dart';
import '../util/open_url.dart';
import '../util/prompt_generator.dart';
import '../widgets/app_dialog.dart';
import '../widgets/dialog_body.dart';

Expand Down Expand Up @@ -45,10 +49,18 @@ Future<void> maybeShowProjectStartupNotice(
/// caller's job, which keeps this widget free of `dart:io` and easy to show in
/// Widgetbook.
class ProjectStartupDialog extends StatefulWidget {
const ProjectStartupDialog({super.key, required this.process});
const ProjectStartupDialog({
super.key,
required this.process,
this.openLink = openUrl,
});

final ProjectReadyView process;

/// Opens the Prompt Generator in the user's browser. Injectable so a test
/// can press the button without a browser opening.
final Future<void> Function(Uri url) openLink;

@override
State<ProjectStartupDialog> createState() => _ProjectStartupDialogState();
}
Expand Down Expand Up @@ -85,28 +97,57 @@ class _ProjectStartupDialogState extends State<ProjectStartupDialog> {
Widget build(BuildContext context) {
// The alert variant, not the primary one: its theme carries no
// `closeIconData`, so there is no X in the corner — which is right for a
// notice you acknowledge rather than dismiss. Nothing here is styled by
// hand; the copy goes in `description` so it picks up shad's body role
// (`style.body` over `textTheme.muted`) instead of a label style.
// notice you acknowledge rather than dismiss. The copy goes in
// `description` so it picks up shad's body role (`style.body` over
// `textTheme.muted`) instead of a label style.
return ShadDialog.alert(
title: const Text('Starting your project'),
description: const Text(
'App Studio is compiling your server and app, then starting them '
'up. The first run takes a minute or two.',
description: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
children: [
Text(
'App Studio is building your server and app and starting them '
'up. The first run takes a minute or two.',
),
Text(
'While you wait, write down what you want to build. The Prompt '
'Generator turns it into a prompt for your AI editor.',
),
],
),
// The row defaults to `min`/`end`, which would park the checkbox next to
// the button; `max` is what lets `spaceBetween` push them apart.
actionsMainAxisSize: MainAxisSize.max,
actionsMainAxisAlignment: MainAxisAlignment.spaceBetween,
actions: [
ShadCheckbox(
value: _dontShowAgain,
onChanged: (v) => setState(() => _dontShowAgain = v),
label: Text("Don't show this again", style: kWeightMedium),
// Flexible, as in the started notice: with two buttons beside it the
// row can run out of room, and the checkbox is the part that can wrap.
Flexible(
child: ShadCheckbox(
value: _dontShowAgain,
onChanged: (v) => setState(() => _dontShowAgain = v),
label: Text("Don't show this again", style: kWeightMedium),
),
),
ShadButton(
onPressed: () => Navigator.of(context).pop(_dontShowAgain),
child: const Text("Let's Go"),
// The two buttons travel together: three children under
// `spaceBetween` would strand the first one mid-row.
Row(
mainAxisSize: MainAxisSize.min,
spacing: 8,
children: [
// Opens the browser and leaves the notice up: the wait it describes
// is not over, and it still closes itself when the project starts.
ShadButton.outline(
onPressed: () => unawaited(widget.openLink(kPromptGeneratorUrl)),
trailing: const Icon(LucideIcons.arrowUpRight, size: 16),
child: const Text('Prompt Generator'),
),
ShadButton(
onPressed: () => Navigator.of(context).pop(_dontShowAgain),
child: const Text('Dismiss'),
),
],
),
],
child: const DialogBody(),
Expand Down
3 changes: 3 additions & 0 deletions lib/util/prompt_generator.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// Serverpod's prompt generator: it turns an idea for an app into a prompt for
/// an AI editor. Offered while a project starts, and from the Help menu.
final kPromptGeneratorUrl = Uri.parse('https://serverpod.dev/start-prompt');
12 changes: 12 additions & 0 deletions test/platform/macos_app_menu_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ void main() {
late MacAppMenu menu;
var migrations = 0;
var newProjects = 0;
late List<Uri> opened;

setUp(() async {
SharedPreferences.setMockInitialValues({});
calls = [];
migrations = 0;
newProjects = 0;
opened = [];
// Tests run as Android, where the plugin picks its no-op implementation.
MacMenuBarPlatform.instance = MethodChannelMacMenuBar();
messenger.setMockMethodCallHandler(channel, (call) async {
Expand Down Expand Up @@ -72,6 +74,7 @@ void main() {
onCreateAndApplyMigrations: () => migrations++,
onCreateRepairMigration: () {},
logView: logView,
openLink: (url) async => opened.add(url),
);
await menu.install();
});
Expand Down Expand Up @@ -101,6 +104,15 @@ void main() {
orElse: () => fail('$itemId was never added'),
);

test('Help opens the prompt generator', () async {
final item = added('help_prompt_generator');
expect(item['menuId'], 'Help');
expect(item['title'], 'Open Prompt Generator');

await click('help_prompt_generator');
expect(opened, [Uri.parse('https://serverpod.dev/start-prompt')]);
});

test('Server and Logs sit between View and Window', () {
expect(added('server')['title'], 'Server');
expect(added('server')['index'], 4);
Expand Down
Loading
Loading