Skip to content

ping-a-human: a queued Allow / Deny is not sent for a prompt already answered at the desk - #23

Open
connorburgess wants to merge 1 commit into
spacesheep-dev:mainfrom
connorburgess:fix/ping-a-human-answered-prompt-queue
Open

connorburgess wants to merge 1 commit into
spacesheep-dev:mainfrom
connorburgess:fix/ping-a-human-answered-prompt-queue

Conversation

@connorburgess

Copy link
Copy Markdown
Contributor

What

@sessionpipe-gui/plugin-ping-a-human: a permission prompt whose Allow / Deny ask is queued behind another one is checked again when its turn comes. If it was answered at the desk in the meantime, or its session is gone, nothing is sent and the queue moves straight on to the next prompt.

The check that fire() already makes after the minSilenceS wait now lives in a small stillOpen(key, attentionId) helper, and both fire() and the queued step use it.

Why

Asks go out one at a time, because ping-a-human's channel reads a single reply stream, and each one waits up to REPLY_TIMEOUT_MS (2 minutes) for a tap. Before sending, the queued step only checked closed. So when two sessions raised a permission prompt each and the second was answered at the desk while the first was still waiting, the second still went to Telegram with Allow / Deny buttons once the first's wait ended. The queue then waited up to 2 more minutes for a reply to a prompt that was already closed, which delayed any live prompt behind it. The README says a prompt answered at the desk sends nothing, and fire() already keeps that promise for the minSilenceS wait.

Not in this PR (each is older than this change and a separate concern):

  • A prompt whose ask is already waiting for a reply still holds the queue for the full 2 minutes if it is answered at the desk. Ending that wait early needs a way to cancel awaitReply in ping-a-human's channel, which takes only timeoutMs and sinceRef.
  • A queued step still uses the channel and settings from when it was queued (quiet hours, dryRun, askOnPermission).

The CHANGELOG line is left out for now. It would go under a new Fixed heading in Unreleased, and #19 adds that same heading at the same place, so the two would conflict. The line follows once #19 lands: "@sessionpipe-gui/plugin-ping-a-human: a permission prompt waiting its turn behind another's Allow / Deny is no longer sent once it was answered at the desk."

Proof

New test in packages/plugin-ping-a-human/test/plugin.test.mjs. The fake channel's awaitReply waits until the test lets it go. Prompts a, b and d (one per session) fire with minSilenceS: 0, so b and d wait behind a. Then b is answered at the desk and d's session leaves the store, and only after that does a's wait end. The test checks that nothing more is sent, that nothing waits on a reply, and that a new prompt c is asked at once.

With packages/plugin-ping-a-human/src/index.ts from main (d92e06a) and the new test, npm test -w packages/plugin-ping-a-human:

    not ok 6 - a queued ask whose prompt was answered at the desk, or whose session is gone, is not sent
      error: |-
        Expected values to be strictly equal:

        2 !== 1

      expected: 1
      actual: 2
      operator: 'strictEqual'
# tests 13
# pass 12
# fail 1

On this branch (80fe898), npm run typecheck && npm run lint && npm run build && npm test at the root:

  • typecheck: canvas, office and ping-a-human pass with no errors.
  • lint: Checked 91 files in 58ms. No fixes applied. Found 2 warnings. Both warnings are noDescendingSpecificity in packages/office/src/office.css (801, 844). main has those 2 plus a third, useOptionalChain at packages/plugin-ping-a-human/src/index.ts:225, which this change removes.
  • build: every workspace builds.
  • test:
    • ping-a-human: # tests 13, # pass 13, # fail 0.
    • color-themes, skin-paper-serif, skin-spacesheep and skin-spacesheep-vivid: their checks pass ("all good").
    • canvas (Playwright): 43 failed. Every failure is the same: browserType.launch: Executable doesn't exist at ~/Library/Caches/ms-playwright/chromium_headless_shell-1248/.... This machine has no browser build installed for the pinned Playwright. Unmodified main (d92e06a) fails the same way, with the same 43 tests and the same message, in npm test -w packages/canvas. This PR does not touch canvas.

Checklist

  • Every commit is signed off (git commit -s): the DCO is the only paperwork.
  • npm run typecheck && npm run lint && npm run build && npm test pass, except the canvas Playwright tests: they cannot start a browser on this machine and fail the same way on main (see above).
  • New source files start with // SPDX-License-Identifier: Apache-2.0. No new files; nothing bundled.
  • No token, real address, hostname or home path in code, fixtures or screenshots.
  • A line under Unreleased in CHANGELOG.md if a person would notice. It follows once color-themes: check.mjs --skin measures a text tier the skin leaves unset with the stock value, as the GUI does #19 lands (see Why).

…answered at the desk

Asks go one at a time, and each waits up to two minutes for a reply. A permission
prompt queued behind another was sent with Allow / Deny when its turn came even if it had
been answered at the desk meanwhile, and the queue then waited on a reply to it. The
queued step now checks the store first, as the wait before sending already does, and
skips a prompt that is no longer open or whose session is gone.

Signed-off-by: Connor Burgess <connorburgesscodes@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant