You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "Phoenix500526 (via GitHub)" <gi...@apache.org> on 2026/09/02 13:08:25 UTC
[PR] fix(desktop): treat teardown as cancellation [maka]
Phoenix500526 opened a new pull request, #4562:
URL: https://github.com/apache/maka/pull/4562
## Summary
Pending Session and transcript observations rejected their readiness promises
when the renderer intentionally released them during startup. Those expected
teardowns escaped the Electron IPC handlers as errors.
Distinguish caller-initiated cancellation from genuine initialization failure,
then carry an explicit `ready` or `cancelled` result across the Main/Preload IPC
boundary. Preload now stops cancelled listeners without reporting a Session as
seeded or reading a missing transcript result. Genuine seed and transcript-open
failures continue to reject unchanged.
Fixes #4434
## Verification
- `npm --workspace @maka/desktop run typecheck`
- `npm --workspace @maka/desktop run build:test`
- Related Session observation and IPC suites: 68 passed
- Session observation release suite: 1 passed
- `npm --workspace @maka/desktop run check:architecture`: 71 fixture tests
passed and the renderer architecture check passed
- Biome and diff checks passed for all changed files
- Manual Edit & resend/reset reproduction no longer prints the pending
observation handler errors
## AI use
Select exactly one:
- [ ] No generative tool made a substantive contribution
- [x] Generative tooling made a substantive contribution
Tool(s) and scope: OpenAI Codex implemented the cancellation contract and
regression tests, then reviewed and verified the resulting diff.
## 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
--
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] fix(desktop): treat teardown as cancellation [maka]
Posted by "Phoenix500526 (via GitHub)" <gi...@apache.org>.
Phoenix500526 commented on PR #4562:
URL: https://github.com/apache/maka/pull/4562#issuecomment-5552837272
Thanks @Astro-Han for flagging the synchronization assumption in the cancellation tests. I updated both tests to wait for an explicit initialization-start signal and hold initialization on a separate deferred promise. They now confirm the registration exists, cancel it while initialization is still pending, verify the registration was removed, and then release initialization and check the cancelled result.
The previous microtask ordering is deterministic in the current implementation; we have not established that these two tests are flaky. However, given the flaky tests we have encountered elsewhere, I would rather make the synchronization explicit now. Adding another asynchronous step before registration could invalidate the assumption that one microtask yield is enough. Waiting for the actual initialization signal makes the tests independent of that detail.
This only changes the tests; production code is unchanged. The Desktop main build, all 30 tests in the affected IPC test file, and Biome checks passed locally.
--
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] fix(desktop): treat teardown as cancellation [maka]
Posted by "Phoenix500526 (via GitHub)" <gi...@apache.org>.
Phoenix500526 commented on PR #4562:
URL: https://github.com/apache/maka/pull/4562#issuecomment-5578568006
> Reviewed at [ee49e8d](https://github.com/apache/maka/commit/ee49e8d0f5f7952d0ae884232f9fa87a90873707) against `main` (`a03dd577bb`), +254/−33, prod +117/−33, test +137.
>
> The problem in #4434 is real on `main`: `observe()` returns `registration.ready.promise` (`runtime-host-session-observation-registry.ts:315`) and `#deleteRegistration` rejects it unconditionally, so tearing down a not-yet-ready observation makes `ipcMain.handle('sessions:observe')` reject and Electron logs "Error occurred in handler". But the consequence stops there: the preload's dispose closure sets `disposed = true` and `onSeedError` is guarded by `!disposed` (`preload.ts:2290-2298` on `main`), so the user never sees it. What this PR buys is one less spurious stderr line in dev builds, which is worth having because it hides real handler errors, but it is a small win and the shape has to stay small and not regress anything.
>
> The envelope in `apps/desktop/src/shared/` is the right seam (both sides of the IPC change together, `work-board-ipc.ts` is the precedent, and `observe` cannot distinguish cancelled from ready without a value), and the tests go through the production handler and would reject on `main`. One P2 in how far "cancellation" was applied.
>
> **P2 (path ②): `forgetSession` and `close()` now report cancellation too, and the renderer goes deaf.** `#cancelRegistration` / `#cancelTranscript` are called from `#remove` (caller-initiated, correct) but also from `forgetSession` (`:242-245`, a guest Session no longer shared, right before `emitSessionsChanged('deleted')`) and `close()` (`:443-446`, connection closed or candidate destroyed). Those are not the caller cancelling; the Session or the connection went away. The preload's `cancelled` branch (`preload.ts:2299-2303`) sets `disposed`, unsubscribes, and calls neither `onSeeded` nor `onSeedError`, so a consumer waiting on readiness never settles: `use-quote-companion.ts` keeps `subscriptionReadyRef` pending, and a side-chat send stays optimistic until the panel is closed, where `main` today goes through `onSeedError`, rejects, shows the send failure and resubscribes. Smallest fix: only `#remove` (unobserve / target destroyed) is a cancellation; `forgetSession` and `close
()` keep the error path. The four tests and the #4434 reproduction all go through `unobserve` / `closeTranscript`, so nothing else moves.
>
> P3:
>
> * Desktop IPC result envelopes now come in two shapes, `{ ok: true | false }` (`ExternalSessionImportIpcResult`) and `{ kind: 'ready' | 'cancelled' }`. Not for this PR to unify, but the next one should not add a third.
> * The sentence "ended before it became ready" is now the message of both the plain `Error` and `RuntimeHostObservationCancelledError`; the issue itself asks not to distinguish by string, so give the two different text.
>
> Evidence boundary: static read against `main`; the side-chat hang is traced through the preload branch and `subscriptionReadyRef`, not reproduced; the teardown race was not run on a Desktop.
>
> AI-assisted review: drafted with Maka; I verified the `forgetSession` / `close()` call sites and the preload branch myself.
Done
--
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] fix(desktop): treat teardown as cancellation [maka]
Posted by "me2seeks (via GitHub)" <gi...@apache.org>.
me2seeks merged PR #4562:
URL: https://github.com/apache/maka/pull/4562
--
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] fix(desktop): treat teardown as cancellation [maka]
Posted by "Phoenix500526 (via GitHub)" <gi...@apache.org>.
Phoenix500526 commented on PR #4562:
URL: https://github.com/apache/maka/pull/4562#issuecomment-5631935760
> ### Automated review (Command Code) — not an approval
> The classification itself is sound: the new predicate is a dedicated error class (not a string match, as issue #4434 required), it can only be constructed on the two teardown paths, and genuine failures still re-throw. The earlier concern about `forgetSession`/`close()` is fixed in the follow-up commit. The problem is the base.
>
> **P1 (Must-Fix) — this branch conflicts with a fix already on `main`, and the two disagree about what teardown means.**
>
> The PR targets an older base and changes the same statement that `main` has already changed. On `main`, `#remove` completes the abandoned read as an **empty success**:
>
> ```ts
> // origin/main:apps/desktop/src/main/runtime-host-session-observation-registry.ts:504-505
> registration.ready.resolve([]);
> this.#deleteRegistration(observerId, registration);
> ```
>
> The PR replaces that with a cancellation:
>
> ```ts
> // review-pr4562:.../runtime-host-session-observation-registry.ts:474
> this.#cancelRegistration(observerId, registration);
> ```
>
> Verified: `git merge-tree --write-tree origin/main review-pr4562` exits 1 with content conflicts in `runtime-host-session-observation-registry.ts`, `runtime-host-session-execution-ipc-main.ts`, its test, and `preload.ts`.
>
> This is not a mechanical rebase, because the two resolutions mean different things to the consumer: `main`'s empty-success leaves the preload path calling `onSeeded`, while the PR's `cancelled` envelope sets `disposed`, unsubscribes, and never calls `onSeeded`. The PR is the more deliberate design and the linked issue asks for it, but the reconciliation is a behavior decision, not a merge conflict to resolve reflexively.
>
> Smallest sound fix: rebase onto current `main`, deliberately drop or keep `#remove`'s `resolve([])`, and re-run the new tests — they should fail against `main`'s line, which is the point of the change.
>
> **P2 (Should-Fix) — the half of the contract that actually consumes `cancelled` is untested.**
>
> The two new branches that read the envelope — `preload.ts` observe (`disposed = true`, unsubscribe, no `onSeeded`) and the transcript path (throw) — have no coverage. The only preload test in the diff was re-fixtured to return the envelope on the happy path; every new assertion is at the registry/IPC-main layer. Since #4434 was user-visible through the preload surface, a regression there would ship green. Add one preload-level case that returns `{kind:'cancelled'}` from `sessions:observe` and asserts no seed callback fires and listeners are removed.
>
> **P3 (Nice-to-have) — the cancelled error reuses the ordinary failure message.** `RuntimeHostObservationCancelledError` is constructed with the same text as the plain `Error` on the non-teardown path, so any log that prints the message cannot distinguish a teardown from a real failure — the exact ambiguity #4434 was about. `instanceof` is correct; give the cancelled class its own message.
>
> **Review-relevant risks.** Internal Desktop main↔preload IPC contract; no security, licensing, release or governance effect identified. The rebase resolution changes user-visible behavior (Edit & resend after a teardown), so a maintainer should settle the semantics.
>
> **Required conclusion.**
>
> 1. Optimal for the actual problem? The classification design is right, but as an artifact this is not mergeable: it is based on a stale `main` and must reconcile with the fix `main` already shipped for the same event.
> 2. Production code that can be deleted? `none identified` in the PR itself. Note that if it lands, `main`'s `resolve([])` line goes away — that is the reconciliation, not dead code.
> 3. Low-quality tests to delete or replace? The preload test edit is fixture alignment only and adds no confidence; replace it with a real cancelled-path assertion.
> 4. Deeper refactor required? No. The envelope at the IPC seam matches existing precedent for this boundary. One caution for follow-ups: the Desktop IPC result envelope now has two shapes (`{ok}` and `{kind}`) — do not add a third.
> 5. Ready to merge? No. It does not apply cleanly to `origin/main`, and the preload contract consumption is untested.
> 6. Residual risks / verification gaps: I did not run the Desktop suite or reproduce #4434 end-to-end; the conflict is verified with `git merge-tree` and the semantic divergence by reading both revisions. A genuine source failure that lands _after_ teardown is still dropped rather than reported (pre-existing).
>
> **Approval boundary.** This is automated review; it is not an approval. Per `CONTRIBUTING.md`, the merge decision requires an independent human review. No approve was submitted.
Done
--
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