# Thisper

Thisper is a typing-first communication translator. It rewrites raw text into clearer text while staying as close as possible to the original meaning, voice, uncertainty, and tone.

## Current Desktop Scope

- Desktop text-to-text rewrite UI with diff review
- Rewrite modes: `Preserve Voice`, `Clean`, `Readable`, `Formal`, `Concise`
- Gemini-backed cloud rewrite provider with typed model selection
- Secure Gemini API key storage through the system credential store
- Global cross-app rewrite shortcut: `Ctrl + Alt + R`
- System tray support with background operation
- Non-destructive clipboard replacement flow: selected text is only replaced after the full rewrite succeeds
- URL protection: links are treated as protected content and must survive rewrites unchanged
- Local-only runtime observability for rewrite attempts, failures, model use, and last error category

## Desktop Workflow

### Main Window

1. Paste or type raw text.
2. Choose a mode and model.
3. Run `Rewrite`.
4. Review either the final output or the diff.
5. Copy the result.

### Cross-App Rewrite

1. Select plain text in another app.
2. Press `Ctrl + Alt + R`.
3. Thisper copies the selection, rewrites it in `Preserve Voice`, then pastes the full replacement only after the provider returns a complete result.
4. The previous text clipboard contents are restored after the operation when they were available as plain text.

If no API key is configured, Thisper brings the main window forward instead of attempting a destructive rewrite.

## Tray And Background Behavior

- Thisper starts with a tray icon on desktop platforms where tray icons are supported.
- Closing the window does not quit the app by default. The first close shows a tray hint, and later closes hide the window to the tray.
- The tray menu provides:
  - `Show Thisper`
  - `Run Clipboard Rewrite`
  - `Quit`
- The global shortcut remains active while the window is hidden.
- `Quit` from the tray exits the app fully.

## Known Limitations

- Cross-app rewrite is designed for plain-text targets first. Rich editors, browser text surfaces, and heavily customized inputs are best-effort.
- Secure fields and some application surfaces may block selection, copy, paste, or synthetic key events.
- Clipboard restoration currently preserves prior plain-text clipboard contents. Non-text clipboard formats are not yet restored.
- If a rewrite attempts to drop a protected URL, Thisper now fails that rewrite instead of silently removing the link.
- Model fidelity still depends on prompt behavior. High-value detail protection is planned, but not part of the current Phase 2 completion scope.

## Setup

### Prerequisites

- [Rust](https://rustup.rs/) stable toolchain
- [Node.js](https://nodejs.org/) LTS
- A Gemini API key from [Google AI Studio](https://aistudio.google.com/)

### Credentials

Use the in-app Settings dialog to save the Gemini API key into your system credential store.

For development, Thisper also accepts:

```powershell
$env:GEMINI_API_KEY = "YOUR_API_KEY_HERE"
```

### Run Development

```powershell
npm install
npm run tauri dev
```

## License Auditing

Thisper includes automated license-audit commands:

```powershell
npm run licenses:npm
npm run licenses:rust
npm run licenses:all
```

Current status:
- automation is present
- the final commercial allowlist policy is still pending
- current Rust audit output includes weak-copyleft and platform-stack licenses that need an explicit policy decision before monetization

## Architecture

- Frontend: Vanilla TypeScript, HTML, CSS, Vite
- Backend: Tauri v2, Rust
- Provider boundary: pluggable rewrite provider trait
- Current provider: Gemini
- Desktop integration: global shortcut, clipboard pipeline, tray/background mode

## Project Tracking

See:

- `THISPER_STATUS.md` for current completion status
- `LEGACY_HARDWARE_VALIDATION.md` for the Phase 2 validation checklist and report
- `PHASE3_SPEECH_PLAN.md` for the queued next-phase speech scope
