You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "YayoiNanoka (via GitHub)" <gi...@apache.org> on 2026/10/14 01:20:18 UTC

[PR] feat(desktop): open sessions in dedicated windows [maka]

YayoiNanoka opened a new pull request, #6093:
URL: https://github.com/apache/maka/pull/6093

   ## Summary
   
   **Problem:** Maka's single workspace window makes it difficult to keep separate tasks visible at the same time. Opening additional workspace windows also requires preventing two editors from owning the same session and preserving drafts, attachments, and native resources during transfers.
   
   **Solution:** Add **Open in new window** to session context and overflow menus. A main-process coordinator assigns each logical session group—its parent, subagents, revisions, and side chats—to one window. Dedicated session windows reuse the conversation and workbar without the sidebar and provide **Open in main window**. Transfers save and restore workspace state, move native browser/terminal ownership, and revoke stale renderer operations.
   
   **Result:** Users can work on separate tasks side by side. Selecting an already detached session focuses its existing window; detaching the current session leaves the main window blank. Drafts, attachments, reading positions, and workbar state survive transfers. Closing the main window leaves session windows running, while restarting opens only the main window.
   
   This branch starts from the fork's `main` at `32b1750487ad2ccee6da5928c5dc8f98851f5bca` and contains only the multi-window feature and its tests.
   
   ## Verification
   
   - Full repository build and typecheck passed.
   - 715 targeted regression tests passed, covering window ownership, concurrency, rollback, drafts, attachment recovery, side chats, native resources, menus, and workbar behavior.
   - Three real Electron tests passed on macOS: new-task draft reload; detach/return preserving native browser identity and restoring a minimized owner; main-window closure/recreation and restart opening only main.
   - Lint, formatting, desktop/UI Knip, strict renderer architecture, app-shell hooks, locale hygiene, and E2E budget checks passed.
   - Independent Codex subagent review found no unresolved P0/P1. The baseline transplant was reviewed separately. Human review remains required.
   - Native Windows/Linux execution was not run.
   
   ## Known limits and draft follow-up
   
   - The existing 128 MiB live attachment-recovery quota remains enforced. Insufficient capacity rejects a transfer before clearing the source workspace.
   - [ ] Fix recovered attachments when an empty side-chat fork is recreated because its model is unavailable. Handles scoped to the old fork are rejected with `source_expired`; removing and reselecting the attachment works around this P2 issue. Stored attachment bytes remain retained.
   
   ## AI use
   
   - [ ] No generative tool made a substantive contribution
   - [x] Generative tooling made a substantive contribution
   
   Tool(s) and scope: OpenAI Codex implemented the feature and tests, ran validation, and performed independent subagent review. Commits include the `Generated-by: OpenAI Codex` trailer. Human review and the merge decision remain pending.
   
   ## Checklist
   
   - [x] Tests cover the change and fail without it
   - [x] Lint, format, typecheck and the affected suites pass locally
   
   Does this PR entail a change in behavior?
   
   - [x] Yes — described under Summary above
   - [ ] No
   
   <details>
   <summary>点击展开中文</summary>
   
   ## 概述
   
   **问题:** Maka 目前只有一个工作区窗口,不便于同时查看不同任务。增加窗口还需要确保同一会话不会被两个编辑界面同时持有,并在窗口转移时保留草稿、附件和原生资源。
   
   **解决方式:** 在会话右键菜单和更多菜单中添加“在新窗口打开”。主进程协调器将每个逻辑会话组(父任务、子 agent、修订版本和侧聊)分配给唯一窗口。独立会话窗口复用聊天界面和工作栏,不显示左侧会话列表,并提供“在主窗口打开”。转移过程中保存和恢复工作区状态,交接原生浏览器与终端的控制权,并拒绝旧窗口迟到的操作。
   
   **实现效果:** 用户可以并排处理不同任务。点击已在独立窗口中的会话会聚焦该窗口;将当前会话移出后,主窗口显示空白页面。草稿、附件、阅读位置和工作栏状态会随会话保留。关闭主窗口不会关闭独立会话窗口,重启应用则只打开主窗口。
   
   本分支从 fork 的 `main`(`32b1750487ad2ccee6da5928c5dc8f98851f5bca`)创建,只包含多窗口功能及其测试。
   
   ## 验证
   
   - 全仓构建和类型检查通过。
   - 715 项针对性回归测试通过,覆盖窗口归属、并发、失败回滚、草稿、附件恢复、侧聊、原生资源、菜单和工作栏行为。
   - macOS 上 3 项真实 Electron 测试通过:新任务草稿刷新恢复;移出与返回时保留原生浏览器实例并恢复最小化窗口;主窗口关闭与重建,以及重启只打开主窗口。
   - Lint、格式、桌面/UI Knip、严格 renderer 架构、app-shell hooks、语言文案检查和 E2E 预算检查均通过。
   - 独立 Codex subagent review 没有未解决的 P0/P1,迁移到新基线也单独复核过;仍需人工审查。
   - 未运行原生 Windows/Linux 测试。
   
   ## 已知限制与 Draft 后续工作
   
   - 保留现有实时附件恢复的 128 MiB 配额。容量不足时,会在清除源工作区之前拒绝转移。
   - 待修 P2:空侧聊因模型不可用而重建 fork 后,属于旧 fork 的恢复附件会被拒绝并返回 `source_expired`。移除并重新选择附件可暂时解决;已保存的附件内容仍然保留。
   
   ## AI 使用
   
   OpenAI Codex 对功能实现、测试、验证及独立 subagent review 作出了实质性贡献。提交包含 `Generated-by: OpenAI Codex` 标记。人工审查和合入决定尚未完成。
   
   ## 检查清单
   
   - 测试覆盖本次改动,并能在缺少对应实现时检测失败。
   - 本地 lint、格式、类型检查及受影响测试集通过。
   - 本 PR 会改变产品行为,具体见上方概述。
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] feat(desktop): open sessions in dedicated windows [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #6093:
URL: https://github.com/apache/maka/pull/6093#discussion_r4286145309


##########
docs/astryx-surface-file-inventory.md:
##########
@@ -126,9 +126,14 @@ Wiki bar: Design Conventions · API Use-the-System · Theming · Container Paddi
 | `apps/desktop/src/renderer/features/session-navigation/services-context.tsx` | shell-chrome-or-panel | none | aligned — no raw controls; no Astryx JSX usage | aligned |
 | `apps/desktop/src/renderer/features/session-navigation/ui/archived-task-scope.tsx` | shell-chrome-or-panel | Button, HStack, Selector, StackItem, Text, TextInput, VStack | aligned — uses Astryx (Button, HStack, Selector, StackItem, Text, TextInput, VStack) | aligned |
 | `apps/desktop/src/renderer/features/session-navigation/ui/session-history-navigation.tsx` | shell-chrome-or-panel | none | aligned — no raw controls; no Astryx JSX usage | aligned |
+| `apps/desktop/src/renderer/features/session-navigation/ui/session-navigation-commands.tsx` | shell-chrome-or-panel | none | aligned — no raw controls; no Astryx JSX usage | aligned |

Review Comment:
   **[P2] Regenerate the inventory totals with these new rows**
   
   These five new surfaces are present in both the path inventory and the generated rows, but the totals at line 9 remain at the main parent's 340 files / 336 aligned instead of 345 / 341. `npm run astryx:surface-inventory` therefore exits 1 on this head; the actual main parent passes with the same generator and pinned dependencies. This check runs before Build in CI. Please regenerate and commit the artifact with `npm run astryx:surface-inventory:write`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] feat(desktop): open sessions in dedicated windows [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #6093:
URL: https://github.com/apache/maka/pull/6093#discussion_r4302472374


##########
apps/desktop/src/main/runtime-host-boot.ts:
##########
@@ -1199,6 +1278,13 @@ const createLocalRuntimeHostManager = () => createRuntimeHostDesktopManager(
           transcriptInitialHistoryBytes: PARTIAL_HISTORY_TRANSCRIPT_BYTES,
         }
       : {}),
