Skip to content

Commit 22fc98f

Browse files
authored
feat(commands): unified slash command dispatch + OCR utility commands (#164)
* feat(commands): add OCR utility commands, fix /translate default, defer pending-image submits, fix TipBar clipping Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com> * refactor(commands): route all slash commands through unified pre-flight gate Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com> * docs(claude): slim slash command flow note to point at docs/commands.md Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com> * feat(ux): clarify OCR-supported commands in capability warnings, tips, and docs Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com> * fix(ux): scope capability strip link to just the OCR-supported-commands phrase Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com> --------- Signed-off-by: Logan Nguyen <lg.131.dev@gmail.com>
1 parent aafe2fc commit 22fc98f

19 files changed

Lines changed: 2033 additions & 716 deletions

CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ The UI morphs between two states: a compact spotlight-style input bar → an exp
6060
- **`config/commands.ts`** — slash command registry: defines supported commands and the `SCREEN_CAPTURE_PLACEHOLDER` sentinel used to show a loading tile in chat while a `/screen` capture is in flight
6161
- **`components/CommandSuggestion.tsx`** — slash command autocomplete popover. Contains `iconForTrigger()`, a switch statement mapping trigger strings to inline SVG constants. **Every new slash command needs a dedicated case here.** Without it, the command falls through to the default, which returns `SCREEN_ICON` (the monitor icon). Steps: (1) add a hoisted `const FOO_ICON = (<svg .../>)` constant, (2) add `case '/foo': return FOO_ICON;` to `iconForTrigger()`.
6262

63+
### Slash commands
64+
65+
User-facing reference for all commands lives in `docs/commands.md`. **Any new slash command must go through the same unified dispatch flow as the existing ones in `src/App.tsx`** (shared pre-flight in `handleSubmit`, then a command-specific stage-2 handler). Do not add a bespoke submit path; extend the existing dispatch instead. This keeps gating, deferral, capability checks, and cancellation behavior consistent across every command.
66+
6367
### Backend (`src-tauri/src/`)
6468

6569
- **`lib.rs`** — app setup: loads `AppConfig` via `config::load`, converts window to NSPanel (fullscreen overlay), registers tray, spawns hotkey listener, intercepts close events (hides instead of quits)

docs/commands.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Commands that operate on text follow a consistent input priority:
1414

1515
This means you can highlight text anywhere on screen, summon Thuki with double-tap Control, type a command, and hit Enter without retyping the selected content.
1616

17+
## Image input on text-only models
18+
19+
`/extract`, `/tldr`, `/translate`, `/rewrite`, `/refine`, `/bullets`, `/todos`, and `/explain` read attached images locally via macOS Vision OCR, so they work even when the active model has no vision capability. Only plain submits and `/screen` alone require a vision model to read images. See [OCR-supported commands](./ocr-commands.md) for the full list and details.
20+
1721
## /search
1822

1923
Runs agentic web search and answers from live sources with citations.
@@ -97,9 +101,11 @@ Translates text to another language.
97101

98102
**Behavior:** Outputs only the translation with no commentary or explanation.
99103

104+
**Composable:** `/translate` works with attached images or `/screen`. Vision OCR extracts the text first; translation runs on the result. Omitting a target language defaults to Vietnamese.
105+
100106
**Language format:** The target language can be a full name (`French`), ISO code (`fr`, `fra`), or common shorthand.
101107

102-
**Default behavior:** If no language is specified, non-English input translates to English and English input translates to Vietnamese.
108+
**Default behavior:** If no language is specified, the text is translated to Vietnamese.
103109

104110
---
105111

@@ -115,6 +121,8 @@ Rewrites text to read more naturally and clearly.
115121

116122
**Behavior:** Preserves the original meaning while improving flow and readability. Outputs only the rewritten text.
117123

124+
**Composable:** `/rewrite` works with attached images or `/screen`. Vision OCR extracts the text first, then rewrites it.
125+
118126
---
119127

120128
## /tldr
@@ -129,6 +137,8 @@ Summarizes text into 1-3 short, direct sentences.
129137

130138
**Behavior:** Captures the core message, key decision, or critical takeaway. Skips background detail and qualifications.
131139

140+
**Composable:** `/tldr` works with attached images or `/screen`. Vision OCR extracts the text first, then summarizes it.
141+
132142
---
133143

134144
## /refine
@@ -143,6 +153,8 @@ Fixes grammar, spelling, and punctuation while preserving your voice.
143153

144154
**Behavior:** Corrects errors and smooths rough phrasing without restructuring or adding new ideas. Your original tone and meaning stay intact.
145155

156+
**Composable:** `/refine` works with attached images or `/screen`. Vision OCR extracts the text first, then refines it.
157+
146158
---
147159

148160
## /bullets
@@ -157,6 +169,8 @@ Extracts key points from text as a markdown bullet list.
157169

158170
**Behavior:** Each point is a concise, self-contained statement. Ordered by importance or logical sequence. Filler and repetition are removed. Output uses `- ` prefixed markdown bullets.
159171

172+
**Composable:** `/bullets` works with attached images or `/screen`. Vision OCR extracts the text first, then extracts key points.
173+
160174
---
161175

162176
## /explain
@@ -172,6 +186,8 @@ Explains any concept, term, or code snippet in plain language, always with a con
172186

173187
**Behavior:** Outputs a brief explanation followed by at least one concrete example. Assumes no background knowledge. Skips jargon or defines it when unavoidable. No intro or sign-off.
174188

189+
**Composable:** `/explain` works with attached images or `/screen`. Vision OCR extracts the text first, then explains it.
190+
175191
---
176192

177193
## /todos
@@ -185,3 +201,5 @@ Summarizes what a piece of text is about, then extracts every task, action item,
185201
- `/todos [paste a conversation or notes]`: processes typed or pasted content
186202

187203
**Behavior:** Responds in two parts: a short paragraph explaining the context and what is at stake, followed by a `- [ ]` checkbox list of all tasks. Each to-do includes who is responsible, plus any deadline or timeframe if mentioned.
204+
205+
**Composable:** `/todos` works with attached images or `/screen`. Vision OCR extracts the text first, then extracts to-dos.

docs/extract.md

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)