SidePaneTerminalPane.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { useCallback } from "react";
  2. import type { IServiceAccessor } from "@zcode/services";
  3. import { TerminalSession } from "@/terminal/TerminalSession.js";
  4. export function SidePaneTerminalPane({
  5. services,
  6. sessionId,
  7. workspaceKey,
  8. cwd,
  9. isVisible,
  10. isWindowsDesktop = false,
  11. onOpenBrowserUrl,
  12. }: {
  13. services: IServiceAccessor;
  14. /**
  15. * 保活:sessionId 复用 tab.id(跨 workspace 稳定),同时作为 TerminalSession 的 persistentKey。
  16. * 让 xterm+PTY 所有权进 sidePaneTerminalSessionRegistry 模块级单例,
  17. * 组件卸载只 detach、不 dispose;重挂按 key 复用,scrollback 跨 workspace 保活。
  18. */
  19. sessionId: string;
  20. /**
  21. * workspace 身份隔离 key(= workspaceIdentity?.trim() || workspacePath)。
  22. * 写入 registry entry.workspaceKey,workspace tab 关闭时按此批量回收 PTY。
  23. */
  24. workspaceKey?: string;
  25. cwd?: string;
  26. isVisible: boolean;
  27. isWindowsDesktop?: boolean;
  28. onOpenBrowserUrl: (url: string) => void;
  29. }) {
  30. const handleShellLabelChange = useCallback(() => {
  31. // 业务说明:side pane 外层 tab 已经承载终端标题,这里只需要单个 shell 实例,
  32. // 不再显示或同步第二层 terminal tab 标题,避免形成嵌套 tabs。
  33. }, []);
  34. return (
  35. <section className="h-full min-h-0 overflow-hidden bg-background p-3">
  36. <TerminalSession
  37. sessionId={sessionId}
  38. persistentKey={sessionId}
  39. workspaceKey={workspaceKey}
  40. services={services}
  41. cwd={cwd}
  42. isVisible={isVisible}
  43. isWindowsDesktop={isWindowsDesktop}
  44. onShellLabelChange={handleShellLabelChange}
  45. onOpenBrowserUrl={onOpenBrowserUrl}
  46. />
  47. </section>
  48. );
  49. }