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.

29u: Get started opens at its top (#854)

Oleksandr Ivanchenko2cefc87f5f9d
diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsx
index 91143ac2..dcfe3a7e 100644
--- a/frontend/src/components/ChatView.tsx
+++ b/frontend/src/components/ChatView.tsx
@@ -948,7 +948,7 @@ export const ChatView: React.FC<ChatViewProps> = ({
const writing = useStreamWriting(stream) || (!streamProp && !!streamingTextProp);
const thinking = useStreamThinking(stream) || (!streamProp && !!streamingThinkingProp);
const lastScrollTopRef = useRef(0);
- // The empty chat's home opens at its top: on a phone a team home is taller than the screen, and its faces come first (13d).
+ // The empty chat's home and Get started open at their top: on a phone both are taller than the screen, and their heads come first (13d, 29u).
const homeShowingRef = useRef(false);
const pinToBottom = (el: HTMLDivElement) => {
el.scrollTop = homeShowingRef.current ? 0 : el.scrollHeight;
@@ -2086,11 +2086,14 @@ export const ChatView: React.FC<ChatViewProps> = ({
};
// The empty chat shows a home (a bot's own chat, #general, or a team's chat) instead of a bare pane and a row of chips
+ // Nothing in the chat yet and nothing on its way: no message, reply, queued turn, routing or waiting card.
+ const chatIsEmpty = messages.length === 0 && !isStreaming && !queued && !deciding && pendingApprovals.length === 0;
const showHome =
!!home &&
(home.kind === 'bot' || home.kind === 'general' || (home.kind === 'team' && !!home.team)) &&
- !welcome && messages.length === 0 && !isStreaming && !queued && !deciding && pendingApprovals.length === 0;
- homeShowingRef.current = showHome;
+ !welcome && chatIsEmpty;
+ // The home and Get started (the welcome) both open at their top (13d, 29u); once anything is in, the chat pins to the bottom.
+ homeShowingRef.current = showHome || (!!welcome && chatIsEmpty);
// first-screen E: nothing can run and Get started (the welcome) isn't on screen. The home shows it in place of its asks.
const accountCard = accountCardShows({ canRun, getStartedShowing: !!welcome });
// Who answers what's typed: the chat decides, an @mention overrides
diff --git a/frontend/tests/welcomeOpensAtTop.test.mjs b/frontend/tests/welcomeOpensAtTop.test.mjs
new file mode 100644
index 00000000..b60b3b82
--- /dev/null
+++ b/frontend/tests/welcomeOpensAtTop.test.mjs
@@ -0,0 +1,99 @@
+// 29u: a brand-new person's first screen (Get started, the welcome) opens at its top, like the empty chat's home (13d).
+// Once a message is in, or a reply is on its way, the chat pins to the bottom as before.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { JSDOM } from 'jsdom';
+import { loadBundled } from './bundle.mjs';
+
+const dom = new JSDOM('<!doctype html><html><body></body></html>', { url: 'http://localhost/', pretendToBeVisual: true });
+for (const k of ['window', 'document', 'navigator', 'HTMLElement', 'HTMLButtonElement', 'Element', 'Node', 'Event', 'KeyboardEvent', 'MutationObserver', 'requestAnimationFrame', 'cancelAnimationFrame', 'getComputedStyle', 'CSS']) {
+ if (!(k in dom.window)) continue;
+ Object.defineProperty(globalThis, k, { value: dom.window[k], configurable: true, writable: true });
+}
+const store = new Map();
+const ls = { getItem: (k) => (store.has(k) ? store.get(k) : null), setItem: (k, v) => void store.set(k, String(v)), removeItem: (k) => void store.delete(k) };
+Object.defineProperty(globalThis, 'localStorage', { value: ls, configurable: true, writable: true });
+Object.defineProperty(dom.window, 'localStorage', { value: ls, configurable: true });
+dom.window.matchMedia ??= () => ({ matches: false, addEventListener() {}, removeEventListener() {}, addListener() {}, removeListener() {} });
+globalThis.matchMedia = dom.window.matchMedia;
+globalThis.ResizeObserver ??= class { observe() {} unobserve() {} disconnect() {} };
+dom.window.ResizeObserver ??= globalThis.ResizeObserver;
+globalThis.IntersectionObserver ??= class { observe() {} unobserve() {} disconnect() {} };
+dom.window.HTMLElement.prototype.scrollIntoView ??= function () {};
+dom.window.HTMLElement.prototype.scrollTo ??= function () {};
+globalThis.fetch = dom.window.fetch = async () => new Response('{}', { status: 404, headers: { 'Content-Type': 'application/json' } });
+// jsdom lays nothing out: give every box the phone welcome's height (1342 of 619, Mira's pass) and keep what scrollTop is set to.
+const tops = new WeakMap();
+Object.defineProperty(dom.window.HTMLElement.prototype, 'scrollHeight', { configurable: true, get: () => 1342 });
+Object.defineProperty(dom.window.HTMLElement.prototype, 'clientHeight', { configurable: true, get: () => 619 });
+Object.defineProperty(dom.window.HTMLElement.prototype, 'scrollTop', { configurable: true, get() { return tops.get(this) ?? 0; }, set(v) { tops.set(this, v); } });
+
+const m = await loadBundled(`
+ import React from 'react';
+ import { flushSync } from 'react-dom';
+ import { createRoot } from 'react-dom/client';
+ import { ChatView } from './src/components/ChatView';
+ export const mount = (p) => {
+ const host = document.createElement('div');
+ document.body.appendChild(host);
+ const root = createRoot(host);
+ flushSync(() => root.render(React.createElement(ChatView, p)));
+ return { host, rerender: (q) => flushSync(() => root.render(React.createElement(ChatView, q))), unmount: () => (root.unmount(), host.remove()) };
+ };
+ export const welcome = React.createElement('div', { 'data-test-welcome': '' }, 'Claude is ready on this computer');
+`);
+const settle = () => new Promise((r) => setTimeout(r, 30));
+const ada = { id: 'a', name: 'Ada', title: 'Tech Lead', avatar_sprite: 'tech lead' };
+const props = (messages, extra = {}) => ({
+ title: '#general', subtitle: '', messages, streamingText: '', streamingThinking: '', isStreaming: false,
+ pendingApprovals: [], onSendMessage() {}, onResolveApproval() {}, onCancelDiscussion() {},
+ kwants: [ada], teams: [], suggestions: [], canRun: true, home: { kind: 'general' },
+ welcome: messages.length === 0 ? m.welcome : undefined, ...extra,
+});
+const log = (v) => v.host.querySelector('[role="log"]');
+const msg = { id: 'm1', sender_role: 'user', sender_id: 'u', text: '@helpers hi', created_at: '2026-11-19T06:00:00Z' };
+
+test('ChatView: Get started (the welcome) opens at its top, not pinned to the bottom', async () => {
+ const v = m.mount(props([]));
+ try {
+ await settle();
+ assert.ok(v.host.querySelector('[data-test-welcome]'), 'the welcome shows');
+ assert.equal(log(v).scrollTop, 0, 'the welcome opens at scrollTop 0');
+ } finally {
+ v.unmount();
+ }
+});
+
+test('ChatView: after the first message the chat pins to the bottom as before', async () => {
+ const v = m.mount(props([]));
+ try {
+ await settle();
+ v.rerender(props([msg]));
+ await settle();
+ assert.equal(v.host.querySelector('[data-test-welcome]'), null, 'the welcome is gone');
+ assert.equal(log(v).scrollTop, 1342, 'pinned to the bottom');
+ } finally {
+ v.unmount();
+ }
+});
+
+test('ChatView: the welcome while a reply is on its way still follows the bottom', async () => {
+ const v = m.mount(props([], { isStreaming: true, streamingText: 'Hello' }));
+ try {
+ await settle();
+ assert.equal(log(v).scrollTop, 1342, 'the reply stays in view');
+ } finally {
+ v.unmount();
+ }
+});
+
+test('ChatView: the empty home still opens at its top (13d)', async () => {
+ const v = m.mount(props([], { welcome: undefined }));
+ try {
+ await settle();
+ assert.ok(v.host.querySelector('[data-bot-home]'), 'the home shows');
+ assert.equal(log(v).scrollTop, 0);
+ } finally {
+ v.unmount();
+ }
+});