swiftDialog icon indicating copy to clipboard operation
swiftDialog copied to clipboard

Issues with swiftDialog 2.5.3 Beta 1 when run from Shortcuts or Apple Script

Open peavine opened this issue 1 year ago • 3 comments

A clear and concise description of what the bug is. I use swiftDialog extensively in shortcuts and AppleScripts, and I encountered no issues with swiftDialog 2.5.2. I installed swiftDialog 2.5.3 Beta 1 and most of my AppleScripts and shortcuts stopped working. No error messages were issued--the AppleScripts and shortcuts simply did not show a dialog. I went back to swiftDialog 2.5.2 and the AppleScripts and shortcuts all worked. I once again installed swiftDialog 2.5.3 Beta 1, and the AppleScripts and shortcuts did not work.

To Reproduce Copy the following AppleScript into Script Editor and run:

do shell script "/usr/local/bin/dialog --title none --message 'The computer will sleep in 10 seconds' --messagefont 'size=14' --button1text 'Sleep' --button2text 'Cancel' --width 350 --height 90 --hideicon --timer 10 --messageposition bottom"

Expected behavior A dialog should be shown.

Screenshots N/A

Desktop (please complete the following information):

  • macOS version 15.0.1
  • see above regarding swiftDialog versions

Additional context With swiftDialog 2.5.3 Beta installed, the following worked when run in Script Editor, so perhaps there's an issue with the syntax of my AppleScripts and shortcuts that fail (although it's odd that they worked before).

do shell script "/usr/local/bin/dialog --title 'Test Title' --message 'Test Title'"

peavine avatar Oct 14 '24 14:10 peavine

I've been testing my Shortcuts this morning, and I'm also seeing issues.

For me, the problem seems to be present in dialog windows which include --ontop, but not every window that includes --ontop

Example:

#!/bin/zsh --no-rcs
# shellcheck shell=bash
#set -x

dialogOutput=$(/usr/local/bin/dialog \
--title "Some Shortcut" \
--message "Instructions." \
--height 200 \
--width 400 \
--messagefont size=16 \
--titlefont size=20 \
--textfield prompt="Prompt",regex="^[0-9]+$",regexerror="Numbers Only" \
--icon none \
--button2text "Cancel" \
--infobuttontext "InfoButton" \
2> /dev/null
)
true

^^ This works fine when put into a Shortcut, but if i add a line with --ontop it fails and never shows the dialog window, instead that section of the Shortcut stays green (as though Dialog is waiting for input) but the window never appears

image

To further complicate things, it seems to behave differently depending on where in the command --ontop is used.

2.5.3.4778 macOS 15.0.1

BigMacAdmin avatar Oct 14 '24 17:10 BigMacAdmin

Can confirm that this isn't isolated to using Dialog in Shortcuts or Apple Script, I'm able to reproduce the issue running from Terminal as well as running via Baseline (script launched from LaunchDaemon). It's failing to display the dialog window, with no errors specific to this cause. If I remote --ontop from the command, the window will draw. If I then subsequently run the script with --ontop added back in it will sometimes draw the window and sometimes not.

Tested with this in Terminal and run from launchd:

#!/bin/zsh --no-rcs
# shellcheck shell=bash
set -x
/usr/local/bin/dialog \
    --title 'Hi, Qwerty Yuiop' \
    --message 'Is **Qwerty** the name of the person using this computer?' \
    --button1text 'Yes, use that name.' \
    --button2text 'No, use a different name.' \
    --icon '/System/Applications/App Store.app' \
    --buttonstyle stack \
    --centericon \
    --messagealignment center \
    --quitkey ']' \
    --width 380 \
    --ontop

BigMacAdmin avatar Oct 14 '24 17:10 BigMacAdmin

I tested swiftDialog 2.5.3 Beta 2 with a number of AppleScripts and shortcuts which did not work with Beta 1, and everything works fine now. Thanks!

peavine avatar Oct 24 '24 16:10 peavine

The issues noted above were fixed in beta 2 and no similar issues were encountered in beta 3.

peavine avatar Oct 31 '24 15:10 peavine