Skip to content

Commit 74daf04

Browse files
committed
revert fix for 402 quota usage
1 parent 567e669 commit 74daf04

2 files changed

Lines changed: 8 additions & 27 deletions

File tree

com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ChatContentViewer.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,11 @@ public void processTurnEvent(ChatProgressValue value) {
217217
errMsg = Messages.chat_model_unsupported_message;
218218
}
219219
if (StringUtils.isNotEmpty(errMsg)) {
220-
// Check once whether we're already on the fallback model
221-
CopilotModel fallback = this.serviceManager.getModelService().getFallbackModel();
222-
CopilotModel current = this.serviceManager.getModelService().getActiveModel();
223-
boolean alreadyOnFallback = fallback != null && current != null
224-
&& fallback.getModelName().equals(current.getModelName());
225-
226-
// Only replace the error message with "switched to fallback" when we're NOT already
227-
// on the fallback model. When already on fallback, show the original CLS message.
228-
if (value.getCode() == 402 && !alreadyOnFallback) {
220+
// TODO: remove this error message replacement if statement when the CLS side warn message is aligned.
221+
if (value.getCode() == 402) {
229222
CopilotPlan userPlan = this.serviceManager.getAuthStatusManager().getQuotaStatus().copilotPlan();
230-
String fallbackModelName = fallback != null ? fallback.getModelName()
223+
CopilotModel fallbackModel = this.serviceManager.getModelService().getFallbackModel();
224+
String fallbackModelName = fallbackModel != null ? fallbackModel.getModelName()
231225
: Messages.chat_noQuotaView_fallbackModel;
232226

233227
if (MenuUtils.isCfiPlan(userPlan)) {
@@ -241,19 +235,15 @@ public void processTurnEvent(ChatProgressValue value) {
241235

242236
renderWarnMessageWithUpgradePlanButton(errMsg, value.getCode());
243237

244-
// Switch to fallback model and auto-retry, but only if not already on the fallback model
245-
// to avoid an infinite loop of 402 → switch → resend → 402 → ...
246-
if (value.getCode() == 402 && !alreadyOnFallback
238+
if (value.getCode() == 402
247239
&& this.serviceManager.getAuthStatusManager().getQuotaStatus().copilotPlan() != CopilotPlan.free) {
248240
this.serviceManager.getModelService().setFallBackModelAsActiveModel();
249241
this.serviceManager.getAuthStatusManager().checkQuota();
250242

251-
String previousInput =
252-
this.serviceManager.getUserPreferenceService().getPreviousInput(StringUtils.EMPTY);
243+
String previousInput = this.serviceManager.getUserPreferenceService().getPreviousInput(StringUtils.EMPTY);
253244
if (StringUtils.isNotEmpty(previousInput)) {
254245
IEventBroker eventBroker = PlatformUI.getWorkbench().getService(IEventBroker.class);
255-
Map<String, Object> properties =
256-
Map.of("previousInput", previousInput, "needCreateUserTurn", false);
246+
Map<String, Object> properties = Map.of("previousInput", previousInput, "needCreateUserTurn", false);
257247
eventBroker.post(CopilotEventConstants.TOPIC_CHAT_ON_SEND, properties);
258248
}
259249
}

com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/CopilotTurnWidget.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
* A custom widget that displays a turn for the copilot.
2626
*/
2727
public class CopilotTurnWidget extends BaseTurnWidget {
28-
29-
private Label modelInfoLabel;
30-
3128
/**
3229
* Create the widget.
3330
*/
@@ -74,11 +71,8 @@ public void renderModelInfo(String modelName, double billingMultiplier) {
7471
if (footer == null || footer.isDisposed()) {
7572
createFooter();
7673
}
77-
if (modelInfoLabel != null && !modelInfoLabel.isDisposed()) {
78-
modelInfoLabel.dispose();
79-
}
8074
if (StringUtils.isNotBlank(modelName)) {
81-
modelInfoLabel = new Label(footer, SWT.NONE);
75+
Label modelInfoLabel = new Label(footer, SWT.NONE);
8276
// When token-based billing is enabled on the language server, the per-turn billing
8377
// multiplier is no longer a meaningful price signal, so render the model name on its
8478
// own. Fall back to the legacy "{model} - {multiplier}" format otherwise.
@@ -97,9 +91,6 @@ public void renderModelInfo(String modelName, double billingMultiplier) {
9791
modelInfoLabel.setLayoutData(labelGridData);
9892
modelInfoLabel.setData(CssConstants.CSS_CLASS_NAME_KEY, "model-info-label");
9993

100-
// Ensure footer stays at the bottom of the turn widget, even when
101-
// warn widgets are appended after it (e.g. quota fallback retry).
102-
footer.moveBelow(null);
10394
footer.requestLayout();
10495
}
10596
}, this);

0 commit comments

Comments
 (0)