feat: refactor composer to two-layer layout, add session permission & context indicator

Composer restructure:
- MessageInput internal footer now only contains: file button, model
  selector, slash command button, and send button
- Removed mode toggle (Code/Plan) from composer area (logic preserved)
- New ChatComposerActionBar below input with three slots: left (Design
  Agent), center (permission selector), right (context indicator)

New components:
- SlashCommandButton: inserts `/` at cursor, reuses existing slash
  command detection and popover logic
- ChatPermissionSelector: session-level permission toggle (default /
  full_access) with danger confirmation dialog
- ContextUsageIndicator: SVG donut chart showing context usage ratio
  with HoverCard displaying model, tokens, cache stats
- ChatComposerActionBar: slot-based container for action bar items

Session permission (permission_profile):
- DB: new column on chat_sessions, default 'default'
- API: PATCH sessions supports updating permission_profile
- Chat API: bypassPermissions = global setting OR session full_access
- PermissionPrompt: auto-approves and hides when full_access
- Claude client: combines global and per-session bypass flags

Bridge integration:
- permission-broker: auto-approves permissions for full_access sessions
  without sending IM notifications
- conversation-engine: passes bypassPermissions to SDK for full_access
- PATCH route: auto-approves pending bridge permissions on switch to
  full_access

Other:
- ImageGenToggle relabeled to "Design Agent" / "设计 Agent"
- New model-context.ts with MODEL_CONTEXT_WINDOWS lookup
- Provider models API returns optional contextWindow field
- New useContextUsage hook for token usage calculation
- i18n: added composer.*, permission.*, context.* keys (en + zh)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
7418andClaude Opus 4.6 committed 2026-03-07 14:55:38 +08:00
1 parent 9695825007
commit 111fa8c92e
23 files changed
+643 -37

No files matched your search

+4 -1
View File
@@ -21,6 +21,7 @@ export interface ChatSession {
runtime_status: string;
runtime_updated_at: string;
runtime_error: string;
permission_profile?: 'default' | 'full_access';
}
// ==========================================
@@ -122,7 +123,7 @@ export interface ProviderModelGroup {
provider_id: string; // provider DB id, or 'env' for environment variables
provider_name: string;
provider_type: string;
models: Array<{ value: string; label: string }>;
models: Array<{ value: string; label: string; contextWindow?: number }>;
}
export interface CreateProviderRequest {
@@ -813,4 +814,6 @@ export interface ClaudeStreamOptions {
/** Recent conversation history from DB — used as fallback context when SDK resume is unavailable or fails */
conversationHistory?: Array<{ role: 'user' | 'assistant'; content: string }>;
onRuntimeStatusChange?: (status: string) => void;
/** Per-session bypass: when true, skip all permission checks for this session */
bypassPermissions?: boolean;
}