gingerbeardman / stapler

My take on the classic Macintosh app Stapler (with a little bit of LaunchList)
https://blog.gingerbeardman.com/2024/08/10/stapler-i-remade-a-32-year-old-classic-macintosh-app/
MIT License
238 stars 10 forks source link

Document opens in edit mode rather than auto-launching items (since 1.2) #25

Closed aptonline closed 3 months ago

aptonline commented 3 months ago

Describe the bug Files not opening when launching the stapler document

To Reproduce Testing for the first time and adding a number of documents (.PDF,.MP4) files into a document both via drag and drop and also via 'Add files'. Saving the document to the desktop and launching from there. The Stapler document opens and shows the added files but no documents are opening. It appears to be opening in edit mode (command key down).

Expected behavior Documents open as expected when opening the Stapler document.

Versions (please complete the following information):

Additional context No error messages appears and app does not crash, just shows the contents of the Stapler document.

gingerbeardman commented 3 months ago

Please use 1.2.2 for now

It seems I have broken auto-launch in 1.2.3

aptonline commented 3 months ago

Same issue with 1.2.2 for me.

gingerbeardman commented 3 months ago

Keep going back until you find one that works :)

That would help me find the point at which I broke it.

Then I'll fix it later today.

gingerbeardman commented 3 months ago

OK, I broke it in 1.2 as 1.1 auto-launches.

Gah.

Will fix later on

gingerbeardman commented 3 months ago

So, in the latest code as it stands it does still work... it's just the flaky nature of the way I am deciding if the file was opened from Finder or not to do an auto-launch is ....crap. See #2

Repro

  1. Open Stapler app
  2. Switch to Finder
  3. Double-click a Stapler Document
  4. Items will auto-launch

Offensive code

if isOpenedFromFinder && !appStateManager.wasJustLaunched {

This means that it won't work in some scenarios, including opening a document to launch the app which is a pretty big oversight on my part. Need to improve that.

gingerbeardman commented 3 months ago

Closing in favour of #2

Feel free to reply if there's anything more to add.

aptonline commented 3 months ago

Hi, this is still not working for me even from a cold start of the app. Same result. no documents opening.

gingerbeardman commented 3 months ago

Screen recording please @aptonline

I believe you I just want to analyse what's happening.

aptonline commented 3 months ago

As requested, tested with no app open and then launching the document I created and testing Quicklook to show the files are present.

https://github.com/user-attachments/assets/b2d84ddb-941a-4642-bd78-92b02da94ac4

gingerbeardman commented 3 months ago

Right, I agree it's broken in this usage.

I thought you were saying you tried my workaround and that didn't work.

You can use my workaround (basically, leave Stapler open) until I fix this soon.

aptonline commented 3 months ago

Leaving Stapler open and launching the document has the same result. Nothing happens.

gingerbeardman commented 3 months ago

Well, it's leaving Stapler open in the background.

But if you're doing that, then I can't reproduce what you're seeing.

Screen shot 2024-08-21 at 18 57 37

https://github.com/user-attachments/assets/e8eda74c-37df-4722-832c-ee783e0484a9

gingerbeardman commented 3 months ago

But, this will be reworked soon so don't worry about whether or not we can agree on repro.

aptonline commented 3 months ago

It's certainly flakey as its started working today if I leave the app open.

As an aside, would it be possible to add a preference toggle displaying the open dialog when launching the app?

gingerbeardman commented 3 months ago

The app is not self-modifying ๐Ÿ˜† so it can't just start working.

Small change: https://github.com/gingerbeardman/stapler/commit/feaa002287e82e1d13f4cc4aac7ef4a35030c9c4

Will live with this for a while. Not entirely sure it's a better experience, more changes needed.

aptonline commented 3 months ago

The app is not self-modifying ๐Ÿ˜† so it can't just start working.

And yet here we areโ€ฆ

Iโ€™ll test the new version when itโ€™s released and provide an update ๐Ÿ‘

gingerbeardman commented 3 months ago

Had a brain wave. Cross your fingers.

I will also put some logging in so we can check some things!

gingerbeardman commented 3 months ago

EUREKA.

Just taking a moment to think if there are any other scenarios I need to deal with.

Screen shot 2024-08-23 at 16 29 11
gingerbeardman commented 3 months ago
// Define an enum for the different document opening scenarios
enum DocumentOpeningScenario {
    case launchedWithDocument
    case resumedBySystem
    case openedThroughFileMenu
    case openedFromFinderWhileRunning
    case unknown
}
aptonline commented 3 months ago

Will give it a whirl on the next release.

gingerbeardman commented 3 months ago

here we go https://github.com/gingerbeardman/stapler/tree/1.2.4

aptonline commented 3 months ago

All working for me now from my tests ๐Ÿ‘๐Ÿผ