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.

Get started: a new space's #general never shows the main space's welcome (0.9.5) (#553)

Oleksandr Ivanchenko29a3d5db3209
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 25c64028..71d377ed 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -3734,6 +3734,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({
generalMessages: messages.length,
teams: teams.length,
started: getStartedWasStarted(space.id),
+ mainSpace: space.is_default,
});
// New bots, teams and their team chats after an import (Space settings or Get started).
const reloadAfterImport = () => {
@@ -3753,6 +3754,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({
onDismissed={() => undefined}
spaceName={space.name}
onImported={reloadAfterImport}
+ mainSpace={space.is_default}
/>
) : null;
const setupChecklist = (
diff --git a/frontend/src/components/GetStarted.tsx b/frontend/src/components/GetStarted.tsx
index 9d9d276c..f17e5c44 100644
--- a/frontend/src/components/GetStarted.tsx
+++ b/frontend/src/components/GetStarted.tsx
@@ -38,6 +38,7 @@ import {
installable,
isImported,
isKept,
+ keepOwnBotsLine,
isLive,
isSignInUrl,
loginApi as defaultLoginApi,
@@ -756,13 +757,17 @@ const KeyPanel: React.FC<{ phone: boolean; onAdded: () => void }> = ({ phone, on
const TeamStep: React.FC<{
phone: boolean;
spaceName: string;
+ /** False outside the main space: Keep names this space's own bots, not the main space's starters. */
+ mainSpace: boolean;
+ /** The space's bots, for that line. */
+ botNames: string[];
onKeep: () => void;
onPicked: () => void;
/** After the import dialog closes with at least one import done: step 3 is done. */
onImported: () => void;
/** Each Import or Undo inside the dialog, so the sidebar loads the new bots. */
onImportChanged?: () => void;
-}> = ({ phone, spaceName, onKeep, onPicked, onImported, onImportChanged }) => {
+}> = ({ phone, spaceName, mainSpace, botNames, onKeep, onPicked, onImported, onImportChanged }) => {
const rt = useReadyTeams();
const [importing, setImporting] = useState(false);
const imported = useRef(false);
@@ -813,8 +818,8 @@ const TeamStep: React.FC<{
))}
<li>
<button type="button" data-keep-starter onClick={onKeep} className={`${tile} h-full flex flex-col gap-1 border-dashed border-zinc-600 bg-transparent hover:border-zinc-500`}>
- <span className="text-sm font-semibold text-zinc-100">Keep the starter bots</span>
- <span className="text-[12.5px] leading-[18px] text-zinc-300">Architect, TechLead and DevOps, in #general.</span>
+ <span className="text-sm font-semibold text-zinc-100">{mainSpace ? 'Keep the starter bots' : 'Keep the bots you have'}</span>
+ <span className="text-[12.5px] leading-[18px] text-zinc-300">{mainSpace ? 'Architect, TechLead and DevOps, in #general.' : keepOwnBotsLine(botNames, spaceName)}</span>
<span className="mt-auto text-right text-xs text-sky-300" aria-hidden="true">
Use ›
</span>
@@ -879,9 +884,11 @@ export interface GetStartedProps {
spaceName?: string;
/** After an Import or Undo from "Bring your bots": new bots, teams and team chats. */
onImported?: () => void;
+ /** The space's `is_default`. Only the main space has the starter bots; left out counts as main. */
+ mainSpace?: boolean;
}
-export const GetStarted: React.FC<GetStartedProps> = ({ space, bots, engines, reloadEngines, onDismissed, loginApiOverride, hostOverride, spaceName, onImported }) => {
+export const GetStarted: React.FC<GetStartedProps> = ({ space, bots, engines, reloadEngines, onDismissed, loginApiOverride, hostOverride, spaceName, onImported, mainSpace = true }) => {
const api = loginApiOverride ?? defaultLoginApi;
const phone = useMedia(PHONE_QUERY);
useStartVersion();
@@ -1109,7 +1116,7 @@ export const GetStarted: React.FC<GetStartedProps> = ({ space, bots, engines, re
3,
'Pick a team',
v.open === 3 && !done3 ? 'open' : done3 ? 'done' : 'todo',
- done3 ? (importedHere ? 'Your imported bots' : 'Starter bots') : undefined,
+ done3 ? (importedHere ? 'Your imported bots' : mainSpace ? 'Starter bots' : 'Your bots') : undefined,
v.open === 2 && slow && !done3 ? (
<Btn phone={phone} kind="link" className="ml-auto shrink-0" onClick={() => setTeamEarly(true)}>
Open
@@ -1118,7 +1125,16 @@ export const GetStarted: React.FC<GetStartedProps> = ({ space, bots, engines, re
)}
{v.open === 3 && !done3 ? (
<div className={`${body} gs-open`}>
- <TeamStep phone={phone} spaceName={spaceName ?? 'this space'} onKeep={keep} onPicked={() => undefined} onImported={importedBots} onImportChanged={onImported} />
+ <TeamStep
+ phone={phone}
+ spaceName={spaceName ?? 'this space'}
+ mainSpace={mainSpace}
+ botNames={bots.map((b) => b.name)}
+ onKeep={keep}
+ onPicked={() => undefined}
+ onImported={importedBots}
+ onImportChanged={onImported}
+ />
</div>
) : null}
</div>
diff --git a/frontend/src/gettingStarted.ts b/frontend/src/gettingStarted.ts
index 0c2be37e..e81f5b44 100644
--- a/frontend/src/gettingStarted.ts
+++ b/frontend/src/gettingStarted.ts
@@ -464,15 +464,35 @@ export function storeChoice(space: string, c: AiChoice | null) {
* Whether #general shows the card (C4): not dismissed here, and either nothing can run yet or the
* card was started here, or #general is still empty in a space with only the starter team (a fresh install that
* found an account already signed in, D2). An older install with any history never sees it.
+ *
+ * The fresh-install welcome and its starter bots belong to the main space (`mainSpace`, the server's
+ * `is_default`; left out counts as main). Another space shows the card only while nothing can run there:
+ * a new space that got its bots (from words, a template or an import) with an account ready is not a fresh
+ * install, and the main space's starter bots aren't in it.
*/
-export function showCard(opts: { dismissed: boolean; canRun: boolean | null; generalMessages: number; teams: number; started: boolean }): boolean {
+export function showCard(opts: { dismissed: boolean; canRun: boolean | null; generalMessages: number; teams: number; started: boolean; mainSpace?: boolean }): boolean {
if (opts.dismissed) return false;
- if (opts.canRun === false || opts.started) return true;
+ if (opts.canRun === false) return true;
+ if (opts.mainSpace === false) return false;
+ if (opts.started) return true;
if (opts.canRun === null) return false;
// A fresh install comes with one starter team (core-engineering), so one team still counts as fresh.
return opts.generalMessages === 0 && opts.teams <= 1;
}
+/**
+ * Step 3's "keep" tile outside the main space: the bots this space already has, never the main space's
+ * starters. Up to three names, then "and N more".
+ */
+export function keepOwnBotsLine(names: string[], spaceName: string): string {
+ const where = `already in ${spaceName}.`;
+ if (!names.length) return `The bots ${where}`;
+ const shown = names.slice(0, names.length > 3 ? 2 : 3);
+ const rest = names.length - shown.length;
+ const list = rest > 0 ? `${shown.join(', ')} and ${rest} more` : shown.length === 1 ? shown[0] : `${shown.slice(0, -1).join(', ')} and ${shown[shown.length - 1]}`;
+ return `${list}, ${where}`;
+}
+
/**
* Whether What's new may treat this person as someone who has used kwant (true), as brand new (false: the
* version is recorded silently), or can't tell yet (null: wait). Get started wins (F-1): a fresh install that
diff --git a/frontend/tests/gettingStarted.test.mjs b/frontend/tests/gettingStarted.test.mjs
index 236329d6..2edfa9d3 100644
--- a/frontend/tests/gettingStarted.test.mjs
+++ b/frontend/tests/gettingStarted.test.mjs
@@ -83,6 +83,34 @@ test('the card shows for a fresh space, never for an older one with history, nev
assert.equal(m.showCard({ ...base, canRun: false, dismissed: true }), false);
});
+test('0.9.5: a new space with bots and an account is not a fresh install; only its own missing account brings the card', () => {
+ // Bakery: a second space that got its team from words, with an account ready. #general was empty and
+ // it had one team, so the main space's fresh-install rule showed the welcome card with the main space's
+ // starter bots.
+ const bakery = { dismissed: false, canRun: true, generalMessages: 0, teams: 1, started: false, mainSpace: false };
+ assert.equal(m.showCard(bakery), false, 'no welcome card in a new space that can already run');
+ assert.equal(m.showCard({ ...bakery, teams: 0 }), false);
+ assert.equal(m.showCard({ ...bakery, started: true }), false, 'a card started there by the old rule goes once an account works');
+ assert.equal(m.showCard({ ...bakery, canRun: false }), true, "the space's own state: nothing can run its bots yet");
+ assert.equal(m.showCard({ ...bakery, canRun: false, dismissed: true }), false);
+ assert.equal(m.showCard({ ...bakery, canRun: null }), false);
+ // The main space keeps today's rule, with the flag given or left out.
+ const main = { ...bakery, mainSpace: true };
+ assert.equal(m.showCard(main), true);
+ assert.equal(m.showCard({ ...main, teams: 2, started: true }), true);
+ assert.equal(m.showCard({ ...main, teams: 2 }), false);
+ const { mainSpace: _, ...unflagged } = bakery;
+ assert.equal(m.showCard(unflagged), true);
+});
+
+test('0.9.5: keep line names the space\'s own bots', () => {
+ assert.equal(m.keepOwnBotsLine([], 'Bakery'), 'The bots already in Bakery.');
+ assert.equal(m.keepOwnBotsLine(['BakeryLead'], 'Bakery'), 'BakeryLead, already in Bakery.');
+ assert.equal(m.keepOwnBotsLine(['BakeryLead', 'Baker'], 'Bakery'), 'BakeryLead and Baker, already in Bakery.');
+ assert.equal(m.keepOwnBotsLine(['BakeryLead', 'Baker', 'Oven'], 'Bakery'), 'BakeryLead, Baker and Oven, already in Bakery.');
+ assert.equal(m.keepOwnBotsLine(['A', 'B', 'C', 'D', 'E'], 'Bakery'), 'A, B and 3 more, already in Bakery.');
+});
+
test('dismiss is kept per space and clears the stored choice', () => {
localStorage.clear();
m.storeChoice('s1', 'grok');
@@ -336,6 +364,24 @@ test('card: already signed in → hero D2, steps 1–2 done with Change, step 3
r2.done();
});
+test('0.9.5: outside the main space step 3 never offers the main space\'s starter bots', async () => {
+ localStorage.clear();
+ const bots = [{ id: 'l', name: 'BakeryLead' }, { id: 'b', name: 'Baker' }];
+ const r = mount(h(m.GetStarted, { space: 'bakery', spaceName: 'Bakery', mainSpace: false, bots, engines: [ready('claude')], reloadEngines() {}, onDismissed() {}, hostOverride: null }));
+ await settle();
+ assert.equal(r.host.querySelector('[data-get-started]').getAttribute('data-open-step'), '3');
+ const text = r.host.textContent;
+ for (const name of ['Architect', 'TechLead', 'DevOps', 'Keep the starter bots']) assert.ok(!text.includes(name), `no "${name}" in Bakery`);
+ const keep = r.host.querySelector('[data-keep-starter]');
+ assert.equal(keep.textContent, 'Keep the bots you haveBakeryLead and Baker, already in Bakery.Use ›');
+ r.done();
+ // The main space keeps today's tile.
+ const r2 = mountStep3('main-keep', { mainSpace: true });
+ await settle();
+ assert.match(r2.host.querySelector('[data-keep-starter]').textContent, /^Keep the starter botsArchitect, TechLead and DevOps, in #general\./);
+ r2.done();
+});
+
// ------------------------------------------------------------------ step 3: Bring your bots (0.7.7)
/** Fake import routes: prompts, a one-bot preview, apply. Records each call. */