You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "chihumyum (via GitHub)" <gi...@apache.org> on 2026/08/21 17:04:36 UTC
[PR] refactor(desktop): extract Workbar as a feature slice [maka]
chihumyum opened a new pull request, #3444:
URL: https://github.com/apache/maka/pull/3444
## Summary
- Extract Workbar layout, tools, and dynamic-resource lifecycles into a feature-owned vertical slice.
- Keep Electron bridge access in a Desktop adapter; the Workbar feature no longer imports AppShell, preload, or main, and does not access `window.maka`.
- Reduce AppShell to Workbar host inputs plus the `host` / `commands` / `selectors` surface while preserving storage, IPC, layout, mounting, and cleanup behavior.
Refs #3439
## Verification
- `npm run lint` — passed (2,513 files)
- `npm run format:check` — passed (1,565 files)
- `npm run build` — passed
- `npm run typecheck` — passed
- `npm --workspace @maka/desktop test` — passed (1,061 tests, 124 suites)
- `npx knip --workspace apps/desktop` — passed
- `npx knip --workspace packages/ui` — passed
- `npm run astryx:surface-inventory` — passed (199 files, 1 exclusion)
- `npm --workspace @maka/desktop run build-storybook` — passed
- `npm --workspace @maka/desktop run smoke:storybook` — passed (162 stories)
- `npm --workspace @maka/desktop run e2e` — passed (41 passed, 1 skipped)
## Review focus
- v1/v2 to v3 Workbar storage hydration and transient-field filtering
- Terminal ownership, stale-start fencing, close/session-switch cleanup, and RAF disposal
- Side Chat collapse/close/source-switch behavior and late fork/send disposal fencing
- Desktop service mapping and subscription disposal, especially Inspector pagination and Session usage authority
- CSS relocation/import order and right/bottom/narrow Workbar visual parity
## AI use
Select exactly one:
- [ ] No generative tool made a substantive contribution
- [x] Generative tooling made a substantive contribution
Tool(s) and scope: Codex — architecture analysis, implementation, tests, latest-main replay, lifecycle race review, and pull request preparation. The human contributor reviewed the contribution and accepts responsibility for it.
All substantive commits include `Generated-by: Codex`; retain the trailer in the final squash commit.
## 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?
- [ ] Yes — described under Summary above
- [x] No
--
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] refactor(desktop): extract Workbar as a feature slice [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on code in PR #3444:
URL: https://github.com/apache/maka/pull/3444#discussion_r3835578654
##########
apps/desktop/src/renderer/styles/workbar/shell.css:
##########
@@ -0,0 +1,311 @@
+/* Chat detail surface — unified session workbar + turn search-highlight +
+ session-branch banner. Relocated from settings/models.css (was misplaced in the
+ model-catalog file) — issue #546 PR1, zero visual change. */
+/* ──────────────────────────────────────────────────────────────────────── */
+/* SessionWorkbar — resizable Tasks / Browser / Files auxiliary workspace. */
+/* The shell owns its visibility and width; tab contents fill this surface. */
+/* ──────────────────────────────────────────────────────────────────────── */
+
+.maka-detail-with-artifacts {
+ display: grid;
+ grid-template-areas:
+ "main right-handle right"
+ "bottom-handle right-handle right"
+ "bottom right-handle right";
+ grid-template-columns: minmax(0, 1fr) 0 auto;
+ grid-template-rows: minmax(0, 1fr) 0 auto;
+ flex: 1 1 auto;
+ height: auto;
+ min-width: 0;
+ min-height: 0;
+}
+
+.maka-detail-with-artifacts > .mainColumn {
+ grid-area: main;
+ min-width: 0;
+ min-height: 0;
+}
+
+.maka-workbar-layout-vars,
+.maka-workbar-workspace-contents {
+ display: contents;
+}
+
+.maka-session-workbar {
+ min-height: 0;
+ overflow: hidden;
+ display: grid;
+ grid-template-rows: var(--maka-plate-titlebar-clearance) minmax(0, 1fr);
+ /* Plate, on the same terms as the conversation beside it: same surface and
+ same corner. The right workbar's tab toolbar owns the shared titlebar band
+ instead of starting below it, so tabs and the panel toggle form one row. */
+ background: var(--agents-content-area-bg);
+ border-radius: var(--radius-modal);
+ box-sizing: border-box;
+}
+
+.maka-session-workbar[data-placement="right"] {
+ grid-area: right;
+ width: var(--maka-session-workbar-width, 480px);
+ min-width: 320px;
+ max-width: 600px;
+ margin-left: var(--agents-content-area-gap);
+}
+
+.maka-session-workbar[data-placement="bottom"] {
+ grid-area: bottom;
+ width: 100%;
+ height: var(--maka-session-bottom-panel-height, 300px);
+ min-height: 180px;
+ max-height: 520px;
+ margin-top: var(--agents-content-area-gap);
+ grid-template-rows: auto minmax(0, 1fr);
+}
+
+.maka-session-workbar[data-collapsed] {
+ display: none;
+}
+
+.maka-workbar-resize-handle-right {
+ grid-area: right-handle;
+}
+
+.maka-workbar-resize-handle-bottom {
+ grid-area: bottom-handle;
+}
+
+.maka-session-workbar-panel[data-overlay] {
+ position: relative;
+ z-index: 1;
+ overflow: hidden;
+ background: var(--agents-content-area-bg);
+ border-radius: var(--radius-modal);
+ box-sizing: border-box;
+}
+
+.maka-session-workbar-panel[data-overlay][data-placement="right"] {
+ grid-area: right;
+ width: var(--maka-session-workbar-width, 480px);
Review Comment:
Fixed, thanks @Astro-Han
--
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] refactor(desktop): extract Workbar as a feature slice [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3444:
URL: https://github.com/apache/maka/pull/3444#discussion_r3835665408
##########
apps/desktop/src/renderer/features/workbar/controller/use-workbar-controller.ts:
##########
@@ -0,0 +1,707 @@
+import {
+ useCallback,
+ useEffect,
+ useLayoutEffect,
+ useMemo,
+ useRef,
+ useState,
+ type ComponentProps,
+} from 'react';
+import type { QuoteRef } from '@maka/core/events';
+import type { SessionSummary } from '@maka/core/session';
+import type { ChatModelChoice, Composer } from '@maka/ui';
+import { useUiLocale } from '@maka/ui';
+import { safeLocalStorageGet, safeLocalStorageSet } from '../../../browser-storage.js';
+import { getDesktopConversationCopy } from '../../../locales/conversation-copy.js';
+import { localizedShellErrorMessage } from '../../../locales/shell-copy.js';
+import { sideChatTitleFromPrompt } from '../../../side-chat-command.js';
+import { useWorkbarServices } from '../services-context.js';
+import type { WorkbarHostModel } from '../ui/workbar-host.js';
+import { SKIP_SIDE_CHAT_CLOSE_CONFIRMATION_KEY } from '../ui/side-chat-close-confirmation.js';
+import {
+ findPreferredSideChatWorkbarTab,
+ reduceWorkbarPanels,
+ terminalRefFromWorkbarTab,
+ terminalSessionWorkbarTabId,
+ type SessionWorkbarPlacement,
+ type SessionWorkbarPanelsState,
+ type SessionWorkbarTab,
+ type SessionWorkbarTabKind,
+} from '../model/workbar-tabs.js';
+import { workbarToolDefinition } from '../model/workbar-tool-definitions.js';
+import {
+ consumeCompanionInitialPrompt,
+ consumeCompanionQuoteSnapshot,
+ openCompanionPanel,
+ removeStagedCompanionQuote,
+ stageCompanionQuote,
+} from '../tools/side-chat/quote-companion-panel-state.js';
+import {
+ applyCompanionForkVisibilityEvent,
+ reconcileCompanionForkVisibility,
+} from '../tools/side-chat/quote-companion-visibility.js';
+import { recoverOrphanedCompanionCopies } from '../tools/side-chat/quote-companion-core.js';
+import { useSideConversationWorkspace } from '../tools/side-chat/use-side-conversation-workspace.js';
+import { useWorkbarLayoutState } from './use-workbar-layout-state.js';
+
+interface OpenToolOptions {
+ initialPrompt?: string;
+}
+
+export interface WorkbarControllerCommands {
+ openTool(
+ kind: SessionWorkbarTabKind,
+ placement?: SessionWorkbarPlacement,
+ options?: OpenToolOptions,
+ ): void;
+ openSideChatWithQuote(quote: QuoteRef): void;
+ toggleRight(): void;
+}
+
+export interface WorkbarControllerSelectors {
+ rightCollapsed: boolean;
+ hiddenSessionIds: ReadonlySet<string>;
+}
+
+export interface UseWorkbarControllerInput {
+ /** Whether the Session workspace (rather than a module page) owns the shell. */
+ available: boolean;
+ activeSession: SessionSummary | undefined;
+ authoritativeSessionIds: ReadonlySet<string> | undefined;
+ shellObscured: boolean;
+ modelChoices: readonly ChatModelChoice[];
+ mentionSkills?: ComponentProps<typeof Composer>['mentionSkills'];
+ searchMentionFiles?: ComponentProps<typeof Composer>['onSearchMentionFiles'];
+ reportError(title: string, description: string, sessionId: string): void;
+}
+
+export interface WorkbarController {
+ host: WorkbarHostModel;
+ commands: WorkbarControllerCommands;
+ selectors: WorkbarControllerSelectors;
+}
+
+function assertNever(value: never): never {
+ throw new Error(`Unexpected Workbar tool: ${JSON.stringify(value)}`);
+}
+
+function nextOrdinal(
+ tabs: readonly SessionWorkbarTab[],
+ kind: 'side-chat' | 'terminal',
+): number {
+ return (
+ tabs.reduce(
+ (highest, tab, index) =>
+ tab.kind === kind
+ ? Math.max(highest, tab.ordinal ?? index + 1)
+ : highest,
+ 0,
+ ) + 1
+ );
+}
+
+function terminalResourceKey(sessionId: string, ref: string): string {
+ return `${sessionId}\u0000${ref}`;
+}
+
+function projectWorkbarPanelsForSession(
+ panels: SessionWorkbarPanelsState,
+ activeSessionId: string | undefined,
+ activeSideChatTabIds: ReadonlySet<string>,
+): SessionWorkbarPanelsState {
+ let projected = panels;
+ for (const placement of ['right', 'bottom'] as const) {
+ const staleTabIds = projected[placement].tabs
+ .filter(
+ (tab) =>
+ (tab.kind === 'terminal' &&
+ tab.ownerSessionId !== activeSessionId) ||
+ (tab.kind === 'side-chat' && !activeSideChatTabIds.has(tab.id)),
+ )
+ .map((tab) => tab.id);
+ if (staleTabIds.length > 0) {
+ projected = reduceWorkbarPanels(projected, {
+ type: 'close',
+ placement,
+ tabIds: staleTabIds,
+ });
+ }
+ }
+ return projected;
+}
+
+export function useWorkbarController(
+ input: UseWorkbarControllerInput,
+): WorkbarController {
+ const locale = useUiLocale();
+ const terminalCopy = getDesktopConversationCopy(locale).terminalPanel;
+ const { browser, sideChat, terminal } = useWorkbarServices();
+ const layout = useWorkbarLayoutState();
+ const sideConversations = useSideConversationWorkspace();
+ const [pendingSideChatClose, setPendingSideChatClose] = useState<
+ Array<{ placement: SessionWorkbarPlacement; tab: SessionWorkbarTab }>
+ >([]);
+ const [skipSideChatCloseConfirmation, setSkipSideChatCloseConfirmation] =
+ useState(
+ () =>
+ safeLocalStorageGet(SKIP_SIDE_CHAT_CLOSE_CONFIRMATION_KEY) === 'true',
+ );
+ const [hiddenCompanionForkIds, setHiddenCompanionForkIds] = useState<
+ ReadonlySet<string>
+ >(() => new Set());
+ const [, setLiveBrowserSessionIds] = useState<readonly string[]>([]);
+
+ const activeSessionId = input.activeSession?.id;
+ const activeSessionIdRef = useRef<string | undefined>(undefined);
+ const resourceGenerationRef = useRef(0);
+ useLayoutEffect(() => {
+ resourceGenerationRef.current += 1;
+ activeSessionIdRef.current = activeSessionId;
+ return () => {
+ resourceGenerationRef.current += 1;
+ activeSessionIdRef.current = undefined;
+ };
+ }, [activeSessionId]);
+ const panelsStateRef = useRef(layout.workbarPanelsState);
+ useLayoutEffect(() => {
+ panelsStateRef.current = layout.workbarPanelsState;
+ }, [layout.workbarPanelsState]);
+ const reservedOrdinalsRef = useRef({
+ 'side-chat': new Set<number>(),
+ terminal: new Set<number>(),
+ });
+ useLayoutEffect(() => {
+ reservedOrdinalsRef.current['side-chat'].clear();
+ reservedOrdinalsRef.current.terminal.clear();
+ }, [layout.workbarPanelsState]);
+ const stoppedTerminalKeysRef = useRef(new Set<string>());
+ const ownedTerminalResourcesRef = useRef(
+ new Map<string, { sessionId: string; ref: string }>(),
+ );
+
+ const stopTerminal = useCallback(
+ (sessionId: string, ref: string) => {
+ const key = terminalResourceKey(sessionId, ref);
+ if (stoppedTerminalKeysRef.current.has(key)) return;
+ stoppedTerminalKeysRef.current.add(key);
+ ownedTerminalResourcesRef.current.delete(key);
+ void terminal.stop({ sessionId, ref }).catch(() => undefined);
Review Comment:
[P2] This marks the resource stopped and removes ownership before `terminal.stop()` succeeds, then swallows rejection. On a reasonable Host disconnect/IPC failure, the remote shell can keep running while the tab and only cleanup ownership are gone; later cleanup will not retry because the key is already in `stoppedTerminalKeysRef`. Could we keep a pending-stop ownership entry until success (or hand it to a main-process retry authority), and add a stop-rejection test that proves cleanup remains retryable?
--
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] refactor(desktop): extract Workbar as a feature slice [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3444:
URL: https://github.com/apache/maka/pull/3444#discussion_r3835559276
##########
apps/desktop/src/renderer/styles/workbar/shell.css:
##########
@@ -0,0 +1,311 @@
+/* Chat detail surface — unified session workbar + turn search-highlight +
+ session-branch banner. Relocated from settings/models.css (was misplaced in the
+ model-catalog file) — issue #546 PR1, zero visual change. */
+/* ──────────────────────────────────────────────────────────────────────── */
+/* SessionWorkbar — resizable Tasks / Browser / Files auxiliary workspace. */
+/* The shell owns its visibility and width; tab contents fill this surface. */
+/* ──────────────────────────────────────────────────────────────────────── */
+
+.maka-detail-with-artifacts {
+ display: grid;
+ grid-template-areas:
+ "main right-handle right"
+ "bottom-handle right-handle right"
+ "bottom right-handle right";
+ grid-template-columns: minmax(0, 1fr) 0 auto;
+ grid-template-rows: minmax(0, 1fr) 0 auto;
+ flex: 1 1 auto;
+ height: auto;
+ min-width: 0;
+ min-height: 0;
+}
+
+.maka-detail-with-artifacts > .mainColumn {
+ grid-area: main;
+ min-width: 0;
+ min-height: 0;
+}
+
+.maka-workbar-layout-vars,
+.maka-workbar-workspace-contents {
+ display: contents;
+}
+
+.maka-session-workbar {
+ min-height: 0;
+ overflow: hidden;
+ display: grid;
+ grid-template-rows: var(--maka-plate-titlebar-clearance) minmax(0, 1fr);
+ /* Plate, on the same terms as the conversation beside it: same surface and
+ same corner. The right workbar's tab toolbar owns the shared titlebar band
+ instead of starting below it, so tabs and the panel toggle form one row. */
+ background: var(--agents-content-area-bg);
+ border-radius: var(--radius-modal);
+ box-sizing: border-box;
+}
+
+.maka-session-workbar[data-placement="right"] {
+ grid-area: right;
+ width: var(--maka-session-workbar-width, 480px);
+ min-width: 320px;
+ max-width: 600px;
+ margin-left: var(--agents-content-area-gap);
+}
+
+.maka-session-workbar[data-placement="bottom"] {
+ grid-area: bottom;
+ width: 100%;
+ height: var(--maka-session-bottom-panel-height, 300px);
+ min-height: 180px;
+ max-height: 520px;
+ margin-top: var(--agents-content-area-gap);
+ grid-template-rows: auto minmax(0, 1fr);
+}
+
+.maka-session-workbar[data-collapsed] {
+ display: none;
+}
+
+.maka-workbar-resize-handle-right {
+ grid-area: right-handle;
+}
+
+.maka-workbar-resize-handle-bottom {
+ grid-area: bottom-handle;
+}
+
+.maka-session-workbar-panel[data-overlay] {
+ position: relative;
+ z-index: 1;
+ overflow: hidden;
+ background: var(--agents-content-area-bg);
+ border-radius: var(--radius-modal);
+ box-sizing: border-box;
+}
+
+.maka-session-workbar-panel[data-overlay][data-placement="right"] {
+ grid-area: right;
+ width: var(--maka-session-workbar-width, 480px);
Review Comment:
[P2] Thanks for preserving the overlay width rule during the CSS move. The narrow-layout E2E currently writes `--maka-session-workbar-width` on `.maka-session-workbar`, but this overlay is its sibling and reads the variable from their shared `.maka-workbar-layout-vars` ancestor. Its second resize therefore still targets the Workbar frame, so the side-chat assertion can pass at the default width without exercising the reported 320px case. Could we set the variable on the shared layout owner, or resize the overlay directly, and assert its bounding box is actually 320px before checking the send button?
--
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] refactor(desktop): extract Workbar as a feature slice [maka]
Posted by "chihumyum (via GitHub)" <gi...@apache.org>.
chihumyum commented on code in PR #3444:
URL: https://github.com/apache/maka/pull/3444#discussion_r3835775886
##########
apps/desktop/src/renderer/features/workbar/controller/use-workbar-controller.ts:
##########
@@ -0,0 +1,707 @@
+import {
+ useCallback,
+ useEffect,
+ useLayoutEffect,
+ useMemo,
+ useRef,
+ useState,
+ type ComponentProps,
+} from 'react';
+import type { QuoteRef } from '@maka/core/events';
+import type { SessionSummary } from '@maka/core/session';
+import type { ChatModelChoice, Composer } from '@maka/ui';
+import { useUiLocale } from '@maka/ui';
+import { safeLocalStorageGet, safeLocalStorageSet } from '../../../browser-storage.js';
+import { getDesktopConversationCopy } from '../../../locales/conversation-copy.js';
+import { localizedShellErrorMessage } from '../../../locales/shell-copy.js';
+import { sideChatTitleFromPrompt } from '../../../side-chat-command.js';
+import { useWorkbarServices } from '../services-context.js';
+import type { WorkbarHostModel } from '../ui/workbar-host.js';
+import { SKIP_SIDE_CHAT_CLOSE_CONFIRMATION_KEY } from '../ui/side-chat-close-confirmation.js';
+import {
+ findPreferredSideChatWorkbarTab,
+ reduceWorkbarPanels,
+ terminalRefFromWorkbarTab,
+ terminalSessionWorkbarTabId,
+ type SessionWorkbarPlacement,
+ type SessionWorkbarPanelsState,
+ type SessionWorkbarTab,
+ type SessionWorkbarTabKind,
+} from '../model/workbar-tabs.js';
+import { workbarToolDefinition } from '../model/workbar-tool-definitions.js';
+import {
+ consumeCompanionInitialPrompt,
+ consumeCompanionQuoteSnapshot,
+ openCompanionPanel,
+ removeStagedCompanionQuote,
+ stageCompanionQuote,
+} from '../tools/side-chat/quote-companion-panel-state.js';
+import {
+ applyCompanionForkVisibilityEvent,
+ reconcileCompanionForkVisibility,
+} from '../tools/side-chat/quote-companion-visibility.js';
+import { recoverOrphanedCompanionCopies } from '../tools/side-chat/quote-companion-core.js';
+import { useSideConversationWorkspace } from '../tools/side-chat/use-side-conversation-workspace.js';
+import { useWorkbarLayoutState } from './use-workbar-layout-state.js';
+
+interface OpenToolOptions {
+ initialPrompt?: string;
+}
+
+export interface WorkbarControllerCommands {
+ openTool(
+ kind: SessionWorkbarTabKind,
+ placement?: SessionWorkbarPlacement,
+ options?: OpenToolOptions,
+ ): void;
+ openSideChatWithQuote(quote: QuoteRef): void;
+ toggleRight(): void;
+}
+
+export interface WorkbarControllerSelectors {
+ rightCollapsed: boolean;
+ hiddenSessionIds: ReadonlySet<string>;
+}
+
+export interface UseWorkbarControllerInput {
+ /** Whether the Session workspace (rather than a module page) owns the shell. */
+ available: boolean;
+ activeSession: SessionSummary | undefined;
+ authoritativeSessionIds: ReadonlySet<string> | undefined;
+ shellObscured: boolean;
+ modelChoices: readonly ChatModelChoice[];
+ mentionSkills?: ComponentProps<typeof Composer>['mentionSkills'];
+ searchMentionFiles?: ComponentProps<typeof Composer>['onSearchMentionFiles'];
+ reportError(title: string, description: string, sessionId: string): void;
+}
+
+export interface WorkbarController {
+ host: WorkbarHostModel;
+ commands: WorkbarControllerCommands;
+ selectors: WorkbarControllerSelectors;
+}
+
+function assertNever(value: never): never {
+ throw new Error(`Unexpected Workbar tool: ${JSON.stringify(value)}`);
+}
+
+function nextOrdinal(
+ tabs: readonly SessionWorkbarTab[],
+ kind: 'side-chat' | 'terminal',
+): number {
+ return (
+ tabs.reduce(
+ (highest, tab, index) =>
+ tab.kind === kind
+ ? Math.max(highest, tab.ordinal ?? index + 1)
+ : highest,
+ 0,
+ ) + 1
+ );
+}
+
+function terminalResourceKey(sessionId: string, ref: string): string {
+ return `${sessionId}\u0000${ref}`;
+}
+
+function projectWorkbarPanelsForSession(
+ panels: SessionWorkbarPanelsState,
+ activeSessionId: string | undefined,
+ activeSideChatTabIds: ReadonlySet<string>,
+): SessionWorkbarPanelsState {
+ let projected = panels;
+ for (const placement of ['right', 'bottom'] as const) {
+ const staleTabIds = projected[placement].tabs
+ .filter(
+ (tab) =>
+ (tab.kind === 'terminal' &&
+ tab.ownerSessionId !== activeSessionId) ||
+ (tab.kind === 'side-chat' && !activeSideChatTabIds.has(tab.id)),
+ )
+ .map((tab) => tab.id);
+ if (staleTabIds.length > 0) {
+ projected = reduceWorkbarPanels(projected, {
+ type: 'close',
+ placement,
+ tabIds: staleTabIds,
+ });
+ }
+ }
+ return projected;
+}
+
+export function useWorkbarController(
+ input: UseWorkbarControllerInput,
+): WorkbarController {
+ const locale = useUiLocale();
+ const terminalCopy = getDesktopConversationCopy(locale).terminalPanel;
+ const { browser, sideChat, terminal } = useWorkbarServices();
+ const layout = useWorkbarLayoutState();
+ const sideConversations = useSideConversationWorkspace();
+ const [pendingSideChatClose, setPendingSideChatClose] = useState<
+ Array<{ placement: SessionWorkbarPlacement; tab: SessionWorkbarTab }>
+ >([]);
+ const [skipSideChatCloseConfirmation, setSkipSideChatCloseConfirmation] =
+ useState(
+ () =>
+ safeLocalStorageGet(SKIP_SIDE_CHAT_CLOSE_CONFIRMATION_KEY) === 'true',
+ );
+ const [hiddenCompanionForkIds, setHiddenCompanionForkIds] = useState<
+ ReadonlySet<string>
+ >(() => new Set());
+ const [, setLiveBrowserSessionIds] = useState<readonly string[]>([]);
+
+ const activeSessionId = input.activeSession?.id;
+ const activeSessionIdRef = useRef<string | undefined>(undefined);
+ const resourceGenerationRef = useRef(0);
+ useLayoutEffect(() => {
+ resourceGenerationRef.current += 1;
+ activeSessionIdRef.current = activeSessionId;
+ return () => {
+ resourceGenerationRef.current += 1;
+ activeSessionIdRef.current = undefined;
+ };
+ }, [activeSessionId]);
+ const panelsStateRef = useRef(layout.workbarPanelsState);
+ useLayoutEffect(() => {
+ panelsStateRef.current = layout.workbarPanelsState;
+ }, [layout.workbarPanelsState]);
+ const reservedOrdinalsRef = useRef({
+ 'side-chat': new Set<number>(),
+ terminal: new Set<number>(),
+ });
+ useLayoutEffect(() => {
+ reservedOrdinalsRef.current['side-chat'].clear();
+ reservedOrdinalsRef.current.terminal.clear();
+ }, [layout.workbarPanelsState]);
+ const stoppedTerminalKeysRef = useRef(new Set<string>());
+ const ownedTerminalResourcesRef = useRef(
+ new Map<string, { sessionId: string; ref: string }>(),
+ );
+
+ const stopTerminal = useCallback(
+ (sessionId: string, ref: string) => {
+ const key = terminalResourceKey(sessionId, ref);
+ if (stoppedTerminalKeysRef.current.has(key)) return;
+ stoppedTerminalKeysRef.current.add(key);
+ ownedTerminalResourcesRef.current.delete(key);
+ void terminal.stop({ sessionId, ref }).catch(() => undefined);
Review Comment:
Fixed in 9211905ca. Terminal cleanup now keeps ownership while stop is in flight, records completion only after success, and clears the in-flight marker on rejection so a later Session cleanup can retry. Added a controller regression test covering first-stop rejection followed by a successful retry. I also rebased onto upstream/main f83b469b5 and resolved the CSS move conflict while preserving the upstream chat-radius behavior. Local verification passed: full build, full typecheck, 36 directed tests, and 6/6 Electron Workbar E2E. @Astro-Han, could you please take another look?
--
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] refactor(desktop): extract Workbar as a feature slice [maka]
Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #3444:
URL: https://github.com/apache/maka/pull/3444
--
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