2026-10-31 15:24:33 +01:00
namespace AIStudio.Assistants.ERI ;
/// <summary>
/// Tells the user why the ERI Server assistant did not write a file.
/// </summary>
/// <remarks>
/// Up to v26.10.1, such a file only showed up in the log, and the user found out by comparing the
/// base directory with the list of files in the answer.
/// </remarks>
internal static class ERIServerFileOutcomeExtensions
{
private static string TB ( string fallbackEN ) => Tools . PluginSystem . I18N . I . T ( fallbackEN , typeof ( ERIServerFileOutcomeExtensions ). Namespace , nameof ( ERIServerFileOutcomeExtensions ));
2026-11-13 10:16:56 +01:00
private static string TA ( string fallbackEN ) => Tools . PluginSystem . I18N . I . TA ( fallbackEN , typeof ( ERIServerFileOutcomeExtensions ). Namespace , nameof ( ERIServerFileOutcomeExtensions ));
2026-10-31 15:24:33 +01:00
/// <param name="outcome">What became of the file.</param>
2026-11-04 10:46:18 +01:00
extension ( ERIServerFileOutcome outcome )
{
/// <summary>
/// Gets the localized message which explains why a file was not written.
/// </summary>
/// <param name="file">The path of the file, as the model named it.</param>
/// <returns>The localized message.</returns>
internal string ToUserMessage ( string file ) => string . Format ( ToUserMessageFormat ( outcome ), file );
}
2026-10-31 15:24:33 +01:00
private static string ToUserMessageFormat ( ERIServerFileOutcome outcome ) => outcome switch
{
ERIServerFileOutcome . OUTSIDE_BASE_DIRECTORY => TB ( "The file '{0}' was not written, because its path leads outside the base directory." ),
2026-11-13 10:16:56 +01:00
ERIServerFileOutcome . NO_COMPLETE_CODE_BLOCK => TA ( "The file '{0}' was not written, because the answer of the model contains no complete code block for it. You find the answer in the conversation." ),
2026-10-31 15:24:33 +01:00
ERIServerFileOutcome . WRITE_FAILED => TB ( "The file '{0}' could not be written. The log of AI Studio names the reason." ),
_ => TB ( "The file '{0}' was not written." ),
};
}