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.

29v new-person-no-moved-notice: no "moved" pointer for a brand-new person; (default) on Ask only when risky (#859)

Oleksandr Ivanchenko6342bbd50f69
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 8af4cf27..648750a0 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -14,7 +14,7 @@ import { useSettingsCover } from './settingsFocus';
import { WhatsNewHost } from './components/WhatsNewSheet';
import { GetStarted, GetStartedBanner } from './components/GetStarted';
import { focusPhoneApp } from './components/PhoneAppTip';
-import { focusDevSettings, markMovedSeen, movedPointerShows, movedSeen, ringDevSettings } from './firstScreen';
+import { focusDevSettings, markMovedSeen, movedPointerShows, movedSeen, recordMovedForNewPerson, ringDevSettings } from './firstScreen';
import { dismiss as dismissGetStarted, isDismissed as getStartedDismissed, showCard as showGetStarted, wasStarted as getStartedWasStarted, whatsNewEstablished as decideWhatsNewEstablished } from './gettingStarted';
import { useStartVersion } from './gettingStartedInstall';
import { SpaceTile } from './components/Spaces';
@@ -4810,6 +4810,11 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({
wroteHere,
getStartedShowing: getStartedEligible,
});
+ // 29v: a brand-new person never gets the "moved" pointer: record it as seen once they're known to be new
+ // (false, never null), the way What's new records its version, so it can't pin after their first message.
+ useEffect(() => {
+ if (recordMovedForNewPerson({ established: whatsNewEstablished, seen: movedHidden })) hideMoved();
+ }, [whatsNewEstablished, movedHidden]);
const readyBots = useMemo(() => kwants.map((k) => ({ id: k.id, name: k.name, role: k.avatar_sprite })), [kwants]);
return (
diff --git a/frontend/src/components/ApprovalsSetting.tsx b/frontend/src/components/ApprovalsSetting.tsx
index d4da6d42..8da45ff5 100644
--- a/frontend/src/components/ApprovalsSetting.tsx
+++ b/frontend/src/components/ApprovalsSetting.tsx
@@ -150,7 +150,7 @@ function refusedOff(err: unknown, passwords: PasswordStoreState): string | null
const radioCls = (on: boolean) =>
`flex items-start gap-2.5 p-2.5 rounded-lg border cursor-pointer transition-colors ${on ? 'border-sky-500/60 bg-sky-500/10' : 'border-zinc-800 hover:border-zinc-700'}`;
-/** Space settings: Ask (default) / Don't ask. Ask saves at once; Don't ask needs the confirm. */
+/** Space settings: Ask / Ask only when risky (default, what a new space starts on) / Don't ask. Ask and smart save at once; Don't ask needs the confirm. */
export const SpaceApprovalsSetting: React.FC<{
spaceId: string;
spaceName: string;
@@ -225,7 +225,7 @@ export const SpaceApprovalsSetting: React.FC<{
<span className="min-w-0">
<span className="block text-xs font-medium text-zinc-200">
{o.label}
- {o.value === 'ask' && <span className="ml-1 text-zinc-500 font-normal">(default)</span>}
+ {o.value === 'smart' && <span className="ml-1 text-zinc-500 font-normal">(default)</span>}
</span>
<span className="block text-[11px] text-zinc-500">{o.hint}</span>
</span>
diff --git a/frontend/src/firstScreen.ts b/frontend/src/firstScreen.ts
index 0d276e6a..7b5e158e 100644
--- a/frontend/src/firstScreen.ts
+++ b/frontend/src/firstScreen.ts
@@ -69,6 +69,14 @@ export function markMovedSeen(): void {
*/
export const movedPointerShows = (opts: { established: boolean | null; seen: boolean }): boolean => opts.established === true && !opts.seen;
+/**
+ * 29v: a brand-new person (`established === false`, decided) has never seen the old place, so the pointer is
+ * recorded as seen, the way What's new records its version for them ('record'). Otherwise `established`
+ * turns true at their first message and the pointer would pin to their sidebar. `null` (can't tell yet) waits;
+ * someone who used kwant before (true on load) is left to see it.
+ */
+export const recordMovedForNewPerson = (opts: { established: boolean | null; seen: boolean }): boolean => opts.established === false && !opts.seen;
+
// ------------------------------------------------------------------ E: the account card
/**
diff --git a/frontend/tests/approvalsOff.test.mjs b/frontend/tests/approvalsOff.test.mjs
index c879c16c..9314022b 100644
--- a/frontend/tests/approvalsOff.test.mjs
+++ b/frontend/tests/approvalsOff.test.mjs
@@ -116,11 +116,12 @@ test('errors are sentences: 403 (a bot token), 409 (archived), no endpoint, no n
// ---------------------------------------------------------------- the space control
-test('space control: Ask is the default and checked, Don\'t ask explains itself, no confirm yet', () => {
+test('space control: Ask is checked when the space asks, Don\'t ask explains itself, no confirm yet', () => {
const html = m.spaceSetting({});
const t = text(html);
assert.match(html, /role="radiogroup" aria-label="Approvals in Work"/);
- assert.match(t, /Ask before running commands \(default\)/);
+ assert.match(t, /Ask before running commands/);
+ assert.match(t, /Ask only when risky \(default\)/, '29v: the default is what a new space starts on (NEW_SPACE = SMART)');
assert.match(t, /Don't ask Bots act without asking, including sending, deleting, publishing and signing in\. Payments still ask you\./);
assert.doesNotMatch(html, /data-approvals-off-hint/, 'no standing hint while asking');
assert.match(html, /checked="" value="ask"/);
diff --git a/frontend/tests/approvalsSmart.test.mjs b/frontend/tests/approvalsSmart.test.mjs
index 56134060..6727fa1f 100644
--- a/frontend/tests/approvalsSmart.test.mjs
+++ b/frontend/tests/approvalsSmart.test.mjs
@@ -38,9 +38,12 @@ test('the space control offers "Ask only when risky" between Ask and Don\'t ask,
const values = [...html.matchAll(/value="(ask|smart|off)"/g)].map((x) => x[1]);
assert.deepEqual(values, ['ask', 'smart', 'off']);
const t = text(html);
- assert.match(t, /Ask only when risky Everyday work in the bot's own folder runs on its own\. A card asks you before it goes online, installs something new, publishes, touches anything outside its folder, or does anything that isn't clearly safe\./);
+ assert.match(t, /Ask only when risky (?:\(default\) )?Everyday work in the bot's own folder runs on its own\. A card asks you before it goes online, installs something new, publishes, touches anything outside its folder, or does anything that isn't clearly safe\./);
assert.match(t, /It isn't a locked box: a program the bot runs inside its folder can still do anything you can\./, 'the honest limit of "smart" stays said');
- assert.match(t, /Ask before running commands \(default\)/, 'Ask stays the default');
+ // 29v: a new space starts on smart (src/db/approval_modes.rs NEW_SPACE = SMART), so the mark sits there.
+ assert.match(t, /Ask only when risky \(default\)/, '"(default)" sits on Ask only when risky, what a new space starts on');
+ assert.doesNotMatch(t, /Ask before running commands \(default\)/, 'not on Ask');
+ assert.equal((t.match(/\(default\)/g) || []).length, 1, 'one default');
});
test('smart is checked when the space is smart, with no "Approvals off" marker', () => {
diff --git a/frontend/tests/firstScreen.test.mjs b/frontend/tests/firstScreen.test.mjs
index 14f18d4e..cfabbb31 100644
--- a/frontend/tests/firstScreen.test.mjs
+++ b/frontend/tests/firstScreen.test.mjs
@@ -149,6 +149,46 @@ test('A: Open goes to Space settings › General and rings the Dev mode card onc
assert.match(app, /<GetStarted[\s\S]*?onDismissed=\{hideMoved\}/, 'finishing Get started (someone new) hides the pointer for good');
});
+// 29v (Mira's UX pass 0.9.26, fix #3): a brand-new person gets the pointer recorded as seen, the way What's new
+// records its version for them, so it never pins to their sidebar after their first message.
+test('29v: a brand-new person (established false) records the pointer; true still shows it; null waits', () => {
+ assert.equal(typeof m.recordMovedForNewPerson, 'function', 'firstScreen exports recordMovedForNewPerson');
+ assert.equal(m.recordMovedForNewPerson({ established: false, seen: false }), true, 'brand new, decided: record it');
+ assert.equal(m.recordMovedForNewPerson({ established: null, seen: false }), false, 'still loading: do nothing');
+ assert.equal(m.recordMovedForNewPerson({ established: true, seen: false }), false, 'used kwant before: leave it to show');
+ assert.equal(m.recordMovedForNewPerson({ established: false, seen: true }), false, 'already recorded: nothing to do');
+});
+
+test('29v: brand new on load, then the first message: the pointer never shows', () => {
+ localStorage.clear();
+ // The same steps SpaceApp runs: load (null), decided brand new (false), first message written (true).
+ let seen = m.movedSeen();
+ for (const established of [null, false, true]) {
+ if (m.recordMovedForNewPerson({ established, seen })) {
+ m.markMovedSeen();
+ seen = true;
+ }
+ assert.equal(m.movedPointerShows({ established, seen }), false, `no pointer at established=${established}`);
+ }
+ assert.equal(localStorage.getItem('kwnt:moved-space-controls'), '1', 'the key is recorded');
+ // Reload after that first message: established is true straight away, the key keeps it hidden.
+ assert.equal(m.movedPointerShows({ established: true, seen: m.movedSeen() }), false);
+ localStorage.clear();
+ // Someone with history and no key: true on load, nothing recorded, the pointer shows.
+ seen = m.movedSeen();
+ assert.equal(m.recordMovedForNewPerson({ established: true, seen }), false);
+ assert.equal(m.movedPointerShows({ established: true, seen }), true, 'someone who used kwant before still sees it');
+ assert.equal(localStorage.getItem('kwnt:moved-space-controls'), null);
+});
+
+test('29v: SpaceApp records it in an effect placed after whatsNewEstablished is declared', () => {
+ const app = src('App.tsx');
+ const decl = app.indexOf('const whatsNewEstablished = decideWhatsNewEstablished(');
+ const eff = app.search(/useEffect\(\(\) => \{\s*if \(recordMovedForNewPerson\(\{ established: whatsNewEstablished, seen: movedHidden \}\)\) hideMoved\(\);\s*\}/);
+ assert.ok(decl > 0, 'whatsNewEstablished is declared');
+ assert.ok(eff > decl, 'the effect sits after the declaration, so it never reads it before it exists');
+});
+
// ------------------------------------------------------------------ C: #general's three asks
test('C: #general with the Helpers team shows "What do you want done?" and its three role asks, no filler', () => {