Skip to content

armgit / kwant

Public Imported from GitHub
0

Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.

Manage Team: saving no longer renames the team

Lin (kwant bot)bf4e2a13fda9
diff --git a/frontend/src/components/ManageTeamModal.tsx b/frontend/src/components/ManageTeamModal.tsx
index 91c8a797..6ba13b8e 100644
--- a/frontend/src/components/ManageTeamModal.tsx
+++ b/frontend/src/components/ManageTeamModal.tsx
@@ -6,6 +6,7 @@ import { FolderBrowserModal } from './FolderBrowserModal';
import { playSfx } from '../audio/chiptune';
import { InstructionsField } from './Instructions';
import { MAX_INSTRUCTIONS } from '../continuity';
+import { teamNameToSave } from '../teamChannel';
interface ManageTeamModalProps {
isOpen: boolean;
@@ -148,7 +149,7 @@ export const ManageTeamModal: React.FC<ManageTeamModalProps> = ({
const handleSave = async (e: React.FormEvent) => {
e.preventDefault();
- const cleanName = name.trim().toLowerCase().replace(/[^a-z0-9_-]/g, '-');
+ const cleanName = teamNameToSave(name, team.name);
if (!cleanName) {
setError('Please provide a valid team name.');
return;
diff --git a/frontend/src/teamChannel.ts b/frontend/src/teamChannel.ts
index e7377e62..b94a650e 100644
--- a/frontend/src/teamChannel.ts
+++ b/frontend/src/teamChannel.ts
@@ -16,3 +16,8 @@ export const teamChannelOf = <C extends Named>(channels: C[], t: Named): C | und
/** The team whose chat channel `c` is, if any. */
export const teamOfChannel = <T extends Named>(teams: T[], c: Named): T | undefined =>
teams.find((t) => t.id === c.id || c.name === `team-${t.name}`) ?? teams.find((t) => isTeamChannel(c, t));
+
+/** The name Manage Team saves: `typed` made into a handle, unless it is still the team's own name
+ * (a hired team can be called "Startup"), so saving other changes never renames the team. */
+export const teamNameToSave = (typed: string, current: string) =>
+ typed.trim() === current ? current : typed.trim().toLowerCase().replace(/[^a-z0-9_-]/g, '-');
diff --git a/frontend/tests/teamChannel.test.mjs b/frontend/tests/teamChannel.test.mjs
index 7bcfa834..1a71a9f8 100644
--- a/frontend/tests/teamChannel.test.mjs
+++ b/frontend/tests/teamChannel.test.mjs
@@ -35,3 +35,14 @@ test('the sidebar hides every team chat and nothing else', async () => {
const shown = channels.filter((c) => ![startup].some((t) => teamChannelOf(channels, t)?.id === c.id));
assert.deepEqual(shown.map((c) => c.name), ['general', 'team-ghost']);
});
+
+test("saving Manage Team keeps a hired team's name as it is", async () => {
+ const { teamNameToSave } = await loadBundled(`export * from './src/teamChannel';`);
+ // The bug: any save turned "Startup" into "startup", and the team lost its chat.
+ assert.equal(teamNameToSave('Startup', 'Startup'), 'Startup');
+ assert.equal(teamNameToSave(' Startup ', 'Startup'), 'Startup');
+ // A name the person actually typed is still made into a handle.
+ assert.equal(teamNameToSave('Launch Crew', 'Startup'), 'launch-crew');
+ const src = (await import('node:fs')).readFileSync(new URL('../src/components/ManageTeamModal.tsx', import.meta.url), 'utf8');
+ assert.match(src, /teamNameToSave\(name, team\.name\)/);
+});