feat(welcome): New project flow + per-repo account roadblock (T-488)
The UI half of the new-project flow (story T-486). A "New project…" welcome action opens a dialog (location + name) that dispatches project.new (T-487), opens the result, and announces it on projectCreatedChannel. The Claude extension consumes that and shows the account roadblock — the embedded per-workspace picker + accounts list, so a fresh project gets bound to an account (or Default) right at birth. The two halves stay decoupled: the welcome builtin only publishes the event (no claude import); the claude builtin owns the account dialog. Only freshly- created projects announce, so existing opens are never prompted. Closes T-488. The non-repo "initialize as a project" path (T-489) is next. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
/// The per-repo account roadblock shown right after a new project is created
|
||||
/// (T-488, story T-486). Only a freshly-created project reaches here (the
|
||||
/// welcome dialog announces it on projectCreatedChannel) — existing opens never
|
||||
/// prompt. The new project is already the open workspace, so the embedded
|
||||
/// per-workspace picker binds it directly; the accounts list lets a first-run
|
||||
/// user add + sign in to an account before picking. No-Material (D-7).
|
||||
library;
|
||||
|
||||
import 'package:clide/builtin/claude/src/account_settings_control.dart';
|
||||
import 'package:clide/widgets/widgets.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class ClaudeAccountRoadblockDialog extends StatelessWidget {
|
||||
const ClaudeAccountRoadblockDialog({super.key, required this.projectName, required this.onClose});
|
||||
|
||||
final String projectName;
|
||||
final VoidCallback onClose;
|
||||
|
||||
KeyEventResult _onKey(FocusNode node, KeyEvent e) {
|
||||
if (e is KeyDownEvent && e.logicalKey == LogicalKeyboardKey.escape) {
|
||||
onClose();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ClideSettings.theme.of(context).surface;
|
||||
return Focus(
|
||||
autofocus: true,
|
||||
onKeyEvent: _onKey,
|
||||
child: Container(
|
||||
width: 560,
|
||||
constraints: const BoxConstraints(maxHeight: 540),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.modalSurfaceBackground,
|
||||
border: Border.all(color: theme.modalSurfaceBorder),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(18),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
ClideText('Claude account for $projectName', fontSize: clideFontDialogTitle, fontWeight: FontWeight.w600, color: theme.globalForeground),
|
||||
const SizedBox(height: 4),
|
||||
ClideText(
|
||||
'Pick which Claude account this new project runs under, or keep the default system login. You can change it later in Settings or the pane badge.',
|
||||
muted: true,
|
||||
fontSize: clideFontMeta,
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
ClideText('Account for this project', fontSize: clideFontMeta, muted: true),
|
||||
const SizedBox(height: 6),
|
||||
const Align(alignment: Alignment.centerLeft, child: ClaudeWorkspaceAccountControl()),
|
||||
const SizedBox(height: 18),
|
||||
ClideText('Accounts', fontSize: clideFontMeta, muted: true),
|
||||
const SizedBox(height: 6),
|
||||
const ClaudeAccountsListControl(),
|
||||
const SizedBox(height: 18),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: ClideButton(label: 'Continue', onPressed: onClose),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import 'dart:io';
|
||||
import 'package:clide/clide.dart';
|
||||
import 'package:clide/builtin/claude/src/account_registry.dart';
|
||||
import 'package:clide/builtin/claude/src/account_login_dialog.dart';
|
||||
import 'package:clide/builtin/claude/src/account_roadblock_dialog.dart';
|
||||
import 'package:clide/builtin/claude/src/account_settings_control.dart';
|
||||
import 'package:clide/builtin/claude/src/activity_cluster.dart' show foldLevelFromName, kActivityFoldLevelKey, nextFoldLevel;
|
||||
import 'package:clide/builtin/claude/src/claude_config.dart';
|
||||
@@ -20,6 +21,7 @@ import 'package:clide/builtin/claude/src/session_storage.dart';
|
||||
import 'package:clide/builtin/claude/src/ticket_pick_up.dart';
|
||||
import 'package:clide/builtin/claude/src/transcript_reader.dart' show ImageMessage;
|
||||
import 'package:clide/src/daemon/claude_account_commands.dart' show accountActionChannel;
|
||||
import 'package:clide/src/daemon/project_commands.dart' show projectCreatedChannel;
|
||||
import 'package:clide/src/daemon/image_commands.dart' show imageShowChannel;
|
||||
import 'package:clide/builtin/claude/src/team_chat_sidebar.dart' show TeamChatPane;
|
||||
import 'package:clide/builtin/claude/src/team_panel_host.dart';
|
||||
@@ -530,6 +532,19 @@ class ClaudeExtension extends ClideExtension {
|
||||
// writes the registry then publishes here; only the UI layer can respawn
|
||||
// the workspace's panes onto the newly-bound account or delete a config dir.
|
||||
_subs.add(ctx.messages.subscribe(channel: accountActionChannel).listen(_onAccountAction));
|
||||
|
||||
// A freshly-created project (T-488) announces itself once it's open; show the
|
||||
// per-repo account roadblock so the user binds it now (existing opens, which
|
||||
// never announce, are never prompted).
|
||||
_subs.add(ctx.messages.subscribe(channel: projectCreatedChannel).listen(_onProjectCreated));
|
||||
}
|
||||
|
||||
void _onProjectCreated(Message m) {
|
||||
final dir = m.data['dir'] as String?;
|
||||
final ctx = _ctx;
|
||||
if (dir == null || ctx == null) return;
|
||||
final name = dir.split('/').where((s) => s.isNotEmpty).lastOrNull ?? dir;
|
||||
ctx.dialog.show<Object>((c, dismiss) => ClaudeAccountRoadblockDialog(projectName: name, onClose: dismiss));
|
||||
}
|
||||
|
||||
/// Side-effects for the `claude account` verbs (T-480). The dispatcher does
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:clide/clide.dart' show clideName, clideTagline, clideVersion;
|
||||
import 'package:clide/kernel/kernel.dart';
|
||||
import 'package:clide/src/daemon/project_commands.dart' show projectCreatedChannel;
|
||||
import 'package:clide/widgets/widgets.dart';
|
||||
import 'package:flutter/services.dart' show MissingPluginException;
|
||||
import 'package:flutter/widgets.dart';
|
||||
@@ -198,10 +199,20 @@ class _StartColumn extends StatelessWidget {
|
||||
tokens: tokens,
|
||||
onTap: () => _openFolder(context),
|
||||
),
|
||||
_ActionRow(
|
||||
icon: PhosphorIcons.byName('folder-plus'),
|
||||
label: ClideSettings.i18n.string(context, 'action.newProject', namespace: 'builtin.welcome', placeholder: 'New project…'),
|
||||
tokens: tokens,
|
||||
onTap: () => _newProject(context),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _newProject(BuildContext context) {
|
||||
kernel.dialog.show<Object>((ctx, dismiss) => _NewProjectDialog(kernel: kernel, onClose: () => dismiss()));
|
||||
}
|
||||
|
||||
void _openFolder(BuildContext context) async {
|
||||
try {
|
||||
final picked = await kernel.window.pickDirectory();
|
||||
@@ -683,3 +694,178 @@ class _NotARepoDialog extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// New-project dialog (T-488, story T-486): pick a location + name, create the
|
||||
/// project via `project.new`, open it, and announce it on [projectCreatedChannel]
|
||||
/// so the Claude extension can run the per-repo account roadblock. Stays
|
||||
/// claude-free — the account step is the consumer's job, not this dialog's.
|
||||
class _NewProjectDialog extends StatefulWidget {
|
||||
const _NewProjectDialog({required this.kernel, required this.onClose});
|
||||
final KernelServices kernel;
|
||||
final VoidCallback onClose;
|
||||
|
||||
@override
|
||||
State<_NewProjectDialog> createState() => _NewProjectDialogState();
|
||||
}
|
||||
|
||||
class _NewProjectDialogState extends State<_NewProjectDialog> {
|
||||
final TextEditingController _parent = TextEditingController();
|
||||
final TextEditingController _name = TextEditingController();
|
||||
final FocusNode _parentFocus = FocusNode(debugLabel: 'new-project-parent');
|
||||
final FocusNode _nameFocus = FocusNode(debugLabel: 'new-project-name');
|
||||
String? _error;
|
||||
bool _loading = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_parent.dispose();
|
||||
_name.dispose();
|
||||
_parentFocus.dispose();
|
||||
_nameFocus.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _browse() async {
|
||||
try {
|
||||
final picked = await widget.kernel.window.pickDirectory();
|
||||
if (picked != null && mounted) setState(() => _parent.text = picked);
|
||||
} on MissingPluginException {
|
||||
// No native picker on this platform — the user types the path instead.
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _create() async {
|
||||
final name = _name.text.trim();
|
||||
final parent = _parent.text.trim();
|
||||
if (name.isEmpty) return setState(() => _error = 'Enter a project name.');
|
||||
if (parent.isEmpty) return setState(() => _error = 'Choose a location.');
|
||||
setState(() {
|
||||
_loading = true;
|
||||
_error = null;
|
||||
});
|
||||
final r = await widget.kernel.ipc.request(
|
||||
'project.new',
|
||||
args: {
|
||||
'positional': [name],
|
||||
'flags': {'dir': parent},
|
||||
},
|
||||
);
|
||||
if (!mounted) return;
|
||||
if (!r.ok) {
|
||||
return setState(() {
|
||||
_loading = false;
|
||||
_error = r.error?.message ?? 'Could not create the project.';
|
||||
});
|
||||
}
|
||||
final path = r.data['path'] as String;
|
||||
// Open the new workspace, then announce it — only a freshly-created project
|
||||
// announces, so only it triggers the account roadblock (T-488).
|
||||
final opened = await widget.kernel.project.open(path);
|
||||
if (opened) widget.kernel.panels.activateTab(Slots.workspace, 'claude.primary');
|
||||
widget.kernel.messages.publish('welcome', projectCreatedChannel, {'dir': path});
|
||||
widget.onClose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tokens = ClideSettings.theme.of(context).surface;
|
||||
return Container(
|
||||
width: 460,
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: tokens.modalSurfaceBackground,
|
||||
border: Border.all(color: tokens.modalSurfaceBorder),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClideText(
|
||||
ClideSettings.i18n.string(context, 'dialog.newProject.title', namespace: 'builtin.welcome', placeholder: 'New project'),
|
||||
fontSize: clideFontDialogTitle,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
ClideText(
|
||||
ClideSettings.i18n.string(
|
||||
context,
|
||||
'dialog.newProject.body',
|
||||
namespace: 'builtin.welcome',
|
||||
placeholder: 'Creates a git repo + a CLAUDE.md, then opens it.',
|
||||
),
|
||||
muted: true,
|
||||
fontSize: clideFontMeta,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_field(
|
||||
tokens,
|
||||
'Location',
|
||||
_parent,
|
||||
_parentFocus,
|
||||
trailing: ClideButton(label: 'Browse…', onPressed: _browse),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_field(tokens, 'Name', _name, _nameFocus, onSubmit: _create),
|
||||
if (_error != null) ...[const SizedBox(height: 8), ClideText(_error!, color: tokens.statusError, fontSize: clideFontSmall)],
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
ClideButton(
|
||||
label: ClideSettings.i18n.string(context, 'button.cancel', namespace: 'builtin.welcome', placeholder: 'Cancel'),
|
||||
onPressed: widget.onClose,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ClideButton(
|
||||
label: _loading
|
||||
? ClideSettings.i18n.string(context, 'button.creating', namespace: 'builtin.welcome', placeholder: 'Creating…')
|
||||
: ClideSettings.i18n.string(context, 'button.create', namespace: 'builtin.welcome', placeholder: 'Create'),
|
||||
onPressed: _loading ? null : _create,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _field(SurfaceTokens tokens, String label, TextEditingController c, FocusNode f, {Widget? trailing, Future<void> Function()? onSubmit}) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ClideText(label, fontSize: clideFontMeta, muted: true),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: tokens.panelBackground,
|
||||
border: Border.all(color: f.hasFocus ? tokens.panelActiveBorder : tokens.globalBorder),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: EditableText(
|
||||
controller: c,
|
||||
focusNode: f,
|
||||
style: TextStyle(
|
||||
color: tokens.globalForeground,
|
||||
fontSize: clideFontCaption,
|
||||
fontFamily: ClideSettings.fonts.monoOf(context),
|
||||
fontFamilyFallback: clideMonoFamilyFallback,
|
||||
),
|
||||
cursorColor: tokens.globalForeground,
|
||||
backgroundCursorColor: tokens.globalTextMuted,
|
||||
maxLines: 1,
|
||||
onSubmitted: onSubmit == null ? null : (_) => unawaited(onSubmit()),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (trailing != null) ...[const SizedBox(width: 8), trailing],
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,13 @@ import '../ipc/envelope.dart';
|
||||
import '../ipc/schema_v1.dart';
|
||||
import 'dispatcher.dart';
|
||||
|
||||
/// MessageBus channel announcing a freshly-created project (path in `dir`). The
|
||||
/// welcome new-project dialog publishes it after create + open; the Claude
|
||||
/// extension consumes it to show the per-repo account roadblock (T-488) — only
|
||||
/// NEW projects prompt, existing opens never do. Lives here in the neutral
|
||||
/// daemon layer so both builtins name one literal without coupling to each other.
|
||||
const projectCreatedChannel = 'project.created';
|
||||
|
||||
/// Runs `git init` in [dir]. Injected so this stays Flutter-free + testable;
|
||||
/// main.dart wires it to the real toolchain.
|
||||
typedef ProjectGitInit = Future<void> Function(String dir);
|
||||
|
||||
Reference in New Issue
Block a user