feat: make AI Assistant a tileable workspace pane (not a rail view)

Open it from the toolbar ( AI Chat) and lay it out next to a Serial
session with Layout (1×2, 2×2…) — chat on one side, watch the terminal
on the other, like Claude Code / Kiro. Previously it was a full-page
Activity Rail view that couldn't sit beside a live session.

WorkspaceView.Session is now abstracted to hold either a SessionPage or
an AiChatView via a Content property; group/log/script actions skip AI
panes. Removed the standalone Ai rail view; Settings → AI Assistant
(provider config) is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-05 21:57:09 +08:00
co-authored by Claude Fable 5
parent d9e0e8fabf
commit 6e955ba247
6 changed files with 72 additions and 45 deletions
+4 -4
View File
@@ -476,7 +476,7 @@ Kiro/Claude CLI ── 啟動子行程 ETTerms.PduMcpstdio / JSON-RPC
### 內建 AI AssistantPhase 10 — ✅ 已完成 v0.6.0
> 讓 ETTerms **自己就是 agent host**——不經 Claude / Kiro,在 GUI 內建 AI 聊天檢視(Activity Rail 的 ✨ view,用自然語言驅動 serial 與 PDU(「接上 COM3,送 help 看回應」「連上 PDU,把 outlet 3 重開」一句話完成)。
> 讓 ETTerms **自己就是 agent host**——不經 Claude / Kiro,在 GUI 內建 AI 聊天**分頁**,用自然語言驅動 serial 與 PDU(「接上 COM3,送 help 看回應」「連上 PDU,把 outlet 3 重開」一句話完成)。**AI 分頁是 Workspace 的一種 pane**(工具列 `✨ AI Chat` 開啟),可用 Layout1×2 / 2×2…)與 serial 分頁**並排同時使用**——像 Claude Code / Kiro 那樣一邊聊、一邊看終端機。
**設計原則:BYO Endpoint(使用者自帶 LLM 端點)**
@@ -488,7 +488,7 @@ Kiro/Claude CLI ── 啟動子行程 ETTerms.PduMcpstdio / JSON-RPC
**架構(in-process function calling,不經 MCP**
```
AiChatViewActivity Rail 的 ✨ view,全頁聊天
AiChatViewWorkspace 的一種 pane,與 SessionPage 並排;工具列 ✨ AI Chat 開啟
└─ AgentHostAi/AgentHost.cs):維護對話歷史 + 手寫 agent loop(最多 8 輪工具)
├─ OpenAiChatClientAi/OpenAiChatClient.cs):極簡 OpenAI 相容 /chat/completions(非串流)→ 使用者設定的 Base URL
└─ AiToolsAi/AiTools.cs):in-process 直呼,不經子行程 / pipe
@@ -748,11 +748,11 @@ Rename-Item (Join-Path $proot "ETTerms.exe") "ETTerms v$ver.exe"
**包含:**
- [x] `AppSettings``AiBaseUrl` / `AiModel` / `AiSystemPrompt`(預設空白);API key 存 `CredentialVault``ETTerms/AiApiKey`
- [x] `App/SettingsView.cs`**AI Assistant** 分頁:Base URL / Model / API Key(密碼框)/ 系統提示詞,Save 寫 settings + Credential Manager;空白=停用
- [x] `App/AiChatView.cs`Activity Rail ✨ view聊天 UI(角色標色訊息串 + 輸入框 + 工具過程顯示);`RefreshProvider()` 切入時依最新設定重建 client
- [x] `App/AiChatView.cs`:聊天 UI(角色標色訊息串 + 輸入框 + 工具過程顯示);`RefreshProvider()` 開分頁時依最新設定重建 client。**作為 Workspace pane**`WorkspaceView` 工具列 `✨ AI Chat``OpenAiPane()``Session` 抽象化容納 `SessionPage``AiChatView``Content` 屬性),可與 serial 用 Layout 並排;AI 分頁無 Group / Log / Script(那些操作自動 skip
- [x] `Ai/OpenAiChatClient.cs`:極簡 OpenAI 相容 chat-completionsHttpClient,非串流)
- [x] `Ai/AgentHost.cs`:手寫 agent looptool_calls → 執行 → role=tool 餵回 → 迴圈,上限 8 輪)
- [x] `Ai/AiTools.cs`seriallist/attach/write/read,經 `SerialBridge``[AI]` echo 沿用)+ PDUconnect/status/set_port/power_cycle`ETTerms.PduCore`);破壞性動作經 `ConfirmAsync` 彈框;每筆呼叫寫 AppLogger
- [x] `ActivityRail``Ai` view(✨);`MainForm` 掛載並在切入時 `RefreshProvider()`
- [x] AI 入口在 `WorkspaceView` 工具列(`✨ AI Chat` 按鈕),開成可並排的 pane(非獨立 rail view)——這樣才能與 serial 分頁同時使用
- [ ] (延伸,未做)MCP host:讓使用者掛自己的第三方 MCP serverschema concat 進 `AiTools.GetSchemas()`
**驗收條件:** ✅ 建置 0 錯誤;未設定 Provider 時 AI 面板停用並提示;`src` grep 無任何私人端點 / key(範例一律 localhost / 假 IP)。實機端到端(接 OpenAI 相容端點跑 serial/PDU 一句話流程、PDU 確認框、`[AI]` 標色、AppLogger 紀錄)待使用者驗收。