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.

19f phone-reply-row: tidy reply buttons on a phone, no empty gap, no broken "!" on Ask chips (#680)

Oleksandr Ivanchenko7ef0385f8fbf
diff --git a/frontend/src/components/AvatarMood.tsx b/frontend/src/components/AvatarMood.tsx
index 5ce02a82..78f5fbba 100644
--- a/frontend/src/components/AvatarMood.tsx
+++ b/frontend/src/components/AvatarMood.tsx
@@ -105,3 +105,20 @@ export const AvatarMood: React.FC<AvatarMoodProps> = ({ mood, size }) => {
</svg>
);
};
+
+/** 19f: the mood mark an avatar of this size gets. The 7×7 plate was drawn for 24–28 px avatars; below 20 px it
+ * covers the face (the Ask chips are 14 px), so there "needs you" is a 6 px amber dot and other moods show nothing.
+ * The words stay on the avatar's title and aria text. 20 px and up is the plate, unchanged. */
+export const AvatarMoodMark: React.FC<AvatarMoodProps> = ({ mood, size }) => {
+ if (size >= 20) return <AvatarMood mood={mood} size={size} />;
+ if (mood !== 'needs_you') return null;
+ return (
+ <span
+ className="kw-mood-small pointer-events-none absolute rounded-full"
+ style={{ top: -1, right: -1, width: 6, height: 6, background: MOOD_GLYPHS.needs_you.color, boxShadow: '0 0 0 1.5px var(--kw-avatar-cut, #27272a)' }}
+ aria-hidden="true"
+ data-mood={mood}
+ data-mood-dot=""
+ />
+ );
+};
diff --git a/frontend/src/components/ChatView.tsx b/frontend/src/components/ChatView.tsx
index 7f5fd50a..6e008b68 100644
--- a/frontend/src/components/ChatView.tsx
+++ b/frontend/src/components/ChatView.tsx
@@ -1972,13 +1972,19 @@ export const ChatView: React.FC<ChatViewProps> = ({
{/* Action row (reply-chrome part 3): Reply, the thumbs, then Copy as a quiet icon; smart-result actions portal in after Copy */}
{/* 0.9.8: on a phone the browsed chip gets its own 44 px row above the action row (it would wrap) */}
- {!isUser && !filesOnly && phone && savedActivity && (
- <div className="mt-1 flex items-center min-h-[44px] max-w-full min-w-0">
+ {/* 19f: only when the reply opened pages; BrowsedChip draws nothing otherwise, and the 44 px row was an empty gap */}
+ {!isUser && !filesOnly && phone && savedActivity && pagesOfReply(savedActivity.steps).length > 0 && (
+ <div className="mt-1 flex items-center min-h-[44px] max-w-full min-w-0" data-phone-browsed-row="">
<BrowsedChip botName={displayName} steps={savedActivity.steps} live={false} phone onOpen={() => openBrowserFor(msg.id)} />
</div>
)}
{!isUser && !filesOnly && (
- <div className="mt-2 flex flex-wrap items-center gap-0 sm:gap-1 text-zinc-400 text-xs max-w-full min-w-0">
+ <>
+ {/* 19f: on a phone the ghost icons keep one row (no wrap) and the smart-result actions get their own row below */}
+ <div
+ className={`mt-2 flex ${phone ? 'flex-nowrap' : 'flex-wrap'} items-center gap-0 sm:gap-1 text-zinc-400 text-xs max-w-full min-w-0`}
+ data-reply-actions={phone ? 'phone' : 'desktop'}
+ >
{!phone && savedActivity && (
<BrowsedChip botName={displayName} steps={savedActivity.steps} live={false} onOpen={() => openBrowserFor(msg.id)} />
)}
@@ -1997,8 +2003,14 @@ export const ChatView: React.FC<ChatViewProps> = ({
)}
<CopyGhost copied={copiedId === msg.id} tipId={`copy-tip-${msg.id}`} onCopy={() => handleCopy(text, msg.id)} />
{continueMenu(msg, `${displayName}'s reply`, 'start')}
- {msg.results != null && <SmartActionsSlot messageId={msg.id} />}
+ {!phone && msg.results != null && <SmartActionsSlot messageId={msg.id} />}
</div>
+ {phone && msg.results != null && (
+ <div className="mt-1 flex flex-wrap items-center gap-2 text-zinc-400 text-xs max-w-full min-w-0 empty:hidden" data-smart-row="">
+ <SmartActionsSlot messageId={msg.id} />
+ </div>
+ )}
+ </>
)}
{continueError?.id === msg.id && <MessageMoreError text={continueError.text} align={isUser ? 'end' : 'start'} />}
</div>
diff --git a/frontend/src/components/ModernAvatar.tsx b/frontend/src/components/ModernAvatar.tsx
index a2ba2cbe..be4d2e27 100644
--- a/frontend/src/components/ModernAvatar.tsx
+++ b/frontend/src/components/ModernAvatar.tsx
@@ -4,7 +4,7 @@ import { isKwantWorking, lastRunOf, liveRunOf, subscribeKwant } from '../kwantAc
import { badgeUsageFor, modelBadgeFor, modelBadgeSize, type ModelBadge } from '../engines';
import { badgeBotOf, badgeEngines, badgeProfiles, subscribeBadgeData } from '../modelBadgeData';
import { EngineMark } from './EngineMark';
-import { AvatarMood, useKwantMood, useKwantNotices } from './AvatarMood';
+import { AvatarMoodMark, useKwantMood, useKwantNotices } from './AvatarMood';
import { moodLabel, restingUntilOf } from '../kwantMood';
import { STATUS_DOT, STATUS_PRIORITY, statusText, type BotStatus } from '../botStatus';
import { avatarStyleFor, botLooksRev, subscribeBotLooks } from '../botLooks';
@@ -520,7 +520,7 @@ export const ModernAvatar: React.FC<ModernAvatarProps> = ({
</g>
</g>
</svg>
- <AvatarMood mood={mood} size={size} />
+ <AvatarMoodMark mood={mood} size={size} />
{hat && <HardHat />}
{modelBadge && kwantId && modelBadgeSize(size) !== null && <AvatarModelBadge kwantId={kwantId} size={size} />}
{shown && (
diff --git a/frontend/src/styles/modern.css b/frontend/src/styles/modern.css
index 674e799a..c60a5a12 100644
--- a/frontend/src/styles/modern.css
+++ b/frontend/src/styles/modern.css
@@ -165,6 +165,23 @@
in on them. Only on touch screens below 768px, so desktop and narrow mouse windows keep the
compact look. Toggle switches, checkboxes and links inside text keep their size; anything else
that must stay small can opt out with data-compact. */
+/* 19f: a phone reply's smart-result row (Show as text, Copy data, From this reply) sits under the ghost icons.
+ It hides when no block put anything in it, and "From this reply" is quiet text there, not a chip that looks
+ like a button it isn't. Desktop keeps evidenceClass as is. */
+[data-smart-row]:has(> [data-smart-actions]:empty) {
+ display: none;
+}
+@media (max-width: 767px) and (pointer: coarse) {
+ [data-smart-row] [data-evidence] {
+ border-color: transparent;
+ background: transparent;
+ padding-inline: 4px;
+ min-height: 28px; /* when it wraps under Copy data it reads as a caption line, not a 36 px chip row */
+ font-weight: 400;
+ color: rgb(161 161 170); /* zinc-400 */
+ }
+}
+
@media (max-width: 767px) and (pointer: coarse) {
:is(button, [role='button'], [role='tab'], [role='menuitem'], [role='option'], select, summary):not([role='switch'], [data-compact], .prose *) {
min-height: 44px;
diff --git a/frontend/tests/phoneReplyRow.test.mjs b/frontend/tests/phoneReplyRow.test.mjs
new file mode 100644
index 00000000..e3872351
--- /dev/null
+++ b/frontend/tests/phoneReplyRow.test.mjs
@@ -0,0 +1,65 @@
+// 19f phone-reply-row: on a phone a reply's buttons sit in two tidy rows, no empty browsed row, and the 14 px
+// Ask-chip avatars get a 6 px dot instead of the mood plate.
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { readFileSync } from 'node:fs';
+import { loadBundled } from './bundle.mjs';
+
+const m = await loadBundled(`
+ import React from 'react';
+ import { renderToStaticMarkup } from 'react-dom/server.browser';
+ import { AvatarMoodMark } from './src/components/AvatarMood';
+ export { evidenceClass } from './src/components/results/SmartActions';
+ export { pagesOfReply } from './src/browserPages';
+ export const mark = (mood, size) => renderToStaticMarkup(React.createElement(AvatarMoodMark, { mood, size }));
+`);
+const read = (p) => readFileSync(new URL(`../${p}`, import.meta.url), 'utf8');
+const chat = read('src/components/ChatView.tsx');
+const css = read('src/styles/modern.css');
+
+test('the phone browsed row renders only when the reply opened pages', () => {
+ assert.match(chat, /phone && savedActivity && pagesOfReply\(savedActivity\.steps\)\.length > 0 && \(\s*<div className="mt-1 flex items-center min-h-\[44px\][^"]*" data-phone-browsed-row/);
+ assert.equal(m.pagesOfReply([]).length, 0);
+ assert.equal(m.pagesOfReply(null).length, 0);
+});
+
+test('on a phone the ghost row does not wrap and the smart actions get their own row after it', () => {
+ const at = chat.indexOf('data-reply-actions=');
+ assert.ok(at > 0);
+ const row = chat.slice(at - 300, at + 60);
+ assert.match(row, /\$\{phone \? 'flex-nowrap' : 'flex-wrap'\}/);
+ const tail = chat.slice(at, at + 2500);
+ assert.match(tail, /\{!phone && msg\.results != null && <SmartActionsSlot messageId=\{msg\.id\} \/>\}\s*<\/div>/);
+ assert.match(tail, /\{phone && msg\.results != null && \(\s*<div className="mt-1 flex flex-wrap items-center gap-2[^"]*" data-smart-row="">\s*<SmartActionsSlot messageId=\{msg\.id\} \/>/);
+ assert.ok(tail.indexOf('data-smart-row') > tail.indexOf('<CopyGhost'), 'the smart row comes after the ghost row');
+ assert.match(css, /\[data-smart-row\]:has\(> \[data-smart-actions\]:empty\) \{\s*display: none;/);
+});
+
+test('on a phone "From this reply" is quiet text; desktop evidenceClass is unchanged', () => {
+ const phoneRule = css.match(/@media \(max-width: 767px\) and \(pointer: coarse\) \{\s*\[data-smart-row\] \[data-evidence\] \{([^}]*)\}/);
+ assert.ok(phoneRule, 'phone-only rule on the evidence span');
+ assert.match(phoneRule[1], /border-color: transparent/);
+ assert.match(phoneRule[1], /background: transparent/);
+ assert.equal(
+ m.evidenceClass,
+ 'inline-flex items-center gap-1.5 min-h-9 min-w-0 max-w-full px-3 rounded-lg border border-hairline bg-white/[0.03] text-xs font-medium text-zinc-300 [&>svg]:text-muted',
+ );
+});
+
+test('a 14 px avatar that needs you gets the 6 px dot, not the 7×7 plate; 24 px keeps the plate', () => {
+ const small = m.mark('needs_you', 14);
+ assert.match(small, /data-mood-dot/);
+ assert.match(small, /width:6px;height:6px/);
+ assert.match(small, /#ffb020/);
+ // not .kw-mood-dot: that class is the thinking dots' 0.25–1 opacity pulse
+ assert.doesNotMatch(small, /class="kw-mood-dot\b/);
+ assert.doesNotMatch(small, /viewBox="0 0 7 7"/);
+ assert.equal(m.mark('thinking', 14), '');
+ assert.equal(m.mark('failed', 19), '');
+ const big = m.mark('needs_you', 24);
+ assert.match(big, /viewBox="0 0 7 7"/);
+ assert.match(big, /width="14" height="14"/);
+ assert.doesNotMatch(big, /data-mood-dot/);
+ assert.match(m.mark('needs_you', 20), /viewBox="0 0 7 7"/);
+ assert.match(read('src/components/ModernAvatar.tsx'), /<AvatarMoodMark mood=\{mood\} size=\{size\} \/>/);
+});
diff --git a/frontend/tests/smartResults.test.mjs b/frontend/tests/smartResults.test.mjs
index 73d31d02..73cb0520 100644
--- a/frontend/tests/smartResults.test.mjs
+++ b/frontend/tests/smartResults.test.mjs
@@ -301,7 +301,9 @@ test('no setting: ChatView always passes results and adds the action-row spot wh
const { readFile } = await import('node:fs/promises');
const read = (f) => readFile(new URL(`../src/${f}`, import.meta.url), 'utf8');
const chat = await read('components/ChatView.tsx');
- assert.match(chat, /\{msg\.results != null && <SmartActionsSlot messageId=\{msg\.id\} \/>\}/);
+ // 19f: desktop keeps the slot inline in the action row; a phone gives it its own row under the ghost icons
+ assert.match(chat, /\{!phone && msg\.results != null && <SmartActionsSlot messageId=\{msg\.id\} \/>\}/);
+ assert.match(chat, /\{phone && msg\.results != null && \(\s*<div[^>]*data-smart-row="">\s*<SmartActionsSlot messageId=\{msg\.id\} \/>/);
assert.match(chat, /results=\{msg\.results\} messageId=\{msg\.id\}/);
for (const f of ['components/ChatView.tsx', 'components/SettingsModal.tsx', 'smartResults.ts', 'components/MarkdownRenderer.tsx']) assert.doesNotMatch(await read(f), /smart_results|SmartResultsOn|smart-results-label/, f);
});