Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ notes. Entries describe what users experience, not internal refactors.

### Added

- **Start with a task for the document in front of you.** Assistant suggestions
follow the editor and selection. Choose a task to prepare an editable request,
then send. If the document scope changes, your draft is kept for you to confirm
again.
- **Read drafts and review changes more clearly.** Document drafts and incomplete
responses have distinct labels. Change reviews emphasize Apply and Cancel,
with editing, refinement, copying and location in More actions.

- **See what the assistant is doing while you wait.** Request understanding,
generation and review show their actual stage. A compact elapsed-time hint
clears when content arrives or you stop, while your next draft stays editable.

- **Find earlier assistant conversations.** Search titles and messages locally,
browse recent chats by date and see the current conversation at a glance.
Compact row actions confirm which conversation will be deleted; history
Expand Down
105 changes: 105 additions & 0 deletions docs/explorations/2026-10-14-assistant-workspace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Contextual assistant workspace

## Product direction

The assistant should help complete the current document task. A generic welcome,
undifferentiated replies and a row of equally prominent review buttons made the
next step harder to identify. This iteration improves task discovery, reading
and the existing review decision together.

Contextual tasks stage an editable request. Explicit Send remains the execution
boundary, and Apply remains the document-change boundary. A host-selected task
can carry its known intent, avoiding a separate classification request when its
text, session and original editor scope still match. Arbitrary typed requests
continue through normal routing.

Result identity follows host metadata: ordinary answers, document drafts and
interrupted output retain their separate meaning. Presentation labels never
become part of copied or applied source content. Review gives Apply and Cancel
priority, with Edit, Refine, Copy and Locate in an accessible disclosure.

## Architecture and boundaries

The panel owns submission, preparation, consent and controller/session state.
Task entry owns transient staging provenance; existing bounded context capture
and SDK event subscriptions remain authoritative. ChatView remains independent
of the editor. ActionPreview retains target validity, confirmation and truthful
sent/verified receipts.

No provider default, persistent history format or editor mutation contract is
replaced. Local inference continues to use existing WebGPU support. Visual
feedback uses CSS/SVG and real application state; no simulated reasoning or
decorative GPU renderer is introduced.

## Verification

Specification and code-quality reviews approved each functional chunk. The
integration checks passed 5,448 unit tests in 187 files, `pnpm run lint:ts`
(including workspace and application TypeScript), and `pnpm run build`.

Reverse regressions established that the tests detect missing task staging,
extra classification on trusted tasks, duplicate context capture, incorrect
Chinese writing intent, missing artifact identity and invisible keyboard focus.
Review tests fail against the earlier primary/secondary action layout. Progress
tests detect a wall-clock jump, a timer restarting after renderer-only clear,
and direct task answers retaining the planning phase.

Browser acceptance covers the actual OnlyOffice editor with controlled provider
and speech events. It checks shared leading edges, compact controls, light and
dark themes, 320/432/520-pixel sidebars, narrow Chinese feedback, reduced motion,
keyboard focus, draft preservation, Stop/retry, review and native Undo. Progress
phase changes move the composer by at most one pixel; dictation checks stable
composer and message geometry. The clock is outside live regions so a screen
reader receives phase changes without per-second announcements.

The initial combined run passed 34 cases; four failed while saving screenshots
because the disk was full. After scoped cleanup of ignored generated outputs,
all four reruns passed. The final combined Chromium run passed all 40 cases
with one worker, including Stop/resume, history, dictation, writing, context
events, layout and new process feedback. The repository format check passed;
35 final screenshots were preserved and inspected across the changed surfaces.

Physical microphone behavior, manual screen-reader operation, high browser zoom
and model quality or first-token latency on the user's hardware are not verified
by these controlled checks. No measured model speedup is claimed.

## Browser-local latency follow-up

