Skip to content

Commit 7170908

Browse files
authored
Merge pull request #34 from semantic-developer/feature/sd-36
feature/sd-36
2 parents 35c6677 + a8f0728 commit 7170908

File tree

4 files changed

+40
-11
lines changed

4 files changed

+40
-11
lines changed

SemanticDeveloper/Installers/Linux/build_deb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ APP_PROJ="$ROOT/SemanticDeveloper/SemanticDeveloper.csproj"
88
PUBLISH_DIR="$SCRIPT_DIR/out/publish"
99
PKG_ROOT="$SCRIPT_DIR/pkgroot"
1010
DIST_DIR="$SCRIPT_DIR/dist"
11-
VERSION="1.0.7"
11+
VERSION="1.0.8"
1212
ARCH="amd64"
1313
if [[ "$RID" == "linux-arm64" ]]; then ARCH="arm64"; fi
1414

Binary file not shown.

SemanticDeveloper/SemanticDeveloper/SemanticDeveloper.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
77
<ApplicationManifest>app.manifest</ApplicationManifest>
88
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
9-
<Version>1.0.7</Version>
9+
<Version>1.0.8</Version>
1010
<Copyright>2025 Stainless Designer LLC</Copyright>
1111
</PropertyGroup>
1212

SemanticDeveloper/SemanticDeveloper/Views/SessionView.axaml.cs

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public partial class SessionView : UserControl, INotifyPropertyChanged
111111
private const long ContextBaselineTokens = 12000;
112112
private static readonly string[] FileTreeIgnoredFolders = new[] { ".git", "node_modules", "bin", "obj", ".idea", ".vs" };
113113
private bool _verboseLogging;
114+
private bool _modelListUseLegacyPaging;
114115
private bool _mcpEnabled;
115116
private bool _allowNetworkAccess;
116117
private bool _loginInProgress;
@@ -644,19 +645,39 @@ private async Task<List<ModelCatalogEntry>> FetchModelCatalogAsync()
644645

645646
while (true)
646647
{
647-
var parameters = new JObject
648+
var parameters = new JObject();
649+
if (_modelListUseLegacyPaging)
648650
{
649-
["limit"] = PageSize,
650-
["pageSize"] = PageSize // legacy field for older Codex builds
651-
};
651+
parameters["pageSize"] = PageSize;
652+
}
653+
else
654+
{
655+
parameters["limit"] = PageSize;
656+
parameters["pageSize"] = PageSize; // fallback for older builds; ignored by newer ones
657+
}
658+
652659
if (!string.IsNullOrWhiteSpace(cursor))
653660
parameters["cursor"] = cursor;
654661

655-
var response = await SendRequestAsync("model/list", parameters).ConfigureAwait(false);
656-
if (response is not JObject obj)
657-
break;
662+
JObject obj;
663+
try
664+
{
665+
var response = await SendRequestAsync("model/list", parameters).ConfigureAwait(false);
666+
if (response is not JObject json)
667+
break;
668+
obj = json;
669+
}
670+
catch (Exception ex) when (ShouldFallbackToLegacyModelList(ex))
671+
{
672+
if (_modelListUseLegacyPaging)
673+
throw;
674+
_modelListUseLegacyPaging = true;
675+
AppendCliLog("System: CLI returned legacy pagination error; retrying model catalog request.");
676+
return await FetchModelCatalogAsync().ConfigureAwait(false);
677+
}
658678

659-
if (obj["items"] is JArray items)
679+
var itemsToken = obj["items"] ?? obj["data"];
680+
if (itemsToken is JArray items)
660681
{
661682
foreach (var token in items.OfType<JObject>())
662683
{
@@ -666,7 +687,7 @@ private async Task<List<ModelCatalogEntry>> FetchModelCatalogAsync()
666687
}
667688
}
668689

669-
var nextCursor = obj["nextCursor"]?.ToString();
690+
var nextCursor = obj["nextCursor"]?.ToString() ?? obj["next_cursor"]?.ToString();
670691
if (string.IsNullOrWhiteSpace(nextCursor))
671692
break;
672693
cursor = nextCursor;
@@ -3463,6 +3484,14 @@ private static bool IsPathAncestorOrSame(string? ancestor, string? target)
34633484
return separator == Path.DirectorySeparatorChar || separator == Path.AltDirectorySeparatorChar;
34643485
}
34653486

3487+
private static bool ShouldFallbackToLegacyModelList(Exception ex)
3488+
{
3489+
if (ex is not InvalidOperationException ioe)
3490+
return false;
3491+
var message = ioe.Message ?? string.Empty;
3492+
return message.IndexOf("invalid request", StringComparison.OrdinalIgnoreCase) >= 0;
3493+
}
3494+
34663495
private void ResetEditorViewport(TextEditor? editor)
34673496
{
34683497
if (editor is null) return;

0 commit comments

Comments
 (0)