fix(cli): rename syncs local config + picker shows display name
Some checks failed
CI / Lint (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Broker tests (Postgres) (push) Has been cancelled
CI / Docker build (linux/amd64) (push) Has been cancelled

After renaming the mesh display name on the server, the launch
picker still showed the slug ("flexicar-2") because (a) local
config.json was not updated and (b) the picker only printed
mesh.slug. Now: rename writes the new name back into config.json
on success, and the picker prints "name (slug)" when they differ.
Also surfaces a hint that slugs are immutable (today).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-05-03 14:52:50 +01:00
parent f3649d761f
commit 5a1d5d6a49
3 changed files with 10 additions and 2 deletions

View File

@@ -49,7 +49,8 @@ async function pickMesh(meshes: JoinedMesh[]): Promise<JoinedMesh> {
console.log("\n Select mesh:");
meshes.forEach((m, i) => {
console.log(` ${i + 1}) ${m.slug}`);
const label = m.name && m.name !== m.slug ? `${m.name} \x1b[2m(${m.slug})\x1b[0m` : m.slug;
console.log(` ${i + 1}) ${label}`);
});
console.log("");

View File

@@ -1,6 +1,7 @@
import { rename as renameMesh } from "~/services/mesh/facade.js";
import { getStoredToken } from "~/services/auth/facade.js";
import { ApiError } from "~/services/api/facade.js";
import { readConfig, setMeshConfig } from "~/services/config/facade.js";
import { bold, dim, green, icons } from "~/ui/styles.js";
import { EXIT } from "~/constants/exit-codes.js";
@@ -19,7 +20,13 @@ export async function rename(slug: string, newName: string): Promise<number> {
try {
await renameMesh(slug, newName);
// Sync the new name into local config so launch / picker
// reflect the change without waiting for the next sync.
const cfg = readConfig();
const local = cfg.meshes.find((m) => m.slug === slug);
if (local) setMeshConfig(slug, { ...local, name: newName });
console.log(` ${green(icons.check)} Renamed "${slug}" to "${newName}"`);
console.log(` ${dim("(slug stays \"" + slug + "\" — only the display name changed)")}`);
return EXIT.SUCCESS;
} catch (err) {
if (err instanceof ApiError) {