mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 14:58:00 +00:00
Skip the chat page render which only echoes the splitter position
This commit is contained in:
1 file changed
+26
@@ -27,6 +27,7 @@ public partial class Chat : MSGComponentBase
|
|||||||
private string currentWorkspaceName = string.Empty;
|
private string currentWorkspaceName = string.Empty;
|
||||||
private Workspaces? workspaces;
|
private Workspaces? workspaces;
|
||||||
private double splitterPosition = 30;
|
private double splitterPosition = 30;
|
||||||
|
private bool skipRenderAfterSplitterChange;
|
||||||
private readonly ChatComposerState composerState = new();
|
private readonly ChatComposerState composerState = new();
|
||||||
|
|
||||||
private readonly Timer splitterSaveTimer = new(TimeSpan.FromSeconds(1.6));
|
private readonly Timer splitterSaveTimer = new(TimeSpan.FromSeconds(1.6));
|
||||||
@@ -58,6 +59,30 @@ public partial class Chat : MSGComponentBase
|
|||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Decides whether this page renders again.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Dragging the splitter reports every movement, and Blazor renders this page after each of
|
||||||
|
/// them. That render is pure waste: all it would contribute is the position the splitter just
|
||||||
|
/// reported, and the splitter has it already -- it renders itself after its own event, which is
|
||||||
|
/// what resizes the two panels. What this page rebuilds instead is everything else it holds,
|
||||||
|
/// the workspace tree above all, which has no render guard of its own and draws an item with
|
||||||
|
/// three buttons for every chat. That is what the user sees stutter while they drag.<br/><br/>
|
||||||
|
/// Dropping that one render costs nothing, because the splitter never needed it. Should a
|
||||||
|
/// message from the bus ask for a render in the very same moment, this swallows it -- both sit
|
||||||
|
/// on the same dispatcher and the render of a movement follows it without a gap, so the window
|
||||||
|
/// is as good as closed, and the next render brings the message along anyway.
|
||||||
|
/// </remarks>
|
||||||
|
protected override bool ShouldRender()
|
||||||
|
{
|
||||||
|
if (!this.skipRenderAfterSplitterChange)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
this.skipRenderAfterSplitterChange = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private string WorkspaceSidebarToggleIcon => this.SettingsManager.ConfigurationData.Workspace.IsSidebarVisible ? Icons.Material.Filled.ArrowCircleLeft : Icons.Material.Filled.ArrowCircleRight;
|
private string WorkspaceSidebarToggleIcon => this.SettingsManager.ConfigurationData.Workspace.IsSidebarVisible ? Icons.Material.Filled.ArrowCircleLeft : Icons.Material.Filled.ArrowCircleRight;
|
||||||
@@ -85,6 +110,7 @@ public partial class Chat : MSGComponentBase
|
|||||||
this.splitterPosition = position;
|
this.splitterPosition = position;
|
||||||
this.splitterSaveTimer.Stop();
|
this.splitterSaveTimer.Stop();
|
||||||
this.splitterSaveTimer.Start();
|
this.splitterSaveTimer.Start();
|
||||||
|
this.skipRenderAfterSplitterChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleWorkspacesOverlay()
|
private void ToggleWorkspacesOverlay()
|
||||||
|
|||||||
Reference in new issue
Block a user