Source inspection establishes that ordinary non-native requests first await
`resolveRequestIntent` and then start the answer or document task. Trusted staged
tasks avoid that first inference. The ordinary chat controller already forwards
streamed text; its local preflight supplies no native tools, so the runtime's
tool-prose deferral does not explain this path's first-content delay.

`captureRequestContext` attaches readable current-document data, capped at 8,000
characters, even for ordinary questions. Writing transformations await a complete
JSON body and validation before publishing the review. These are concrete places
to measure classification time, input processing and first visible output. This
inspection does not establish the user's actual model, GPU/CPU backend, prompt
token count or latency.

The requested process feedback identifies actual host phases and elapsed waiting;
it does not claim faster model computation or invent a reasoning transcript.
Prompt compression, selective context and validated streamed writing remain
separate performance interventions requiring quality and scope regressions.

## Overall experience assessment

The next action is clearer at each boundary: choose a document task, edit and
send its request, read the answer or draft, review the change, then apply and
undo if needed. Task selection does not execute automatically. Interrupted
content cannot acquire completed-draft authority. Existing history and voice
controls remain compact and preserve the editing surface while their state
changes.

The largest remaining opportunity is time to useful content for ordinary
browser-local questions. Measure intent classification, document input
processing and answer generation separately before changing defaults. A scoped
read-only path could avoid repeated inference, but it must explicitly disable
mutation tools and preserve target, consent and stream validity checks; simply
routing document tasks as ordinary chat would lose those guarantees.

A smaller recovery opportunity is an expired staged task after changing model
or document scope. The current behavior safely preserves the draft and requires
confirmation. A later explicit recovery action could retain that draft and make
reselection easier without silently retargeting or sending it.
90 changes: 90 additions & 0 deletions docs/superpowers/plans/2026-10-14-assistant-workspace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Assistant Workspace Implementation Plan

> **For agentic workers:** REQUIRED: Use superpowers:subagent-driven-development. Steps use checkbox syntax for tracking.

**Goal:** Make document tasks discoverable and make generated results and reviewed changes clearer, within one new PR.

**Architecture:** The panel retains submission and consent ownership. An app-owned task module stages bound request intent, ChatView improves generic result rendering, and ActionPreview improves its existing review composition. No persistence or model-provider contract is replaced.

**Tech Stack:** TypeScript, ranui builders/components/tokens, Vitest/jsdom, Playwright and the existing OnlyOffice editor bridge.

**Specification:** `docs/superpowers/specs/2026-10-14-assistant-workspace-design.md`.

## Chunk 1: Contextual task entry and routing

Files: new `lib/agent-plugin/ui/task-entry.ts`; integration in `panel.ts` and
`panel-context.ts`; task-entry styles in `styles/assistant.css`; locale tables
and `i18n/types.ts`; unit tests and `test/e2e/agent-workspace.spec.ts`.

- [x] Write failing tests for format/selection suggestions, no automatic sends,
draft preservation, expired scope and edited-request fallback.
- [x] Run focused Vitest; verify behavioral failures before implementation.
- [x] Build the contextual task entry using existing bounded context reads.
Stage `{ text, intent, target, session }` only on a user task click; consume
after explicit Send and fresh scope checks. Preserve preparation/consent.
- [x] Integrate known intent into routing without altering arbitrary typed
requests, native tools, literal commands, cancellation or refinement.
- [x] Verify a ready staged writing task makes zero classification calls and
one writing call. Add real Word flow through native change and Undo.
- [x] Commit as `feat(assistant): add contextual tasks and direct request routing`.

## Chunk 2: Conversation and result hierarchy

Files: `packages/chat-ui/src/{chat-view,styles,types}.ts`; existing chat-view
unit suites; relevant browser result/streaming tests.