+    canUseSession: async (senderId, scope, sessionId) => {
+      const sender = mainWindowController.registry.entries().find((entry) => entry.window.webContents.id === senderId)?.window.webContents;
+      if (!sender) return false;
+      const key = desktopSessionKey({ ...scope, sessionId });
+      await sessionWindows.refreshGroup(key);

Review Comment:
   P3: this runs on every `shell-runs:write` (one call per terminal keystroke). Each call goes through `resolveGroup`, which rescans `sessionLocal.catalog()` and calls `publish()`, broadcasting ownership to every window. A synchronous membership check, with a refresh only when the session is unknown, would avoid that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] feat(desktop): open sessions in dedicated windows [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #6093:
URL: https://github.com/apache/maka/pull/6093#discussion_r4268891285


##########
apps/desktop/src/main/browser-ipc-main.ts:
##########
@@ -96,9 +103,10 @@ export function registerBrowserIpc(deps: BrowserIpcDeps): BrowserIpcController {
       window.isVisible() && !window.isMinimized();
   };
   const canRunInBackground = (sessionId: string): boolean => {
+    const ref = parseDesktopSessionResourceKey(sessionId);
+    if (detachedSessions.has(sessionId)) return deps.isHostActive(ref);

Review Comment:
   P1: any session ever transferred or parked stays in `detachedSessions` until `retireTarget`, so `canDrive`/`beginAction` admit observe *and* mutate actions while it is hidden, minimized, back in main behind another session, or parked after its window closed. This removes the shown+viewport requirement that only WorkHub coordination sessions were exempt from. Keep parked pages alive, but leave them under the normal visibility rule.



##########
apps/desktop/src/main/runtime-host-boot.ts:
##########
@@ -2118,6 +2267,9 @@ function emitSessionsChanged(
     ...(extra?.modelId ? { modelId: extra.modelId } : {}),
     ...(extra?.turnId ? { turnId: extra.turnId } : {}),
   };
+  if (sessionId && reason !== 'deleted') {
+    void sessionWindows.refreshGroup(desktopSessionKey({ ...scope, sessionId })).catch(() => undefined);

Review Comment:
   P2: this runs a full `client.listSessions()` catalog read (line 898) for every non-delete `sessions:changed`, including per-run `status-change`/`message-appended` events, even when no session window exists. Gate it on session windows being open or the session being a new unknown member.



##########
apps/desktop/src/main/session-window-coordinator.ts:
##########
@@ -0,0 +1,520 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { randomUUID } from 'node:crypto';
+import type { IpcMain, WebContents } from 'electron';
+import type {
+  SessionWindowCommand, SessionWindowCommandReply, SessionWindowCommandResult,
+  SessionWindowGroup, SessionWindowNavigation,
+} from '../shared/session-window-contract.js';
+import type { SessionWorkspaceSnapshot } from '../shared/session-workspace-state.js';
+import type { MainWindowController } from './main-window.js';
+import type { WorkspaceWindowEntry } from './workspace-window-registry.js';
+
+type CommandInput = SessionWindowCommand extends infer Command
+  ? Command extends SessionWindowCommand ? Omit<Command, 'requestId'> : never : never;
+
+export interface SessionWindowCoordinatorDeps {
+  readonly windows: MainWindowController;
+  readonly signal: AbortSignal;
+  readonly ensureMainWindow: () => Promise<void>;
+  readonly resolveGroup: (sessionId: string) => Promise<SessionWindowGroup>;
+  readonly saveSnapshot: (sender: WebContents, snapshot: SessionWorkspaceSnapshot) => Promise<void>;
+  readonly forgetSnapshot: (sender: WebContents, snapshot: SessionWorkspaceSnapshot) => void;
+  readonly loadSnapshot: (sender: WebContents, sessionIds: readonly string[]) => Promise<SessionWorkspaceSnapshot>;
+  readonly releaseSnapshot: (sender: WebContents, snapshot: SessionWorkspaceSnapshot) => void;
+  readonly transferResources: (input: {
+    readonly group: SessionWindowGroup;
+    readonly source: WebContents | undefined;
+    readonly target: WebContents;
+  }) => Promise<void>;
+  readonly releaseResources: (sender: WebContents) => void | Promise<void>;
+  readonly isQuitting: () => boolean;
+  readonly onError: (error: unknown, sender?: WebContents) => void;
+  readonly commandTimeoutMs?: number;
+}
+
+/** A process-scoped ownership authority; a renderer never chooses its own owner. */
+export function createSessionWindowCoordinator(deps: SessionWindowCoordinatorDeps) {
+  const registry = deps.windows.registry;
+  const owners = new Map<string, string>();
+  const groups = new Map<string, SessionWindowGroup>();
+  const memberGroups = new Map<string, string>();
+  const queues = new Map<string, Promise<unknown>>();
+  let mainPresentation: Promise<unknown> = Promise.resolve();
+  const ready = new Set<string>();
+  const selections = new Map<string, SessionWindowNavigation>();
+  const readyWaiters = new Map<string, Set<() => void>>();
+  const pending = new Map<string, {
+    windowId: string;
+    resolve: (result: SessionWindowCommandResult) => void;
+    reject: (error: Error) => void;
+  }>();
+  const closing = new Set<string>();
+  const timeoutMs = deps.commandTimeoutMs ?? 20_000;
+  const groupKey = (group: SessionWindowGroup): string => JSON.stringify([group.hostId, group.groupId]);
+  const reportError = (error: unknown, sender?: WebContents): void => deps.onError(error, sender);
+
+  function requireWindow(sender: WebContents): WorkspaceWindowEntry {
+    const entry = registry.forSender(sender);
+    if (!entry) throw new Error('This operation requires a workspace window');
+    return entry;
+  }
+
+  function rejectWindowRequests(windowId: string): void {
+    ready.delete(windowId);
+    for (const operation of pending.values()) {
+      if (operation.windowId === windowId) operation.reject(new Error('The workspace window closed'));
+    }
+  }
+
+  function attachWindow(entry: WorkspaceWindowEntry): void {
+    const windowId = entry.context.windowId;
+    const sender = entry.window.webContents;
+    sender.on('did-start-navigation', (_event, _url, isInPlace, isMainFrame) => {
+      if (isMainFrame && !isInPlace) rejectWindowRequests(windowId);
+    });
+    sender.on('render-process-gone', () => {
+      rejectWindowRequests(windowId);
+      void Promise.resolve().then(() => deps.releaseResources(sender)).catch((error) => reportError(error, sender));
+    });
+    entry.window.once('closed', () => {
+      rejectWindowRequests(windowId);
+      void Promise.resolve().then(() => deps.releaseResources(sender)).catch((error) => reportError(error, sender));
+      for (const [key, owner] of owners) if (owner === windowId) owners.delete(key);
+      selections.delete(windowId);
+    });
+    entry.window.on('close', (event) => {
+      if (deps.isQuitting() || !ready.has(windowId)) return;
+      event.preventDefault();

Review Comment:
   P2: close is always prevented and only completes if flush+save succeed. `#prepareDraft` rejects `approval` attachments older than the 30-minute approval TTL (`source_expired`) or whose file is gone. The window then resumes and refuses every later close until the attachment is removed. Final close should be best-effort and not depend on custody of the draft.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] feat(desktop): open sessions in dedicated windows [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #6093:
URL: https://github.com/apache/maka/pull/6093#issuecomment-6228017942

   > **Automated agent notice:** This comment was posted by an automated agent on behalf of @Astro-Han (maintainer) and reflects his decision. It is not an independent human review.
   
   Thanks for the careful work on this, @YayoiNanoka. The maintainers like the feature: being able to keep separate sessions side by side is useful. At +7,183 lines across 145 files (about 4,000 production lines), though, it is too large for us to review and maintain as one change. **We would like you to reduce it to a minimal first version and move the rest into follow-up PRs.**
   
   **What we think the minimal version needs** (correctness only: no data loss, never two editors on one session, no destroyed-view crashes):
   - Multi-window infrastructure and an owner map, so each session belongs to exactly one window, keyed by the message-edit revision family. Open in a new window, return to main, and focus the existing window.
   - Main pushes the set of sessions each window owns, so the renderer can route synchronously. This keeps `session-visit-history` / back-forward unchanged.
   - Transfer the plain-text draft (text plus inline references) in both directions.
   - **Refuse to detach or return** when the draft has attachments, quotes, directory references, an edit in progress, a pending send, or a side chat with content. Show a short "send or clear first" message instead of transferring them.
   - A simple renderer "Discard unsent draft?" confirmation when closing a session window with a non-empty composer.
   - Keep the browser re-parenting and release-on-close, and the terminal `assertOwner` check, so two windows can never write to the same shell run. Also keep `persistLayout: false` for the child.
   
   We estimate this at roughly **1,000–1,150 production lines**. An even smaller option is to allow detaching only when there is no unsent content at all, at about 700.
   
   **What we would like to see moved out** (later PRs, each judged on its own merits):
   - Attachment/quote/directory-reference transfer, including the main-process attachment byte store with 256 MiB capacity accounting, tombstones and recovery-token reissue. That is a lot of machinery for a handoff between two renderers in the same process.
   - The multi-phase window command protocol with per-group queues, the global presentation lock, timeouts and rollback. With text-only transfer, `release` and `adopt` should be enough.
   - Side-conversation custody transfer through the persisted copy lease.
   - Retain-on-close with cancel/recover, which also moves the hard-coded zh/en dialog text into locale copy if it comes back.
   - Session-group resolution beyond the revision family: subagent and side-chat ancestry walks.
   - Workbar layout and reading-position handoff, PiP owner, notification focus routing, async back/forward, and smart window placement.
   - The pure moves out of `app-shell.tsx`. Please land these first as a separate no-behaviour-change PR, so the feature diff stays small.
   
   Please keep tests proportional to the smaller design. Much of the current test volume covers transaction cases that would no longer exist.
   
   If you see a correctness reason that one of the "moved out" items must be in the first version, please point it out and we will discuss it. Thank you!
   
   🤖 Posted by an automated agent at @Astro-Han's request.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org