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.

Team delete: show the 'Nothing was changed' note under the Delete button

Lin (kwant bot)3b98fc5c2c77
diff --git a/frontend/src/components/ManageTeamModal.tsx b/frontend/src/components/ManageTeamModal.tsx
index f77196cf..91c8a797 100644
--- a/frontend/src/components/ManageTeamModal.tsx
+++ b/frontend/src/components/ManageTeamModal.tsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useRef } from 'react';
import { X, Users, Trash2, Check, AlertTriangle, ShieldCheck, Folder, GitBranch, FolderSearch } from 'lucide-react';
import { ModernAvatar } from './ModernAvatar';
import { Team, Kwant } from './Sidebar';
@@ -27,6 +27,24 @@ interface ManageTeamModalProps {
onDeleteTeam: (id: string) => Promise<void>;
}
+/**
+ * Why a delete didn't happen, shown right below the Delete button. On a phone the modal is scrolled
+ * down to that button, so a note at the top would be out of sight; this one scrolls itself into view.
+ */
+export const DeleteNote: React.FC<{ text: string | null }> = ({ text }) => {
+ const ref = useRef<HTMLDivElement>(null);
+ useEffect(() => {
+ if (text) ref.current?.scrollIntoView?.({ block: 'nearest', behavior: 'smooth' });
+ }, [text]);
+ if (!text) return null;
+ return (
+ <div ref={ref} role="alert" data-testid="team-delete-note" className="p-2.5 bg-rose-500/10 border border-rose-500/20 rounded-xl text-xs text-rose-300 flex items-center gap-2">
+ <AlertTriangle size={14} className="flex-shrink-0 text-rose-400" aria-hidden="true" />
+ <span>{text}</span>
+ </div>
+ );
+};
+
export const ManageTeamModal: React.FC<ManageTeamModalProps> = ({
isOpen,
team,
@@ -49,6 +67,7 @@ export const ManageTeamModal: React.FC<ManageTeamModalProps> = ({
const [confirmDelete, setConfirmDelete] = useState(false);
const [isSaving, setIsSaving] = useState(false);
const [error, setError] = useState<string | null>(null);
+ const [deleteError, setDeleteError] = useState<string | null>(null);
const handleBrowseFolder = async () => {
playSfx('click');
@@ -102,6 +121,7 @@ export const ManageTeamModal: React.FC<ManageTeamModalProps> = ({
setMemberIds(parsedMembers);
setConfirmDelete(false);
setError(null);
+ setDeleteError(null);
}
}, [team, kwants, isOpen]);
@@ -172,13 +192,14 @@ export const ManageTeamModal: React.FC<ManageTeamModalProps> = ({
try {
setIsDeleting(true);
+ setDeleteError(null);
playSfx('click');
await onDeleteTeam(team.id);
setIsDeleting(false);
onClose();
} catch (err) {
setIsDeleting(false);
- setError(err instanceof Error && err.message ? err.message : 'Couldn’t delete the team.');
+ setDeleteError(err instanceof Error && err.message ? err.message : 'Couldn’t delete the team.');
}
};
@@ -506,6 +527,8 @@ export const ManageTeamModal: React.FC<ManageTeamModalProps> = ({
</button>
</div>
</div>
+
+ <DeleteNote text={deleteError} />
</form>
</div>
diff --git a/frontend/tests/teamDeleteNote.test.mjs b/frontend/tests/teamDeleteNote.test.mjs
new file mode 100644
index 00000000..8ae43807
--- /dev/null
+++ b/frontend/tests/teamDeleteNote.test.mjs
@@ -0,0 +1,38 @@
+// Team delete on a phone (2026-10-20): the modal is scrolled down to the Delete button, so the
+// "Nothing was changed" note after "Not now" sits right above that button, not at the top.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { loadBundled } from './bundle.mjs';
+
+// The sound effects module reads its mute flag on load.
+globalThis.localStorage ??= { getItem: () => null, setItem: () => {} };
+
+const m = await loadBundled(`
+ export { createElement } from 'react';
+ export { renderToStaticMarkup } from 'react-dom/server.browser';
+ export { ManageTeamModal, DeleteNote } from './src/components/ManageTeamModal';
+ export { PERSON_CANCELLED_TEXT } from './src/auth';
+`);
+
+test('the delete note is an alert with the reason, and renders nothing without one', () => {
+ const html = m.renderToStaticMarkup(m.createElement(m.DeleteNote, { text: m.PERSON_CANCELLED_TEXT }));
+ assert.match(html, /role="alert"/);
+ assert.ok(html.includes('Nothing was changed'));
+ assert.equal(m.renderToStaticMarkup(m.createElement(m.DeleteNote, { text: null })), '');
+});
+
+test('the team modal has no delete note before a delete is tried', () => {
+ const team = { id: 't1', name: 'crew', lead_kwant_id: 'k1', member_kwants: ['k1'] };
+ const html = m.renderToStaticMarkup(
+ m.createElement(m.ManageTeamModal, {
+ isOpen: true,
+ team,
+ kwants: [{ id: 'k1', name: 'Ada' }],
+ onClose: () => {},
+ onUpdateTeam: async () => {},
+ onDeleteTeam: async () => {},
+ }),
+ );
+ assert.ok(html.includes('Delete Team'));
+ assert.ok(!html.includes('team-delete-note'));
+});