- [x] Write failing result tests: artifact identity, interrupted/restored
semantics, original source for copy/apply, accessible actual activity.
- [x] Run red tests, then improve typography, document-draft framing, compact
actions and truthful streaming/activity states through optional labels.
- [x] Preserve editor independence and all existing public method behavior.
Coordinate any new localized labels with the task-entry owner.
- [x] Verify long Markdown/table/code, keyboard focus, draft editing, Stop and
reader scroll position. Honor reduced motion and narrow layouts.
- [x] Commit as `feat(chat-ui): clarify drafts and conversation results`.

## Chunk 3: Review and completion

Files: `lib/agent-plugin/ui/action-preview.ts`, review styles only in
`styles/assistant.css`, action-preview units and content-review E2E.

- [x] Add failing tests for clear primary/secondary action hierarchy and
accessible secondary controls; retain all existing review behaviors.
- [x] Improve target/comparison composition and action grouping using ranui.
Use actual review data and actual execution outcomes. Preserve expiration,
cancellation, refinement, current-target checks and draft editing.
- [x] Verify Apply/Cancel/Edit/Refine/Copy/Locate, selection invalidation,
sent versus verified outcomes, error states and restored focus.
- [x] Run native Word review/application/Undo E2E and screenshot validation.
- [x] Commit as `feat(assistant): refine change review and completion`.

## Chunk 4: Immediate process feedback

The user requested visible process while browser-local inference is waiting.
ChatView owns presentation and elapsed-time cleanup; the host supplies the
actual phase and translated labels. Existing provider and history contracts stay
unchanged. A classification phase is only shown when classification runs.

- [x] Add failing tests for immediate phase feedback, measured elapsed waiting,
first streamed content, review resting state and Stop/disposal cleanup.
- [x] Add an explicit routing phase and localized labels. Keep elapsed text out
of repeated live announcements and preserve stable composer geometry.
- [x] Validate a held endpoint request before and after its first content delta,
Stop/retry and focus. Do not claim real-device model latency improvement.
- [x] Commit as `feat(assistant): show immediate request progress`.

## Chunk 5: Integration and delivery

- [x] Spec compliance review, then code-quality review for each functional unit.
Fix verified findings and check final consumers/state owners.
- [x] Integrate functional commits; keep root and subagent checkouts isolated.
- [x] Inspect final light/dark/narrow screenshots and measure shared alignment
and stable composer geometry; record unverified acceptance surfaces.
- [x] Update changelog and concise exploration record. Run reverse regressions.
- [x] Run full unit suite, format, lint/typecheck and production build, then
selected real-editor E2E including Stop, history and dictation regressions.
- [ ] Fetch latest main, verify clean checkout and ahead/behind, push the feature
branch, create/attach one new PR, and inspect checks for the pushed SHA.

This checklist is committed before publication. The PR records the final branch
revision and subsequent CI status.
104 changes: 104 additions & 0 deletions docs/superpowers/specs/2026-10-14-assistant-workspace-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Contextual document assistant workspace

## Approved direction and evidence

The user approved implementing the overall UX/design direction discussed in the
conversation: document-aware entry points, clearer context, stronger answer and
review hierarchy, less uninformative waiting, and direct completion in the editor.
Use one new PR from current main, with functional commits. PR #268 is merged.

Current code facts:

- `panel-context.ts` and `composer-context.ts` already own bounded selection reads
and event-driven refresh. The welcome view currently offers text hints only.
- `panel.ts` routes ready non-native requests through `resolveRequestIntent`
before generating an answer or writing proposal. Exact host-selected tasks
can carry their known intent without this extra model classification.
- `ActionPreview` already owns target validity, comparison, confirmation,
cancellation, refinement and verified/sent receipts. Improve its composition;
retain these execution safeguards.
- `ChatView` is editor-independent. The host marks document artifacts; generic
rendering must never infer write permission from prose or show interrupted
results as completed artifacts.

No claim is made about actual model latency or answer quality without measurement.

### Follow-up: immediate process feedback

