Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

feat: switch Fast mode with /fast instead of a composer button

leepokaiaeb82ab3ae68
diff --git a/apps/desktop/src/renderer/views/thread/Composer.tsx b/apps/desktop/src/renderer/views/thread/Composer.tsx
index af16e30e..32fb42de 100644
--- a/apps/desktop/src/renderer/views/thread/Composer.tsx
+++ b/apps/desktop/src/renderer/views/thread/Composer.tsx
@@ -1,6 +1,6 @@
import { useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, type ReactNode } from 'react'
import { isBelow } from '@shared/compat'
-import { fastModeShown, fastModeState, fastModeTitle } from '@shared/fast-mode'
+import { fastCommandOffered, fastModeState, fastModeTitle, isFastCommand } from '@shared/fast-mode'
import { isGroup, isWorkingIn, type Bot } from '@shared/models'
import { BotAvatar } from '../../components/Avatar'
import { Icon } from '../../components/Icon'
@@ -18,7 +18,7 @@ type Trailing = 'interrupt' | 'stop' | 'call' | 'send'
/**
* The message box under a chat or a thread: send, or stop while the bot (or the group) is
- * working there. In a group, typing `@` suggests its bots; with one bot, a leading `/` suggests its skills.
+ * working there. In a group, typing `@` suggests its bots; with one bot, a leading `/` offers Fast mode and its skills.
*/
export function Composer({ botId, thread = null, onCall, onInterrupt }: {
botId: string
@@ -104,8 +104,9 @@ function DestinationComposer({ botId, thread, onCall, onInterrupt }: {
// Not in a group: each member has its own skills.
const skillsShown = !!bot && !isGroup(bot) && !isBelow(store.hello?.version ?? '', SKILLS_HOST)
- const typedSkill = skillsShown ? skillQuery(draft) : null
- const skills = typedSkill === null || !bot ? [] : matchingSkills(plugins.installedSkills, bot.skills, typedSkill)
+ const slash = skillQuery(draft)
+ const skills = !skillsShown || slash === null || !bot ? [] : matchingSkills(plugins.installedSkills, bot.skills, slash)
+ const fastOffered = slash !== null && fastCommandOffered(bot, slash)
const pickSkill = (id: string) => {
setDraft(`/${id} `)
@@ -125,7 +126,15 @@ function DestinationComposer({ botId, thread, onCall, onInterrupt }: {
setFiles((list) => [...list, ...accepted])
}
+ const toggleFast = () => {
+ if (!bot) return
+ store.setFastMode(bot, !bot.fastMode)
+ setDraft('')
+ field.current?.focus()
+ }
+
const submit = () => {
+ if (!files.length && isFastCommand(bot, draft)) return toggleFast()
if (!canSend) return
store.send(draft, botId, thread, files)
setDraft('')
@@ -146,7 +155,7 @@ function DestinationComposer({ botId, thread, onCall, onInterrupt }: {
return (
<div style={{ display: 'flex', flexDirection: 'column' }}>
- <ComposerReveal open={suggestions.length > 0 || skills.length > 0}>
+ <ComposerReveal open={suggestions.length > 0 || skills.length > 0 || fastOffered}>
<div className="mentions">
{suggestions.map((m) => (
<button key={m.id} className="press mention" onClick={() => mention(m)}>
@@ -154,6 +163,15 @@ function DestinationComposer({ botId, thread, onCall, onInterrupt }: {
<span style={{ ...font('subheadline'), color: 'var(--text)' }}>{m.name}</span>
</button>
))}
+ {fastOffered && bot ? (
+ <button className="press mention" title={fastModeTitle(bot)} aria-label={fastModeTitle(bot)} aria-pressed={bot.fastMode} onClick={toggleFast}>
+ <Icon name="bolt" size={12} color="var(--secondary)" />
+ <span style={{ ...font('subheadline'), color: 'var(--text)' }}>Fast mode</span>
+ <span style={{ ...font('subheadline'), color: fastModeState(bot) === 'refused' ? 'var(--warning)' : 'var(--secondary)' }}>
+ {{ on: 'On', off: 'Off', refused: 'Refused' }[fastModeState(bot)]}
+ </span>
+ </button>
+ ) : null}
{skills.map((s) => (
<button key={s.id} className="press mention" title={s.description || s.name} onClick={() => pickSkill(s.id)}>
<Icon name="book.pages" size={12} color="var(--secondary)" />
@@ -188,17 +206,6 @@ function DestinationComposer({ botId, thread, onCall, onInterrupt }: {
<Icon name="plus" size={13} weight="medium" color="var(--text)" />
</button>
) : null}
- {bot && fastModeShown(bot) ? (
- <button
- className={`press composer-add composer-fast fade-in ${fastModeState(bot)}`}
- aria-label={fastModeTitle(bot)}
- aria-pressed={bot.fastMode}
- title={fastModeTitle(bot)}
- onClick={() => store.setFastMode(bot, !bot.fastMode)}
- >
- <Icon name="bolt" size={12} weight="semibold" />
- </button>
- ) : null}
<div className="composer-field">
<div ref={measure} className="composer-measure" aria-hidden="true">{draft + '\u200b'}</div>
<textarea
diff --git a/apps/desktop/src/renderer/views/thread/composer.css b/apps/desktop/src/renderer/views/thread/composer.css
index 23de49bd..34ed8a1a 100644
--- a/apps/desktop/src/renderer/views/thread/composer.css
+++ b/apps/desktop/src/renderer/views/thread/composer.css
@@ -10,17 +10,6 @@
flex: none;
margin-bottom: calc(max(0px, (round(up, calc(var(--conversation) * 1.25), 1px) + 10px - 25px) / 2));
}
-/* Fast mode: filled while on, a warning tint while the agent refuses it. */
-.composer-fast {
- color: var(--secondary);
- transition: background var(--fade), color var(--fade), border-color var(--fade);
-}
-.composer-fast.on {
- background: var(--accent-fill);
- border-color: transparent;
- color: var(--on-accent);
-}
-.composer-fast.refused { color: var(--warning); }
.composer-surface {
flex: 1;
min-width: 0;
diff --git a/apps/desktop/src/renderer/views/thread/skill-command.ts b/apps/desktop/src/renderer/views/thread/skill-command.ts
index 55215655..e19e1ccc 100644
--- a/apps/desktop/src/renderer/views/thread/skill-command.ts
+++ b/apps/desktop/src/renderer/views/thread/skill-command.ts
@@ -1,4 +1,5 @@
-// `/skill` in the composer: while the draft is just `/partial`, the bot's skills are offered.
+// `/skill` in the composer: while the draft is just `/partial`, the bot's skills are offered
+// (after Fast mode's `/fast`, `@shared/fast-mode`).
// The host turns a message starting with `/<skill id>` into "read this skill first"
// (host/src/market/skills.rs `expand_command`).
diff --git a/apps/desktop/src/shared/fast-mode.ts b/apps/desktop/src/shared/fast-mode.ts
index d7ff8b3f..ca31688a 100644
--- a/apps/desktop/src/shared/fast-mode.ts
+++ b/apps/desktop/src/shared/fast-mode.ts
@@ -1,4 +1,4 @@
-// Fast mode in the chat (composer ⚡) and bot settings; the host reports what the agent
+// Fast mode in the chat (the composer's `/fast`) and bot settings; the host reports what the agent
// offers (`fastModeSupport`, `fastModeIssue`): docs/features/marketplace.md, "Fast mode".
import type { Bot } from './models'
@@ -21,7 +21,20 @@ export function fastModeRefusal(bot: Bot): string | null {
return `The agent turned it off: ${bot.fastModeIssue ?? 'not available'}. Switch it off and on to try again.`
}
-/** The composer button's tooltip and accessibility label. */
+/** `/fast` in the composer turns Fast mode on or off instead of going to the agent. */
+export const FAST_COMMAND = '/fast'
+
+/** The `/` menu offers Fast mode while `query` (what follows the `/`) could still name it. */
+export function fastCommandOffered(bot: Bot | null, query: string): boolean {
+ return fastModeShown(bot) && 'fast mode'.includes(query.toLowerCase())
+}
+
+/** A draft that is just `/fast`: sending it switches Fast mode. */
+export function isFastCommand(bot: Bot | null, draft: string): boolean {
+ return fastModeShown(bot) && draft.trim() === FAST_COMMAND
+}
+
+/** The `/` menu entry's tooltip and accessibility label. */
export function fastModeTitle(bot: Bot): string {
switch (fastModeState(bot)) {
case 'off':
diff --git a/apps/desktop/src/shared/models.test.ts b/apps/desktop/src/shared/models.test.ts
index a64bfe82..872dc05e 100644
--- a/apps/desktop/src/shared/models.test.ts
+++ b/apps/desktop/src/shared/models.test.ts
@@ -22,3 +22,15 @@ test('the composer offers Fast mode once the agent does, and while it is on', as
assert.equal(fastModeState(refused), 'refused')
assert.match(fastModeTitle(refused), /requires extra usage/)
})
+
+test('/fast is offered while typed and switches Fast mode instead of sending', async () => {
+ const { fastCommandOffered, isFastCommand } = await import('./fast-mode.ts')
+ const offered = normalizeBot({ id: 'b', fastModeSupport: 'offered' })
+ assert.equal(fastCommandOffered(offered, ''), true)
+ assert.equal(fastCommandOffered(offered, 'fa'), true)
+ assert.equal(fastCommandOffered(offered, 'pdf'), false)
+ assert.equal(fastCommandOffered(normalizeBot({ id: 'b' }), ''), false)
+ assert.equal(isFastCommand(offered, '/fast '), true)
+ assert.equal(isFastCommand(offered, '/fast please'), false)
+ assert.equal(isFastCommand(normalizeBot({ id: 'b' }), '/fast'), false, 'without Fast mode it reaches the agent')
+})
diff --git a/apps/ios/Kit/Sources/CodyncKit/Models/Bot+FastMode.swift b/apps/ios/Kit/Sources/CodyncKit/Models/Bot+FastMode.swift
index 81560acf..3ed74d3a 100644
--- a/apps/ios/Kit/Sources/CodyncKit/Models/Bot+FastMode.swift
+++ b/apps/ios/Kit/Sources/CodyncKit/Models/Bot+FastMode.swift
@@ -1,6 +1,6 @@
import Foundation
-/// Fast mode in the chat (composer) and bot settings; the host reports what the agent offers
+/// Fast mode in the chat (the composer's `/fast`) and bot settings; the host reports what the agent offers
/// (`fastModeSupport`, `fastModeIssue`): docs/features/marketplace.md, "Fast mode".
public extension Bot {
enum FastModeState: Sendable { case on, off, refused }
@@ -20,4 +20,17 @@ public extension Bot {
guard fastModeState == .refused else { return nil }
return "The agent turned it off: \(fastModeIssue ?? "not available"). Switch it off and on to try again."
}
+
+ /// `/fast` in the composer turns Fast mode on or off instead of going to the agent.
+ static let fastCommand = "/fast"
+
+ /// The `/` menu offers Fast mode while `query` (what follows the `/`) could still name it.
+ func offersFastCommand(_ query: String) -> Bool {
+ fastModeShown && (query.isEmpty || "fast mode".localizedCaseInsensitiveContains(query))
+ }
+
+ /// A draft that is just `/fast`: sending it switches Fast mode.
+ func isFastCommand(_ draft: String) -> Bool {
+ fastModeShown && draft.trimmingCharacters(in: .whitespacesAndNewlines) == Self.fastCommand
+ }
}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
index f34ce162..b2912f50 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/Composer.swift
@@ -5,7 +5,7 @@ import UniformTypeIdentifiers
/// The message box under a chat or a thread: send, or stop while the bot (or the
/// group) is working there. In a group, typing `@` suggests its bots; with one bot, a
-/// leading `/` suggests its skills.
+/// leading `/` offers Fast mode and its skills.
struct Composer: View {
let botId: String
/// Replies go to the thread on this message.
@@ -69,11 +69,18 @@ struct Composer: View {
return SkillCommand.matches(model.installedSkills, enabled: bot.skills, query: query)
}
+ /// The bot whose Fast mode the `/` menu offers while the draft could still be `/fast`.
+ private var fastOffer: Bot? {
+ guard let bot, let query = SkillCommand.query(draft), bot.offersFastCommand(query) else { return nil }
+ return bot
+ }
+
var body: some View {
VStack(alignment: .leading, spacing: 6) {
- if !suggestions.isEmpty || !skillSuggestions.isEmpty {
+ if !suggestions.isEmpty || !skillSuggestions.isEmpty || fastOffer != nil {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 6) {
+ if let bot = fastOffer { fastChip(bot) }
ForEach(suggestions) { member in
SuggestionChip(title: member.name) {
CharacterAvatar(bot: member, size: 18, animated: false)
@@ -100,6 +107,25 @@ struct Composer: View {
}
.animation(Motion.layout, value: suggestions.map(\.id))
.animation(Motion.layout, value: skillSuggestions.map(\.id))
+ .animation(Motion.layout, value: fastOffer != nil)
+ }
+
+ /// `/fast`: Fast mode and whether it's on; tapping switches it.
+ private func fastChip(_ bot: Bot) -> some View {
+ let (value, tint): (String, Color) = switch bot.fastModeState {
+ case .on: ("On", Palette.secondary)
+ case .off: ("Off", Palette.secondary)
+ case .refused: ("Refused", Palette.warning)
+ }
+ let about = bot.fastModeRefusal ?? "Faster replies for more usage."
+ return SuggestionChip(title: "Fast mode", detail: (value, tint)) {
+ Image(systemName: "bolt").font(.caption).foregroundStyle(Palette.secondary)
+ } action: {
+ toggleFast(bot)
+ }
+ .accessibilityValue(value)
+ .accessibilityHint(about)
+ .help(about)
}
private var fieldPadding: CGFloat { 10 }
@@ -239,15 +265,9 @@ struct Composer: View {
if UIPasteboard.general.hasImages || UIPasteboard.general.hasURLs {
items.append(MenuItem("Paste", icon: "doc.on.clipboard") { pasteFiles() })
}
- if let bot, bot.fastModeShown {
- items.append(MenuItem("Fast mode", icon: "bolt", selected: bot.fastMode, divider: true) {
- model.setFastMode(bot, !bot.fastMode)
- })
- }
return items
} label: { addLabel }
- .accessibilityLabel(bot?.fastModeShown == true ? "Add files or Fast mode" : "Add files")
- .accessibilityValue(bot?.fastModeShown == true ? (bot?.fastMode == true ? "Fast mode on" : "Fast mode off") : "")
+ .accessibilityLabel("Add files")
}
private var addLabel: some View {
@@ -257,22 +277,6 @@ struct Composer: View {
.frame(width: fieldHeight, height: fieldHeight)
.glass(in: Circle())
.contentShape(Circle())
- .overlay(alignment: .topTrailing) { fastModeBadge }
- .animation(Motion.reduced(Motion.fade, reduceMotion), value: bot?.fastModeState)
- }
-
- /// Fast mode is on: a bolt on the + button, tinted while the agent refuses it.
- @ViewBuilder private var fastModeBadge: some View {
- if let bot, bot.fastModeShown, bot.fastMode {
- Image(systemName: "bolt.fill")
- .font(.system(size: 9, weight: .bold))
- .foregroundStyle(bot.fastModeState == .refused ? Palette.warning : Palette.background)
- .frame(width: 16, height: 16)
- .background(Circle().fill(bot.fastModeState == .refused ? Palette.secondary.opacity(0.25) : Palette.text))
- .offset(x: 3, y: -3)
- .transition(.opacity)
- .accessibilityHidden(true)
- }
}
private var fileChips: some View {
@@ -334,7 +338,14 @@ struct Composer: View {
focused = true
}
+ private func toggleFast(_ bot: Bot) {
+ model.setFastMode(bot, !bot.fastMode)
+ draft = ""
+ focused = true
+ }
+
private func submit() {
+ if files.isEmpty, let bot, bot.isFastCommand(draft) { return toggleFast(bot) }
guard canSend else { return }
withAnimation(Motion.reduced(Motion.conversation, reduceMotion)) {
guard model.sendComposerDraft(to: botId, thread: thread, files: files) else { return }
@@ -344,9 +355,11 @@ struct Composer: View {
}
}
-/// One suggestion above the box: a bot to @mention or a skill to start with.
+/// One suggestion above the box: a bot to @mention, Fast mode, or a skill to start with.
private struct SuggestionChip<Icon: View>: View {
let title: String
+ /// A value after the title, such as Fast mode's On / Off.
+ var detail: (text: String, tint: Color)?
@ViewBuilder let icon: Icon
let action: () -> Void
@@ -355,6 +368,7 @@ private struct SuggestionChip<Icon: View>: View {
HStack(spacing: 6) {
icon
Text(title).font(.subheadline).foregroundStyle(Palette.text)
+ if let detail { Text(detail.text).font(.subheadline).foregroundStyle(detail.tint) }
}
.padding(.horizontal, 10)
.padding(.vertical, 6)
diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.md
index ed9e0edf..b79a903b 100644
--- a/apps/ios/WhatsNew.md
+++ b/apps/ios/WhatsNew.md
@@ -5,12 +5,12 @@ listing what iPhone users notice. tools/asc-submit.py reads the released version
a version without one gets a generic "Bug fixes and improvements" line. Delete old sections.
-->
-## 2.17.0
+## 2.17.2
### zh-Hant
-- Claude Code 和 Codex 的 bot 可以開啟快速模式:回覆更快,用量也較多。在輸入框的 + 選單或 bot 設定裡切換,開啟時 + 按鈕上會出現閃電。帳號不能使用時,設定裡會說明原因。
+- 快速模式改成在輸入框輸入 /fast 開關:打 / 就會在選單最前面看到快速模式和它目前的狀態,點一下或送出 /fast 即可切換。
### en-US
-- Turn on Fast mode for Claude Code and Codex bots: faster replies for more usage. Switch it from the composer's + menu or the bot's settings; a bolt on the + button shows it's on. If your account can't use it, the settings say why.
+- Fast mode now lives in the composer's / menu: type / to see it first, with whether it's on, and tap it or send /fast to switch it.
diff --git a/docs/features/marketplace.md b/docs/features/marketplace.md
index df17fc59..555aceea 100644
--- a/docs/features/marketplace.md
+++ b/docs/features/marketplace.md
@@ -25,7 +25,7 @@ Skills follow the same rule: an installed or hand-written skill is turned on for
Clicking a skill (an Extensions row, an installed skill, or the info button beside a skill's switch in bot settings; in the terminal, ↵ on a skill, or `i` on the bot form's Skills field) opens its details: the description and its instructions, with Add while it isn't installed. `skillDetails {id}` (installed) or `{source}` (catalog) returns `{markdown}`: the `SKILL.md` body without its front matter, at most 256 KB. The host looks names up in the installed list or the catalog cache, never as a path; the catalog fetch already downloads every `SKILL.md`, so the bodies stay in that cache. An Extensions row opens its details, or does what its button does when it has none (connectors open their install sheet).
-Typing `/` at the start of a message to a bot (desktop, iPhone, terminal; not in a group, where each member has its own skills) lists that bot's skills; picking one fills in `/<skill id> `. The host sees a message starting with `/<id of a skill the bot has on>` and hands the agent `[Codync: the user picked the "<name>" skill for this message. Read <path> first and follow it.]` followed by the rest of the message; the chat keeps the text as typed. Any other `/command` reaches the agent unchanged, so its own commands keep working. Clients show the menu and load skill instructions only from hosts 2.14.1 and newer.
+Typing `/` at the start of a message to a bot (desktop, iPhone, terminal; not in a group, where each member has its own skills) lists that bot's skills, after the built-in `/fast` when the bot offers [Fast mode](#fast-mode); picking a skill fills in `/<skill id> `. The host sees a message starting with `/<id of a skill the bot has on>` and hands the agent `[Codync: the user picked the "<name>" skill for this message. Read <path> first and follow it.]` followed by the rest of the message; the chat keeps the text as typed. Any other `/command` reaches the agent unchanged, so its own commands keep working. Clients show the menu and load skill instructions only from hosts 2.14.1 and newer.
Registry-backed package connectors follow their upstream release. The host checks the Registry periodically after credentials are unlocked and checks again immediately before a package process starts. If a newer pinned npm, PyPI, OCI or NuGet reference is available, only that package/image argument is replaced; the running process is not interrupted, and the new version applies on its next launch. Network failures, missing packages and attempted downgrades leave the installed reference unchanged. Custom command connectors are never updated automatically.
@@ -77,7 +77,7 @@ The bot's runtime carries what the agent says (`fastModeSupport`, `fastModeIssue
Clients show Fast mode for an agent bot whose runtime says `offered` or `refused`, or while it's on (so it can be turned off); never for a group:
-- Composer: the desktop shows a ⚡ button next to +: filled while on, tinted with the warning color while refused (its tooltip gives the reason). The iPhone adds a Fast mode item to the + menu and a ⚡ badge on the + button while on. The terminal UI shows `⚡ fast` or `⚡ refused` in the chat header and toggles with `F`.
+- Composer: `/fast`, a client command rather than a button. Typing `/` (or a start of "fast mode") puts a Fast mode entry first in the `/` menu, with its state (On, Off, or Refused in the warning color, the reason in its tooltip / accessibility hint; the terminal shows it as the row's description). Picking it, or sending a message that is just `/fast`, switches Fast mode with `updateBot` and clears the box; nothing reaches the agent. Without Fast mode on offer, `/fast` is an ordinary message. The terminal UI also shows `⚡ fast` or `⚡ refused` in the chat header.
- Bot settings: a Fast mode switch row under Model when the agent's model list offers it (never for a custom command), when the bot's own sessions do, or while it's on. While refused, its detail gives the reason. The terminal UI form always lists the field and notes when the agent doesn't offer it.
## Secure connection setup
diff --git a/host/src/tui/app/input.rs b/host/src/tui/app/input.rs
index 5a9ca0ca..7413d17b 100644
--- a/host/src/tui/app/input.rs
+++ b/host/src/tui/app/input.rs
@@ -106,6 +106,9 @@ impl App {
if text.is_empty() && files.is_empty() {
return;
}
+ if files.is_empty() && self.fast_command(&text) {
+ return;
+ }
if let Some(m) = &self.mismatch {
// The draft stays; it sends once the update is done.
let why = mismatch_text(m, &self.host);
@@ -369,25 +372,11 @@ impl App {
self.call("updateBot", json!({"id": id, "pinned": pinned}), After::Nothing);
}
}
- KeyCode::Char('F') => self.toggle_fast_mode(),
KeyCode::Char('c') => self.copy_last(),
_ => {}
}
}
- fn toggle_fast_mode(&mut self) {
- let Some(b) = self.bot() else { return };
- if b.group {
- self.flash("A group has no agent of its own");
- } else if !b.fast_shown() {
- self.flash("This bot's agent doesn't offer Fast mode");
- } else {
- let (id, on) = (b.id.clone(), !b.fast_mode);
- self.call("updateBot", json!({"id": id, "fastMode": on}), After::Nothing);
- self.flash(if on { "Fast mode on" } else { "Fast mode off" });
- }
- }
-
// ---------- mouse ----------
pub fn on_mouse(&mut self, m: MouseEvent) {
diff --git a/host/src/tui/app/slash.rs b/host/src/tui/app/slash.rs
index de47fb8d..90033350 100644
--- a/host/src/tui/app/slash.rs
+++ b/host/src/tui/app/slash.rs
@@ -1,38 +1,60 @@
-//! The composer's `/` menu: the bot's skills, offered while the draft is just `/partial`.
+//! The composer's `/` menu: Fast mode and the bot's skills, offered while the draft is just `/partial`.
use crossterm::event::{KeyCode, KeyEvent};
use serde_json::json;
use super::{After, App, Editor};
-/// A skill the menu offers.
-pub struct SkillMatch {
+/// `/fast` switches the bot's Fast mode instead of going to the agent.
+const FAST: &str = "/fast";
+
+/// What the menu offers: Fast mode or one of the bot's skills.
+pub struct SlashMatch {
pub id: String,
pub name: String,
pub description: String,
}
impl App {
- /// The selected bot's skills whose id or name holds the `/partial` being typed (none in a group).
- pub fn skill_matches(&self) -> Vec<SkillMatch> {
+ /// Fast mode, then the selected bot's skills, whose id or name holds the `/partial` being
+ /// typed (none in a group).
+ pub fn slash_matches(&self) -> Vec<SlashMatch> {
let Some(bot) = self.bot().filter(|b| !b.group) else { return vec![] };
let draft = self.draft();
let Some((query, None)) = crate::market::slash_command(&draft.text) else { return vec![] };
let query = query.to_lowercase();
- self.plugins
- .1
- .iter()
- .filter_map(|s| {
- let id = s["id"].as_str()?;
- let name = s["name"].as_str().unwrap_or(id);
- let hit = id.contains(&query) || name.to_lowercase().contains(&query);
- (hit && bot.skills.iter().any(|on| on == id)).then(|| SkillMatch {
- id: id.to_owned(),
- name: name.to_owned(),
- description: s["description"].as_str().unwrap_or_default().to_owned(),
- })
+ let fast = (bot.fast_shown() && "fast mode".contains(&query)).then(|| SlashMatch {
+ id: FAST[1..].to_owned(),
+ name: "Fast mode".to_owned(),
+ description: match bot.fast_refusal() {
+ Some(why) => format!("Fast mode refused · {why}"),
+ None if bot.fast_mode => "Fast mode on".to_owned(),
+ None => "Fast mode off · faster replies, more usage".to_owned(),
+ },
+ });
+ let skills = self.plugins.1.iter().filter_map(|s| {
+ let id = s["id"].as_str()?;
+ let name = s["name"].as_str().unwrap_or(id);
+ let hit = id.contains(&query) || name.to_lowercase().contains(&query);
+ (hit && bot.skills.iter().any(|on| on == id)).then(|| SlashMatch {
+ id: id.to_owned(),
+ name: name.to_owned(),
+ description: s["description"].as_str().unwrap_or_default().to_owned(),
})
- .collect()
+ });
+ fast.into_iter().chain(skills).collect()
+ }
+
+ /// A draft that is just `/fast` switches Fast mode instead of being sent. Returns whether it did.
+ pub(super) fn fast_command(&mut self, text: &str) -> bool {
+ let Some(b) = self.bot().filter(|b| b.fast_shown() && text == FAST) else { return false };
+ let (id, on) = (b.id.clone(), !b.fast_mode);
+ self.call("updateBot", json!({"id": id, "fastMode": on}), After::Nothing);
+ self.flash(if on { "Fast mode on" } else { "Fast mode off" });
+ if let Some(key) = self.draft_key() {
+ self.drafts.remove(&key);
+ }
+ true
}
/// Tab, or Return before the name is complete, fills in the first match. Returns whether it did.
@@ -40,10 +62,10 @@ impl App {
if !k.modifiers.is_empty() || !matches!(k.code, KeyCode::Tab | KeyCode::Enter) {
return false;
}
- let matches = self.skill_matches();
+ let matches = self.slash_matches();
let Some(first) = matches.first() else { return false };
let typed = self.draft().text;
- // `/pdf` already names a skill: Return sends it.
+ // `/pdf` already names a skill (or `/fast` the command): Return sends it.
if k.code == KeyCode::Enter && matches.iter().any(|m| typed[1..] == m.id) {
return false;
}
@@ -77,7 +99,7 @@ mod tests {
json!({"id": "docx", "name": "docx"}),
json!({"id": "xlsx", "name": "xlsx"}),
];
- let ids = |app: &super::App| app.skill_matches().into_iter().map(|m| m.id).collect::<Vec<_>>();
+ let ids = |app: &super::App| app.slash_matches().into_iter().map(|m| m.id).collect::<Vec<_>>();
let key = |code| KeyEvent::new(code, KeyModifiers::NONE);
app.drafts.insert("b".into(), super::Editor::with("/"));
assert_eq!(ids(&app), ["pdf", "docx"], "only skills the bot has on");
@@ -90,4 +112,22 @@ mod tests {
assert!(!app.complete_skill(key(KeyCode::Enter)), "a full name sends");
assert!(app.complete_skill(key(KeyCode::Tab)));
}
+
+ #[tokio::test]
+ async fn fast_comes_first_and_switches_instead_of_sending() {
+ let mut app = test_app();
+ let bot = Bot::parse(&json!({"id": "b", "name": "Bot", "skills": ["fastlane"], "fastModeSupport": "offered"}))
+ .expect("a bot parses");
+ app.bots.insert("b".into(), bot);
+ app.selected = Some("b".into());
+ app.plugins.1 = vec![json!({"id": "fastlane", "name": "fastlane"})];
+ let ids = |app: &super::App| app.slash_matches().into_iter().map(|m| m.id).collect::<Vec<_>>();
+ app.drafts.insert("b".into(), super::Editor::with("/fa"));
+ assert_eq!(ids(&app), ["fast", "fastlane"]);
+ assert!(!app.fast_command("/fast please"), "only the bare command");
+ assert!(app.fast_command("/fast"));
+ assert_eq!(app.draft().text, "", "the draft clears");
+ app.bots.get_mut("b").expect("the bot").fast_support = "unsupported".into();
+ assert!(!app.fast_command("/fast"), "without Fast mode it reaches the agent");
+ }
}
diff --git a/host/src/tui/view/chat.rs b/host/src/tui/view/chat.rs
index 60ccd4cf..8faebf4a 100644
--- a/host/src/tui/view/chat.rs
+++ b/host/src/tui/view/chat.rs
@@ -197,10 +197,10 @@ pub(super) fn chat(buf: &mut Buffer, r: Rect, app: &mut App, narrow: bool) {
}
}
-/// The `/` menu over the bottom of the transcript: the bot's skills matching what's typed.
+/// The `/` menu over the bottom of the transcript: Fast mode and the bot's skills matching what's typed.
fn skill_menu(buf: &mut Buffer, body: Rect, app: &App) {
let t = theme();
- let matches = app.skill_matches();
+ let matches = app.slash_matches();
let n = u(matches.len().min(5)).min(body.height);
for (i, m) in matches.iter().take(usize::from(n)).enumerate() {
let y = body.bottom() - n + u(i);
diff --git a/host/src/tui/view/help.rs b/host/src/tui/view/help.rs
index 290379df..c8075ca1 100644
--- a/host/src/tui/view/help.rs
+++ b/host/src/tui/view/help.rs
@@ -44,11 +44,11 @@ const HELP: [(&str, &str, &str); 57] = [
("TYPE", "alt b / f", "word left / right"),
("TYPE", "^w ^u", "delete word / line"),
("TYPE", "@name", "group: ask just that bot"),
+ ("TYPE", "/fast", "Fast mode on / off"),
("BOTS", "n", "new bot"),
("BOTS", "m", "new group chat"),
("BOTS", "e", "edit bot or group"),
("BOTS", "p", "pin / unpin"),
- ("BOTS", "F", "Fast mode on / off"),
("BOTS", "J K", "move bot down / up"),
("BOTS", "S", "new session"),
("BOTS", "M", "memory"),