Repository navigation
Commit e2f0dd3
committed
feat(mcode-island): pill click toggles show / hide CLI window (round-14)
Previously the pill's MouseLeftButtonUp always invoked Focus-CallerWindow,
which only ever restored + foregrounded the target window. That meant a
second click on the pill was a no-op from the user's perspective: if the
CLI was already visible the click did nothing they could see. The mental
model "单击调出, 单击收起" was not honored.
This commit extracts the caller-target resolution into a shared helper
(Resolve-CallerWindow) and adds Toggle-CallerWindow, which gates on
IsWindowVisible + IsIconic:
shown + no -> SW_MINIMIZE (click hides; taskbar entry kept)
hidden/min -> SW_RESTORE + (click shows; SetForegroundWindow
SetForegroundWindow steals focus)
The click handler now calls Toggle-CallerWindow instead of
Focus-CallerWindow. Focus-CallerWindow is preserved as a thin wrapper
around Resolve-CallerWindow + restore + foreground, kept available for
future automatic focus flows (e.g. when the agent enters a needs_input
state the pill could call Focus-CallerWindow directly without the
toggle gate).
## Design
Toggle, not flip-and-stick: every click cycles show -> hide -> show.
The user's "单击调出, 单击收起" requirement is the mental model.
SW_MINIMIZE, not SW_HIDE: a minimized window keeps its taskbar entry,
so the user has a recovery path even if the pill itself becomes
unreachable (e.g. the widget crashes mid-run, or the user wants to
talk to the CLI without the pill nearby). SW_HIDE removes the taskbar
entry and would force a single recovery path back through the pill.
Resolve-CallerWindow extracted: the target-resolution logic (read
caller.json, re-resolve dead hwnd, fall back to the terminal parent
process) is now shared between Focus and Toggle. Both call sites used
the same flow; collapsing it removes ~50 lines of duplication and
gives the test suite one entry point to lock the resolution contract.
Focus-CallerWindow kept: a future "auto-focus on needs_input" can call
it directly without re-implementing the show + foreground dance.
Today only Toggle is wired to the click handler.
## Backward compatibility
No external contract changes. caller.json schema is untouched. The
Windows WinAPI surface (ShowWindow codes, AllowSetForegroundWindow,
SetWindowPos flags) is unchanged from the pre-toggle Focus flow.
Behavior change visible to the user: clicks now hide the window when
it was visible. This is the requested feature.
## Design compliance (per PR #21 round-11 standards)
no credentials : none added; the IPC is local-filesystem only
no network : no network calls added
no telemetry : no telemetry added
no third-party svcs : no new third-party deps; pure PowerShell +
Win32 user32.dll calls (already declared)
cross-platform : Win32 calls + user32.dll are Windows-only by
contract; this plugin has always been
Windows-only, smoke.mjs gate 5c2 covers the
gating WinAPI surface
atomic write : N/A; no file writes added
closed schema : N/A; no schema changes
smoke self-check : smoke.mjs section 5c2 (4 checks) locks:
- Resolve-CallerWindow function present
- Toggle-CallerWindow function present
- Toggle gates on IsWindowVisible + IsIconic
- MouseLeftButtonUp invokes Toggle (not Focus)
## Validation
smoke.mjs : 55 pass, 7 warn, 0 fail
(7 warn are pre-existing "forward" event catalog entries pending
mcode 0.2.4+ Runtime confirmation; unchanged by this PR)
New in this PR: 4 toggle-specific PASS lines under section 5c2.
## Test evidence (negative-injection verified)
Per the round-4 lesson (test pass != contract honored), I broke the
click handler by replacing Toggle-CallerWindow with Focus-CallerWindow
and re-ran smoke.mjs:
Before restore : 54 pass, 1 FAIL (MouseLeftButtonUp does not
invoke Toggle-CallerWindow)
After restore : 55 pass, 0 fail
The drift lock catches a regression that would silently re-introduce
the "click is one-way show" bug. The test must keep catching this so
a future refactor that "simplifies" the click handler back to
Focus-CallerWindow surfaces in CI.
## Reference
No docs change required (the toggle is implicit in "click the pill").
Skill SKILL.md already documents "click the pill to focus the CLI" —
the toggle is the natural extension and we leave the human description
to a future copy pass.
Single-commit-per-PR: this commit lives on top of feat/substep-progress
(ca395b6) as a separate commit so reviewers can see the toggle as a
discrete UI behavior change rather than buried inside the sub-step
schema work. Upstream can squash or keep separate.1 parent ca395b6 commit e2f0dd3
2 files changed
Lines changed: 126 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
519 | | - | |
520 | | - | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
521 | 523 | | |
522 | | - | |
| 524 | + | |
523 | 525 | | |
524 | 526 | | |
525 | 527 | | |
| |||
530 | 532 | | |
531 | 533 | | |
532 | 534 | | |
533 | | - | |
534 | | - | |
| 535 | + | |
| 536 | + | |
535 | 537 | | |
536 | | - | |
| 538 | + | |
537 | 539 | | |
538 | | - | |
| 540 | + | |
539 | 541 | | |
540 | | - | |
| 542 | + | |
541 | 543 | | |
542 | 544 | | |
543 | 545 | | |
544 | | - | |
| 546 | + | |
545 | 547 | | |
546 | 548 | | |
547 | | - | |
| 549 | + | |
548 | 550 | | |
549 | 551 | | |
550 | 552 | | |
551 | 553 | | |
552 | 554 | | |
553 | 555 | | |
554 | | - | |
555 | 556 | | |
556 | 557 | | |
557 | 558 | | |
558 | 559 | | |
559 | 560 | | |
560 | | - | |
| 561 | + | |
561 | 562 | | |
562 | 563 | | |
563 | 564 | | |
564 | | - | |
565 | | - | |
| 565 | + | |
| 566 | + | |
566 | 567 | | |
567 | 568 | | |
568 | | - | |
| 569 | + | |
| 570 | + | |
569 | 571 | | |
570 | | - | |
| 572 | + | |
571 | 573 | | |
572 | 574 | | |
573 | | - | |
574 | | - | |
| 575 | + | |
| 576 | + | |
575 | 577 | | |
576 | | - | |
| 578 | + | |
577 | 579 | | |
578 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
579 | 592 | | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
585 | 596 | | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
594 | 603 | | |
595 | 604 | | |
596 | 605 | | |
597 | 606 | | |
598 | 607 | | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
599 | 647 | | |
600 | 648 | | |
601 | 649 | | |
| |||
692 | 740 | | |
693 | 741 | | |
694 | 742 | | |
695 | | - | |
| 743 | + | |
696 | 744 | | |
697 | 745 | | |
698 | 746 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
393 | 438 | | |
394 | 439 | | |
395 | 440 | | |
| |||
0 commit comments