Skip to content

Polish UX for sandbox commands - #4

Merged
enisoc merged 11 commits into
mainfrom
enisoc-sandbox-ux
May 21, 2022
Merged

enisoc merged 11 commits into
mainfrom
enisoc-sandbox-ux

Conversation

@enisoc
enisoc requested a review from scott-cotton May 18, 2022 16:17
@scott-cotton

Copy link
Copy Markdown
Member

For delete, I am getting the attached image for the output, which is odd because it is
repeating the same (truncated) message but still has the spinner.

Screenshot 2022-05-19 at 16 33 56

@enisoc

enisoc commented May 19, 2022

Copy link
Copy Markdown
Contributor Author

I was able to reproduce that too by making my terminal window narrower. So it seems that the spinner library (yacspin) doesn't work properly when you try to print a message that doesn't fit in the terminal.

I don't see an issue for that library, but the other popular Go spinner library seems to have the same issue. It appears to be a common challenge for spinners, though potentially solvable.

As a quick workaround, perhaps we could truncate the message to fit in the terminal while the spinner is running, and then print the full message only at the end when the spinner stops.

@enisoc

enisoc commented May 19, 2022

Copy link
Copy Markdown
Contributor Author

@scott-cotton I implemented the above workaround. PTAL.

@scott-cotton scott-cotton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the print package, it seems to me that it is starting to scatter the consolidation of a command implementation under internal/command/

Would it be possible to have things like print.{ClusterTable, SandboxDetails} in its own file and function under internal/command/? In this scenario I would consider what's remaining in print to be minor helper functionality such as making the json more like the yaml, and it seems it would retain the nice property of the current organisation in this PR of breaking out individual cases when they start to become more cumbersome in the switch statement.

@scott-cotton

Copy link
Copy Markdown
Member

@scott-cotton I implemented the above workaround. PTAL.

Looks like that will work, great. At the same time, I'd personally have preferred being more conservative about the packages we import, as often enough the dependencies + such workarounds end up taking more time in the long run than building directly what we need, starting with minimal features. A spinner seems like a it may be such a case.

@enisoc

enisoc commented May 20, 2022

Copy link
Copy Markdown
Contributor Author

Regarding the print package, it seems to me that it is starting to scatter the consolidation of a command implementation under internal/command/

Good point. I moved the command-specific printers back into the same package as the rest of each command's implementation.

A spinner seems like a it may be such a case.

I thought so too so I started without a spinner at all and just trying to rewrite the status line. I started running into terminal nuances and at some point I decided it would be a better use of my time to just pick an off-the-shelf library because I don't know enough about this terminal magic.

@enisoc
enisoc requested a review from foxish May 20, 2022 21:17

@foxish foxish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM aside from the one comment

Comment thread internal/command/sandbox/delete.go Outdated
}
status := result.Payload.Status
if status.Ready {
spin.Message("Waiting for sandbox to begin terminating.")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like a weird error message - maybe we group this under "Waiting for sandbox to terminate"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@enisoc
enisoc merged commit 424bbad into main May 21, 2022
@enisoc
enisoc deleted the enisoc-sandbox-ux branch May 21, 2022 00:03
scott-cotton added a commit that referenced this pull request May 21, 2026
…rnings)

Address findings #3, #4, #5, #6 from the versioned-resource-plugins UX pass.

#4 — apply immutable-version error: the previous code matched on
*ApplyResourcePluginConflict, but the go-sdk's transport middleware
(FixAPIErrors) intercepts every 4xx/5xx response before the per-endpoint
typed reader runs, so that type is never in the error chain and the
catch-and-rewrite was dead code. Users saw the generic '409 Conflict:
plugin version already exists'. Switch to errors.As against
*transport.APIError + Code==409 (the same pattern used in planexec/logs).

Also #11 — branch the message text on the bare-name vs. concrete-version
case: a bare-name author has no '@semver' suffix to bump, so the
'bump the version field' advice was a dead end; now they get a concrete
'add an @<semver> suffix to publish a new revision (e.g. [email protected])'.

#5 — apply success line: previously stayed silent on the version for
bare-name authors ('Created resource plugin my-plugin') while
explicit-version authors saw '@0.0.1'. The asymmetry hid the versioning
rule from exactly the population that most needed to learn it. Always
echo the explicit version on the apply success line (rendering '@0.0.0'
for bare publishes). The list/table/get-yaml output continues to bare
the default version for backward compatibility with pre-versioning
clients — this one message is explicit on purpose, as a teaching moment.

#3 — bare-form delete: previously silently removed only the latest
version with no indication that others remained, a footgun for users
who assumed 'delete my-plugin' meant 'delete the plugin'. Resolve the
latest version explicitly before the delete (one List call), then
report which version was removed and how many remain, e.g.
'Deleted resource plugin [email protected].
 1 other version(s) remain (use 'signadot resourceplugin versions my-plugin' to list).'

#6 — delete-in-use: previously surfaced the server's generic
'400 Bad Request: plugin is currently in use' with no hint about which
sandbox(es) were holding the version. Enrich client-side: on that
specific 400 we GET the plugin and surface Status.Resources sandbox
names: 'resource plugin [email protected] is still referenced by sandbox(es): a, b'.
Falls back to the original error if the enrichment can't be done.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@scott-cotton scott-cotton mentioned this pull request May 21, 2026
2 of 6 tasks
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.

3 participants