The user reports long waits before browser-local answers and requests visible
process feedback. Show actual host phases immediately: request classification,
reading content and generating an answer. Keep human review a resting state.
Elapsed waiting time is measured locally, does not announce every tick to screen
readers, and ends on completion, Stop, failure, view disposal or a new turn.
Streaming text still appears as it arrives. Do not expose simulated reasoning,
invent percentages or claim that process visibility speeds up model computation.
Keep provider settings, inference and history contracts unchanged.

## Experience

1. Open the assistant to see the current document scope and a compact set of
useful tasks for Word, Excel, PowerPoint or PDF. Selected text changes the
suggestions. Empty, oversized/unavailable selection and read-only contexts
must remain honest about scope and supported operations.
2. Clicking a task stages an editable request and focuses the composer. It does
not invoke a model, download a model, overwrite a nonempty draft, or queue work.
Explain the staging interaction briefly. Explicit Send starts the operation.
3. A staged task is host-owned metadata, consumed once only if the request and
captured session/editor scope still match. Edited requests use normal routing;
stale selection/context gives visible guidance and preserves the request.
Never skip classification solely by matching arbitrary user-authored text.
4. Preserve current preparation, endpoint consent and local writing consent.
Ready staged writing tasks avoid exactly one routing model call. Prove this
with request counts, not an invented percentage or timing promise.
5. Distinguish ordinary answers, document drafts, interrupted output and activity
with restrained typography, surfaces and labels. Main content remains readable;
copy and apply retain the original source and completion guards.
6. A pending review shows its actual target and original/proposed changes, with
one clear Apply decision, Cancel, and a discoverable secondary-actions area.
Preserve Edit, Refine, Copy and Locate. Completion shows only the actual
verified/sent outcome, location and existing Undo guidance.

## Scope and ownership

Allowed: assistant UI modules and integration in `lib/agent-plugin/ui/panel.ts`,
`styles/assistant.css`, generic presentation in `packages/chat-ui/src`, seven
locale tables/types, relevant tests, changelog and design/verification records.

Ownership: panel coordinates submission/consent/session state; a dedicated task
entry module owns staged-task provenance and UI; existing context reads remain
single-owned; ChatView owns rendering; ActionPreview owns review state.

Compatibility boundaries: preserve storage formats, provider defaults, explicit
Send, experimental local-writing consent, cloud consent, read-only behavior,
selection bounds, model/tool cancellation, target validity and truthful receipts.
No vendor edits, new renderer dependency, GPU visual framework, background model
calls, synthetic thinking, fabricated audio waveforms or automatic document writes.
Existing browser-local inference continues using WebGPU where supported.

## Visual acceptance

Use the repository's ranui components/tokens. GPUI-native APIs do not apply to
this TypeScript browser UI. Common leading edges, a stable composer and compact
secondary chrome give the document/result space priority. Use CSS/SVG for state
transitions, honor reduced motion, and retain keyboard operation/focus restoration.

Check real editor layouts at 320px sidebar width and default/wide widths, light
and dark themes, long/CJK content, empty/loading/error/read-only states. Review
actual screenshots. Avoid generic welcome screens repeated for every format.

## Acceptance

- Context suggestions update through existing SDK events and perform no model
call until explicit Send; drafts survive setup, Stop and state changes.
- Host-selected writing request: classification count decreases from one to
zero; writing still executes once, then waits for review. Edited/stale/session
switched requests cannot reuse a privileged or stale task hint.
- Real Word: select text, stage polish, Send, review old/new, Apply, verify native
text and Undo. Exercise a follow-up refinement and Stop/retry.
- Excel/PPT/PDF suggestions describe only available scope; read-only/oversized
selection does not promise unsupported mutation.
- Copy/apply/interrupted/restored result semantics and history/speech regressions
remain passing. Reverse-disable new behavior to prove regressions fail.
- Full unit suite, format, lint/typecheck, production build and appropriate real
editor E2E pass before push/PR. Physical model quality and microphone accuracy
remain separate acceptance surfaces.
Loading
Loading