Auto-generate session name when user creates without typing one
Click "Create session" with the input empty and a name of the form `YYMMDD-session-NNN` is generated automatically: today's date as two-digit year/month/day, then a zero-padded counter that starts at 000 and increments past the highest existing match for the same day. Added: - `computeNextDefaultName(existing, now?)` pure helper exported from `@engine/services/sessions`. - `SessionService.nextDefaultName(now?)` method that wraps it against the current repo. - Both create call sites (CreateFirstSession empty state + SessionMenu's New session form) fall back to `service.nextDefaultName()` when the trimmed input is empty. - 5 new unit tests covering today-only counting, max-not-count increment, and trimmed/wrong-shape filtering. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
430c0e124c
commit
f42b4ec87c
5 changed files with 89 additions and 2 deletions
|
|
@ -33,7 +33,9 @@ export function CreateFirstSession() {
|
|||
const handleCreate = useCallback(() => {
|
||||
setError(null);
|
||||
try {
|
||||
const created = service.create(name);
|
||||
const trimmed = name.trim();
|
||||
const effective = trimmed.length === 0 ? service.nextDefaultName() : name;
|
||||
const created = service.create(effective);
|
||||
navigateTo({ sessionId: created.id, mode: "review" });
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : String(err));
|
||||
|
|
|
|||
|
|
@ -104,7 +104,9 @@ export function SessionMenu({ onExportZip, onImportZip, onOpenSamples }: Session
|
|||
const handleCreate = useCallback(() => {
|
||||
setError(null);
|
||||
try {
|
||||
const created = service.create(newName);
|
||||
const trimmed = newName.trim();
|
||||
const effective = trimmed.length === 0 ? service.nextDefaultName() : newName;
|
||||
const created = service.create(effective);
|
||||
setNewName("");
|
||||
setCreating(false);
|
||||
setOpen(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue