Added a notice naming the page when a source opens without it (#1233)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-11-25 16:38:31 +01:00
1 parent e63e70a5cf
commit deb75c8dd1
18 files changed
+447 -57

No files matched your search

@@ -0,0 +1,32 @@
namespace AIStudio.Tools.Rust;
/// <summary>
/// What became of the page a document was to be shown at, as the runtime reports it.
/// </summary>
/// <remarks>
/// The runtime names these values in PageOutcome in runtime/src/file_actions.rs. The app tells the user
/// from them why a document opened without its page, so that they know AI Studio could not do otherwise.
/// </remarks>
public enum DocumentPageOutcome
{
/// <summary>A value of a newer runtime which the app does not know.</summary>
UNKNOWN,
/// <summary>The document was handed to its program together with the page.</summary>
APPLIED,
/// <summary>No page was asked for.</summary>
NOT_REQUESTED,
/// <summary>AI Studio runs as a Flatpak, whose sandbox lets no page through to the program.</summary>
SANDBOXED,
/// <summary>The program which shows the document cannot be told a page, or the document is no PDF.</summary>
PROGRAM_TAKES_NO_PAGE,
/// <summary>The program takes a page, but it could not be started with one.</summary>
PROGRAM_FAILED,
/// <summary>The document did not open at all.</summary>
DOCUMENT_NOT_OPENED
}
@@ -4,11 +4,9 @@ namespace AIStudio.Tools.Rust;
/// Says how opening a document went.
/// </summary>
/// <param name="Success">Whether the document was opened at all.</param>
/// <param name="PageApplied">
/// Whether the document was handed to its program together with the page. False means it opens on
/// its first page: no page was asked for, the system uses a program which cannot be told one, or
/// starting that program failed. None of these is an error, so this belongs in the log rather than
/// in front of the user, who is told the page by the source itself.
/// <param name="PageOutcome">
/// What became of the page the document was to be shown at. A page which did not arrive is no error,
/// since the document opens either way, but the user hears why, see SourceDocumentLocationExtensions.
/// </param>
/// <param name="Issue">Why the document could not be opened, or an empty text when it was.</param>
public readonly record struct OpenDocumentResponse(bool Success, bool PageApplied, string Issue);
public readonly record struct OpenDocumentResponse(bool Success, DocumentPageOutcome PageOutcome, string Issue);
@@ -0,0 +1,20 @@
namespace AIStudio.Tools.Rust;
public static class RuntimeInfoResponseExtensions
{
/// <param name="runtimeInfo">What the runtime tells about itself.</param>
extension(RuntimeInfoResponse runtimeInfo)
{
/// <summary>
/// Whether a document can be opened at a page at all.
/// </summary>
/// <remarks>
/// Never inside a Flatpak: its sandbox lets AI Studio start no program itself, and the desktop
/// portal, which opens the document instead, knows no pages, see PageOutcome in
/// runtime/src/file_actions.rs. Everywhere else, whether the page arrives depends on the
/// program, which the runtime learns only while it opens the document.
/// </remarks>
/// <value>False inside a Flatpak.</value>
public bool CanOpenDocumentsAtPage => runtimeInfo.LinuxPackageType is not LinuxPackageType.FLATPAK;
}
}