mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-25 23:13:49 +00:00
Added a notice naming the page when a source opens without it (#1233)
This commit is contained in:
1 parent
e63e70a5cf
commit
deb75c8dd1
18 files changed
+447
-57
No files matched your search
@@ -9799,6 +9799,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEACTIONS::T4218155268"] = "Open the fi
|
||||
-- Open the file in the program your system uses for it
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEACTIONS::T4218155268::INFORMAL"] = "Open the file in the program your system uses for it"
|
||||
|
||||
-- Open the file. As a Flatpak, AI Studio cannot open it at page {0}, where the passage is.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEACTIONS::T755778778"] = "Open the file. As a Flatpak, AI Studio cannot open it at page {0}, where the passage is."
|
||||
|
||||
-- Exclusion help and examples
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEEXCLUSIONEDITOR::T1309128010"] = "Exclusion help and examples"
|
||||
|
||||
@@ -24439,15 +24442,27 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCECODELANGUAGES::T1041509726"] = "Text"
|
||||
-- Could not open the file location.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T1118835751"] = "Could not open the file location."
|
||||
|
||||
-- As a Flatpak, AI Studio cannot open the document at its page: the sandbox of the Flatpak lets no page through to the program which shows the document. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T1426315148"] = "As a Flatpak, AI Studio cannot open the document at its page: the sandbox of the Flatpak lets no page through to the program which shows the document. The passage is on page {0}."
|
||||
|
||||
-- Could not open the file location: {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T1455637941"] = "Could not open the file location: {0}"
|
||||
|
||||
-- AI Studio could not open the document at its page: the program which shows the document could not be started with the page, so it opened without it. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T3168067729"] = "AI Studio could not open the document at its page: the program which shows the document could not be started with the page, so it opened without it. The passage is on page {0}."
|
||||
|
||||
-- Unknown error
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T3461425987"] = "Unknown error"
|
||||
|
||||
-- Could not open the document.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T3570758363"] = "Could not open the document."
|
||||
|
||||
-- AI Studio cannot open the document at its page: the program your system shows it with does not allow choosing a page. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T932584602"] = "AI Studio cannot open the document at its page: the program your system shows it with does not allow choosing a page. The passage is on page {0}."
|
||||
|
||||
-- AI Studio cannot open the document at its page: the program your system shows it with does not allow choosing a page. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T932584602::INFORMAL"] = "AI Studio cannot open the document at its page: the program your system shows it with does not allow choosing a page. The passage is on page {0}."
|
||||
|
||||
-- Could not open the document: {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T945417289"] = "Could not open the document: {0}"
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
@if (this.ShowOpen)
|
||||
{
|
||||
<MudTooltip Text="@GetOpenTooltip(this.PageNumber)" Placement="@this.TooltipPlacement" ShowOnFocus="@false">
|
||||
<MudTooltip Text="@GetOpenTooltip(this.PageNumber, this.CanOpenAtPage)" Placement="@this.TooltipPlacement" ShowOnFocus="@false">
|
||||
<MudIconButton Icon="@AppIcons.OPEN_EXTERNAL" Size="Size.Small" Class="icon-button-compact" OnClick="@this.Open"/>
|
||||
</MudTooltip>
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.Rust;
|
||||
using AIStudio.Tools.Services;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -82,6 +83,9 @@ public partial class FileActions : MSGComponentBase
|
||||
[Inject]
|
||||
private RustService RustService { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private RuntimeInfoResponse RuntimeInfo { get; init; }
|
||||
|
||||
private FileActionsKind kind;
|
||||
|
||||
/// <summary>
|
||||
@@ -94,14 +98,28 @@ public partial class FileActions : MSGComponentBase
|
||||
/// </summary>
|
||||
private bool isMissing;
|
||||
|
||||
/// <summary>
|
||||
/// Whether a page can reach the program which opens a file, see RuntimeInfoResponseExtensions.
|
||||
/// </summary>
|
||||
private bool CanOpenAtPage => this.RuntimeInfo.CanOpenDocumentsAtPage;
|
||||
|
||||
/// <summary>
|
||||
/// The tooltip of opening a file, at its page where there is one.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Inside a Flatpak, no page reaches the program, so the tooltip promises none and says why. Elsewhere,
|
||||
/// whether the page arrives depends on the program, and the user hears afterwards when it did not, see
|
||||
/// SourceDocumentLocationExtensions.GetPageNotice.
|
||||
/// </remarks>
|
||||
/// <param name="pageNumber">The page the file opens at, or null when it opens at its beginning.</param>
|
||||
/// <param name="canOpenAtPage">Whether a page can reach the program at all; false inside a Flatpak.</param>
|
||||
/// <returns>The tooltip.</returns>
|
||||
internal static string GetOpenTooltip(int? pageNumber) => pageNumber is { } page
|
||||
? string.Format(TB("Open the file at page {0}"), page)
|
||||
: TA("Open the file in the program your system uses for it");
|
||||
internal static string GetOpenTooltip(int? pageNumber, bool canOpenAtPage) => pageNumber switch
|
||||
{
|
||||
{ } page when canOpenAtPage => string.Format(TB("Open the file at page {0}"), page),
|
||||
{ } page => string.Format(TB("Open the file. As a Flatpak, AI Studio cannot open it at page {0}, where the passage is."), page),
|
||||
_ => TA("Open the file in the program your system uses for it"),
|
||||
};
|
||||
|
||||
#region Overrides of ComponentBase
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</MudText>
|
||||
}
|
||||
|
||||
<MudTooltip Text="@FileActions.GetOpenTooltip(pageRange.First)" Placement="Placement.Top">
|
||||
<MudTooltip Text="@FileActions.GetOpenTooltip(pageRange.First, this.CanOpenAtPage)" Placement="Placement.Top">
|
||||
<MudLink Typo="Typo.body1" OnClick="@(() => this.OpenDocument(pagedDocument with { PageNumber = pageRange.First }))">
|
||||
@pageRange
|
||||
</MudLink>
|
||||
@@ -55,7 +55,7 @@
|
||||
{
|
||||
@* Inline rather than the usual inline block: a long title, e.g., one naming many
|
||||
parts, then wraps like text right after its number instead of moving below it. *@
|
||||
<MudTooltip Text="@FileActions.GetOpenTooltip(null)" Placement="Placement.Top" RootClass="d-inline">
|
||||
<MudTooltip Text="@FileActions.GetOpenTooltip(null, this.CanOpenAtPage)" Placement="Placement.Top" RootClass="d-inline">
|
||||
<MudLink Typo="Typo.body1" OnClick="@(() => this.OpenDocument(document))">
|
||||
@entry.Title
|
||||
</MudLink>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using AIStudio.Dialogs;
|
||||
using AIStudio.Tools.RAG;
|
||||
using AIStudio.Tools.Rust;
|
||||
using AIStudio.Tools.Services;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -39,6 +40,9 @@ public partial class SourcesList : MSGComponentBase
|
||||
[Inject]
|
||||
private RustService RustService { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private RuntimeInfoResponse RuntimeInfo { get; init; }
|
||||
|
||||
[Inject]
|
||||
private IDialogService DialogService { get; init; } = null!;
|
||||
|
||||
@@ -112,6 +116,11 @@ public partial class SourcesList : MSGComponentBase
|
||||
|
||||
private async Task OpenDocument(SourceDocumentLocation document) => await document.OpenAsync(this.RustService);
|
||||
|
||||
/// <summary>
|
||||
/// Whether a page can reach the program which opens a document, see RuntimeInfoResponseExtensions.
|
||||
/// </summary>
|
||||
private bool CanOpenAtPage => this.RuntimeInfo.CanOpenDocumentsAtPage;
|
||||
|
||||
/// <summary>
|
||||
/// The files of sources which are no longer at their place, by their paths, as FileActions found out.
|
||||
/// </summary>
|
||||
|
||||
+15
@@ -9801,6 +9801,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEACTIONS::T4218155268"] = "Datei in de
|
||||
-- Open the file in the program your system uses for it
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEACTIONS::T4218155268::INFORMAL"] = "Datei in dem Programm öffnen, das dein System dafür verwendet"
|
||||
|
||||
-- Open the file. As a Flatpak, AI Studio cannot open it at page {0}, where the passage is.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEACTIONS::T755778778"] = "Datei öffnen. Als Flatpak kann AI Studio sie nicht auf Seite {0} öffnen, wo die Textstelle steht."
|
||||
|
||||
-- Exclusion help and examples
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEEXCLUSIONEDITOR::T1309128010"] = "Hilfe und Beispiele zu Ausschlussregeln"
|
||||
|
||||
@@ -24441,15 +24444,27 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCECODELANGUAGES::T1041509726"] = "Text"
|
||||
-- Could not open the file location.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T1118835751"] = "Der Speicherort der Datei konnte nicht geöffnet werden."
|
||||
|
||||
-- As a Flatpak, AI Studio cannot open the document at its page: the sandbox of the Flatpak lets no page through to the program which shows the document. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T1426315148"] = "Als Flatpak kann AI Studio das Dokument nicht auf der richtigen Seite öffnen: Die Sandbox des Flatpaks lässt keine Seitenzahl zu dem Programm durch, das das Dokument anzeigt. Die Textstelle steht auf Seite {0}."
|
||||
|
||||
-- Could not open the file location: {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T1455637941"] = "Der Speicherort der Datei konnte nicht geöffnet werden: {0}"
|
||||
|
||||
-- AI Studio could not open the document at its page: the program which shows the document could not be started with the page, so it opened without it. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T3168067729"] = "AI Studio konnte das Dokument nicht auf der richtigen Seite öffnen: Das Programm, das das Dokument anzeigt, ließ sich nicht mit der Seitenzahl starten und hat es deshalb ohne sie geöffnet. Die Textstelle steht auf Seite {0}."
|
||||
|
||||
-- Unknown error
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T3461425987"] = "Unbekannter Fehler"
|
||||
|
||||
-- Could not open the document.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T3570758363"] = "Das Dokument konnte nicht geöffnet werden."
|
||||
|
||||
-- AI Studio cannot open the document at its page: the program your system shows it with does not allow choosing a page. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T932584602"] = "AI Studio kann das Dokument nicht auf der richtigen Seite öffnen: Das Programm, mit dem Ihr System es anzeigt, erlaubt keine Wahl der Seite. Die Textstelle steht auf Seite {0}."
|
||||
|
||||
-- AI Studio cannot open the document at its page: the program your system shows it with does not allow choosing a page. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T932584602::INFORMAL"] = "AI Studio kann das Dokument nicht auf der richtigen Seite öffnen: Das Programm, mit dem dein System es anzeigt, erlaubt keine Wahl der Seite. Die Textstelle steht auf Seite {0}."
|
||||
|
||||
-- Could not open the document: {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T945417289"] = "Das Dokument konnte nicht geöffnet werden: {0}"
|
||||
|
||||
|
||||
+15
@@ -9801,6 +9801,9 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEACTIONS::T4218155268"] = "Open the fi
|
||||
-- Open the file in the program your system uses for it
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEACTIONS::T4218155268::INFORMAL"] = "Open the file in the program your system uses for it"
|
||||
|
||||
-- Open the file. As a Flatpak, AI Studio cannot open it at page {0}, where the passage is.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEACTIONS::T755778778"] = "Open the file. As a Flatpak, AI Studio cannot open it at page {0}, where the passage is."
|
||||
|
||||
-- Exclusion help and examples
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::FILEEXCLUSIONEDITOR::T1309128010"] = "Exclusion help and examples"
|
||||
|
||||
@@ -24441,15 +24444,27 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCECODELANGUAGES::T1041509726"] = "Text"
|
||||
-- Could not open the file location.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T1118835751"] = "Could not open the file location."
|
||||
|
||||
-- As a Flatpak, AI Studio cannot open the document at its page: the sandbox of the Flatpak lets no page through to the program which shows the document. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T1426315148"] = "As a Flatpak, AI Studio cannot open the document at its page: the sandbox of the Flatpak lets no page through to the program which shows the document. The passage is on page {0}."
|
||||
|
||||
-- Could not open the file location: {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T1455637941"] = "Could not open the file location: {0}"
|
||||
|
||||
-- AI Studio could not open the document at its page: the program which shows the document could not be started with the page, so it opened without it. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T3168067729"] = "AI Studio could not open the document at its page: the program which shows the document could not be started with the page, so it opened without it. The passage is on page {0}."
|
||||
|
||||
-- Unknown error
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T3461425987"] = "Unknown error"
|
||||
|
||||
-- Could not open the document.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T3570758363"] = "Could not open the document."
|
||||
|
||||
-- AI Studio cannot open the document at its page: the program your system shows it with does not allow choosing a page. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T932584602"] = "AI Studio cannot open the document at its page: the program your system shows it with does not allow choosing a page. The passage is on page {0}."
|
||||
|
||||
-- AI Studio cannot open the document at its page: the program your system shows it with does not allow choosing a page. The passage is on page {0}.
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T932584602::INFORMAL"] = "AI Studio cannot open the document at its page: the program your system shows it with does not allow choosing a page. The passage is on page {0}."
|
||||
|
||||
-- Could not open the document: {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::SOURCEDOCUMENTLOCATIONEXTENSIONS::T945417289"] = "Could not open the document: {0}"
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -177,11 +177,11 @@ public sealed partial class RustService
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The page is best effort and never decides whether this succeeded. Which programs can be
|
||||
/// told a page is the runtime's business, and it says afterwards whether it managed to.
|
||||
/// told a page is the runtime's business, and it says afterwards what became of the page.
|
||||
/// </remarks>
|
||||
/// <param name="path">The document to open.</param>
|
||||
/// <param name="pageNumber">The page to show, counted from one, or null when there is none.</param>
|
||||
/// <returns>Whether the document was opened, whether the page was applied, and what went wrong.</returns>
|
||||
/// <returns>Whether the document was opened, what became of the page, and what went wrong.</returns>
|
||||
public async Task<OpenDocumentResponse> TryOpenDocumentInSystemViewer(string path, int? pageNumber)
|
||||
{
|
||||
HttpResponseMessage result;
|
||||
@@ -192,12 +192,12 @@ public sealed partial class RustService
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
this.logger!.LogWarning(e, "Failed to reach the Rust runtime document endpoint.");
|
||||
return new OpenDocumentResponse(false, false, TB("The runtime document endpoint is not available."));
|
||||
return new OpenDocumentResponse(false, DocumentPageOutcome.DOCUMENT_NOT_OPENED, TB("The runtime document endpoint is not available."));
|
||||
}
|
||||
catch (TaskCanceledException e)
|
||||
{
|
||||
this.logger!.LogWarning(e, "Timed out while reaching the Rust runtime document endpoint.");
|
||||
return new OpenDocumentResponse(false, false, TB("The runtime document endpoint is not available."));
|
||||
return new OpenDocumentResponse(false, DocumentPageOutcome.DOCUMENT_NOT_OPENED, TB("The runtime document endpoint is not available."));
|
||||
}
|
||||
|
||||
try
|
||||
@@ -205,28 +205,24 @@ public sealed partial class RustService
|
||||
if (!result.IsSuccessStatusCode)
|
||||
{
|
||||
this.logger!.LogWarning("Failed to open a document through the Rust runtime: '{StatusCode}'", result.StatusCode);
|
||||
return new OpenDocumentResponse(false, false, string.Format(TB("The runtime document endpoint returned '{0}'."), result.StatusCode));
|
||||
return new OpenDocumentResponse(false, DocumentPageOutcome.DOCUMENT_NOT_OPENED, string.Format(TB("The runtime document endpoint returned '{0}'."), result.StatusCode));
|
||||
}
|
||||
|
||||
var response = await result.Content.ReadFromJsonAsync<OpenDocumentResponse>(JSON_OPTIONS);
|
||||
if (response.Success)
|
||||
{
|
||||
//
|
||||
// A page which was asked for but not applied is noted here and nowhere else: the
|
||||
// document is open, and the source the user clicked names the page anyway.
|
||||
//
|
||||
if (pageNumber is > 0 && !response.PageApplied)
|
||||
this.logger!.LogInformation("Opened a document without the requested page {PageNumber}, because the system uses a program which cannot be told one.", pageNumber);
|
||||
if (pageNumber is > 0 && response.PageOutcome is not DocumentPageOutcome.APPLIED)
|
||||
this.logger!.LogInformation("Opened a document without the requested page {PageNumber}: {PageOutcome}.", pageNumber, response.PageOutcome);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
return new OpenDocumentResponse(false, false, string.IsNullOrWhiteSpace(response.Issue) ? TB("The runtime document endpoint failed without details.") : response.Issue);
|
||||
return new OpenDocumentResponse(false, DocumentPageOutcome.DOCUMENT_NOT_OPENED, string.IsNullOrWhiteSpace(response.Issue) ? TB("The runtime document endpoint failed without details.") : response.Issue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.logger!.LogWarning(e, "Failed to process the Rust runtime document endpoint response.");
|
||||
return new OpenDocumentResponse(false, false, TB("The runtime document endpoint failed without details."));
|
||||
return new OpenDocumentResponse(false, DocumentPageOutcome.DOCUMENT_NOT_OPENED, TB("The runtime document endpoint failed without details."));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -17,6 +17,8 @@ public static class SourceDocumentLocationExtensions
|
||||
|
||||
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(SourceDocumentLocationExtensions).Namespace, nameof(SourceDocumentLocationExtensions));
|
||||
|
||||
private static string TA(string fallbackEN) => I18N.I.TA(fallbackEN, typeof(SourceDocumentLocationExtensions).Namespace, nameof(SourceDocumentLocationExtensions));
|
||||
|
||||
/// <param name="document">The document to show, and the page to show it at.</param>
|
||||
extension(SourceDocumentLocation document)
|
||||
{
|
||||
@@ -25,8 +27,9 @@ public static class SourceDocumentLocationExtensions
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Whether the program can be sent to a page is the runtime's business, and it says afterwards
|
||||
/// whether it managed to. Nothing is shown about that: the document is open, and the page is
|
||||
/// named where the user asked to open it.
|
||||
/// what became of the page. When the page did not arrive, the user hears where the passage is
|
||||
/// and why AI Studio could not do otherwise, see GetPageNotice. Otherwise, they would take the
|
||||
/// beginning of the document, or the place their program remembered, for the passage.
|
||||
/// </remarks>
|
||||
/// <param name="rustService">The runtime, which opens the document.</param>
|
||||
public async Task OpenAsync(RustService rustService)
|
||||
@@ -44,12 +47,42 @@ public static class SourceDocumentLocationExtensions
|
||||
}
|
||||
|
||||
if (response.Success)
|
||||
{
|
||||
if (document.GetPageNotice(response) is { } notice)
|
||||
await MessageBus.INSTANCE.SendInfo(new(AppIcons.DOCUMENT, notice));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var issue = string.IsNullOrWhiteSpace(response.Issue) ? TB("Unknown error") : response.Issue;
|
||||
await MessageBus.INSTANCE.SendError(new(AppIcons.DOCUMENT, string.Format(TB("Could not open the document: {0}"), issue)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells the user on which page the passage is, when the document opened without that page, and
|
||||
/// why AI Studio could not open it there.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Each reason lies outside of AI Studio, and the notice says so: the sandbox of the Flatpak, a
|
||||
/// program which does not let anybody choose its page, or a program which did not start with
|
||||
/// one. A reason of a newer runtime is told like a program which takes no page.
|
||||
/// </remarks>
|
||||
/// <param name="response">How opening the document went.</param>
|
||||
/// <returns>The notice, or null when the page arrived, none was asked for, or the document did not open at all, which the user hears about as an error.</returns>
|
||||
internal string? GetPageNotice(OpenDocumentResponse response)
|
||||
{
|
||||
if (!response.Success || document.PageNumber is not { } page || page <= 0)
|
||||
return null;
|
||||
|
||||
return response.PageOutcome switch
|
||||
{
|
||||
DocumentPageOutcome.APPLIED or DocumentPageOutcome.NOT_REQUESTED or DocumentPageOutcome.DOCUMENT_NOT_OPENED => null,
|
||||
DocumentPageOutcome.SANDBOXED => string.Format(TB("As a Flatpak, AI Studio cannot open the document at its page: the sandbox of the Flatpak lets no page through to the program which shows the document. The passage is on page {0}."), page),
|
||||
DocumentPageOutcome.PROGRAM_FAILED => string.Format(TB("AI Studio could not open the document at its page: the program which shows the document could not be started with the page, so it opened without it. The passage is on page {0}."), page),
|
||||
_ => string.Format(TA("AI Studio cannot open the document at its page: the program your system shows it with does not allow choosing a page. The passage is on page {0}."), page),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the file browser of the system and selects the document in it.
|
||||
/// </summary>
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
- Improved the assistants when a request nearly fills the context window of the selected model: before sending it, AI Studio tells you, so that you can attach fewer or smaller files, or send the request anyway.
|
||||
- Improved the settings of the AI tasks, which AI Studio hands to a model on its own, such as the data source selection or the text content cleaner, formerly called agents: for each of them, you can now set the minimum confidence its provider needs, and the provider selection tells you which model AI Studio uses when you choose none.
|
||||
- Improved classic RAG: when the model you chose for selecting data sources or validating retrieval contexts may not see the data sources of your chat, AI Studio now uses the model of the chat for this step instead of skipping it.
|
||||
- Improved the page numbers in the sources of your own documents: when a document opens without the page you clicked, AI Studio now tells you on which page the passage is and why it could not open the document there. This happens, for example, when AI Studio runs as a Flatpak, whose sandbox lets no page through, or when the program which shows the document does not allow choosing a page. In the Flatpak, the tooltip of a page number says so already.
|
||||
- Improved entering API keys: AI Studio removes spaces and line breaks around a pasted key and tells you right away when a key contains a character which an API key cannot contain, such as an invisible character copied from a web page or a typographic quotation mark.
|
||||
- Improved the message when a stored API key contains a character which an API key cannot contain, such as a line break: AI Studio now asks you to enter the key again instead of showing a technical error.
|
||||
- Improved the API keys which organizations provide through configuration plugins: AI Studio removes spaces and line breaks around them and leaves out a key with characters which an API key cannot contain, noting this in the log.
|
||||
|
||||
Reference in new issue
Block a user