Fix detached-window IPC scoping and pane-transfer session loss
- capabilities/default.json: extend window scope to "pane-window-*" so detached windows can invoke/listen (fixes blank panes B2-B5). - App.tsx: memoize the destructive take_pending_window_init read at module scope so React StrictMode's double mount-effect doesn't consume the transfer payload twice and lose the adopted PTY session. - lib.rs: add `use tauri::Manager;` for Window::app_handle() in on_window_event. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
681d15fdc3
commit
bea6cf2977
4 changed files with 54 additions and 2 deletions
18
src/App.tsx
18
src/App.tsx
|
|
@ -42,6 +42,22 @@ const MAIN_WINDOW_LABEL = "main";
|
|||
* this window's state to the cross-window aggregator. */
|
||||
const CURRENT_WINDOW_LABEL = getCurrentWebviewWindow().label;
|
||||
const IS_MAIN_WINDOW = CURRENT_WINDOW_LABEL === MAIN_WINDOW_LABEL;
|
||||
|
||||
/** `take_pending_window_init` is a DESTRUCTIVE backend read (it removes the
|
||||
* entry). React StrictMode runs the mount effect twice in dev, so a plain
|
||||
* call would consume the payload on the first (cancelled) pass and hand the
|
||||
* second pass `null` — booting a fresh "Default" workspace and spawning a new
|
||||
* PTY instead of adopting the transferred one (session lost). Memoize the
|
||||
* promise at module scope so the backend take happens exactly once per window
|
||||
* and every effect pass awaits the same result. */
|
||||
let pendingInitOnce: Promise<Awaited<ReturnType<typeof takePendingWindowInit>>> | null =
|
||||
null;
|
||||
const consumePendingWindowInit = () => {
|
||||
if (!pendingInitOnce) {
|
||||
pendingInitOnce = takePendingWindowInit(CURRENT_WINDOW_LABEL);
|
||||
}
|
||||
return pendingInitOnce;
|
||||
};
|
||||
import {
|
||||
type TreeNode,
|
||||
type NodeId,
|
||||
|
|
@ -263,7 +279,7 @@ export default function App() {
|
|||
|
||||
if (!IS_MAIN_WINDOW) {
|
||||
try {
|
||||
const pending = await takePendingWindowInit(CURRENT_WINDOW_LABEL);
|
||||
const pending = await consumePendingWindowInit();
|
||||
if (pending) {
|
||||
try {
|
||||
const adoptedLeaf = JSON.parse(pending.leafJson) as LeafNode;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue