Skip to content

Commit e3cfac0

Browse files
committed
fix: header shows the real last-used model, not always flash
Fix: ProxyServer now increments _modelVersion each time _currentModel changes. TUI refresh loop checks _proxy.modelVersion against _lastModelVersion on every 1-second tick, so the header and the Proxy page immediately reflect the model from the most recent chat completion request, regardless of which info page is active. Also show the current model directly on the Proxy page content.
1 parent 5d92ea8 commit e3cfac0

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

lib/src/server/proxy.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ class ProxyServer {
1212
final ConfigStore configStore;
1313
bool _running = false;
1414
String _currentModel = 'deepseek/deepseek-v4-flash';
15+
int _modelVersion = 0;
1516

1617
bool get isRunning => _running;
1718
String get currentModel => _currentModel;
19+
int get modelVersion => _modelVersion;
1820

1921
ProxyServer({required this.accountStore, required this.configStore});
2022

@@ -91,6 +93,7 @@ class ProxyServer {
9193
final tools = _toWireTools(openaiReq['tools']);
9294

9395
_currentModel = model;
96+
_modelVersion++;
9497

9598
if (stream) {
9699
await _proxyStreaming(

lib/src/tui/app.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class AppState extends State<CmdBridgeApp> {
4848
bool _foregroundRefresh = true;
4949
DateTime? _lastAutoRefreshAt;
5050
int _lastLogVersion = -1;
51+
int _lastModelVersion = 0;
5152

5253
final _portCtrl = TextEditingController();
5354
bool _portScanDone = false;
@@ -120,6 +121,12 @@ class AppState extends State<CmdBridgeApp> {
120121
return;
121122
}
122123

124+
if (_lastModelVersion != _proxy.modelVersion) {
125+
_lastModelVersion = _proxy.modelVersion;
126+
setState(() {});
127+
return;
128+
}
129+
123130
if (_infoPage == _InfoPage.proxy) {
124131
setState(() {});
125132
return;
@@ -1061,6 +1068,7 @@ class AppState extends State<CmdBridgeApp> {
10611068
add('Proxy Configuration', Colors.cyan);
10621069
add('');
10631070
add('Status: ${_proxy.isRunning ? "Running" : "Stopped"}');
1071+
add('Last Model: ${_proxy.currentModel}');
10641072
add('Port: ${_config.config.serverPort}');
10651073
add('Listen: http://127.0.0.1:${_config.config.serverPort}');
10661074
add('API URL: ${_config.config.apiBaseUrl}');

0 commit comments

Comments
 (0)