mirror of
https://github.com/katanemo/plano.git
synced 2026-07-05 15:52:12 +02:00
updated content.js to update the labels even when default model
This commit is contained in:
parent
f46b8b4968
commit
cde10fc084
1 changed files with 34 additions and 24 deletions
|
|
@ -50,33 +50,44 @@
|
||||||
// Insert a route label for the last user message in the chat
|
// Insert a route label for the last user message in the chat
|
||||||
function insertRouteLabelForLastUserMessage(routeName) {
|
function insertRouteLabelForLastUserMessage(routeName) {
|
||||||
chrome.storage.sync.get(['preferences'], ({ preferences }) => {
|
chrome.storage.sync.get(['preferences'], ({ preferences }) => {
|
||||||
if (!Array.isArray(preferences)) return;
|
// Find the most recent user bubble
|
||||||
|
const bubbles = [...document.querySelectorAll('[data-message-author-role="user"]')];
|
||||||
|
const lastBubble = bubbles[bubbles.length - 1];
|
||||||
|
if (!lastBubble) return;
|
||||||
|
|
||||||
const match = preferences.find(p => p.name === routeName);
|
// Skip if we’ve already added a label
|
||||||
if (!match || !match.usage) {
|
if (lastBubble.querySelector('.arch-route-label')) {
|
||||||
console.log('[RouteLabel] No usage found for route:', routeName);
|
console.log('[RouteLabel] Label already exists, skipping');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bubbles = [...document.querySelectorAll('[data-message-author-role="user"]')];
|
// Default label text
|
||||||
const lastBubble = bubbles[bubbles.length - 1];
|
let labelText = 'RouteGPT: preference = default';
|
||||||
if (!lastBubble) return;
|
|
||||||
|
|
||||||
if (lastBubble.querySelector('.arch-route-label')) {
|
// Try to override with preference-based usage if we have a routeName
|
||||||
console.log('[RouteLabel] Label already exists, skipping');
|
if (routeName && Array.isArray(preferences)) {
|
||||||
return;
|
const match = preferences.find(p => p.name === routeName);
|
||||||
}
|
if (match && match.usage) {
|
||||||
|
labelText = `RouteGPT: preference = ${match.usage}`;
|
||||||
|
} else {
|
||||||
|
console.log('[RouteLabel] No usage found for route (falling back to default):', routeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const label = document.createElement('span');
|
// Build and attach the label
|
||||||
label.textContent = `RouteGPT: preference = ${match.usage}`;
|
const label = document.createElement('span');
|
||||||
label.className = 'arch-route-label';
|
label.textContent = labelText;
|
||||||
label.style.fontWeight = '100';
|
label.className = 'arch-route-label';
|
||||||
label.style.fontSize = '0.85rem';
|
label.style.fontWeight = '350';
|
||||||
label.style.marginTop = '4px';
|
label.style.fontSize = '0.85rem';
|
||||||
|
label.style.marginTop = '2px';
|
||||||
|
label.style.fontStyle = 'italic';
|
||||||
|
label.style.alignSelf = 'end';
|
||||||
|
label.style.marginRight = '5px';
|
||||||
|
|
||||||
lastBubble.appendChild(label);
|
lastBubble.appendChild(label);
|
||||||
console.log('[RouteLabel] Inserted label:', label.textContent);
|
console.log('[RouteLabel] Inserted label:', labelText);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -275,10 +286,9 @@ Based on your analysis, provide your response in the following JSON formats if y
|
||||||
} else {
|
} else {
|
||||||
console.log(`${TAG} Resolved model for route "${selectedRoute}" →`, targetModel);
|
console.log(`${TAG} Resolved model for route "${selectedRoute}" →`, targetModel);
|
||||||
}
|
}
|
||||||
insertRouteLabelForLastUserMessage(selectedRoute);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
insertRouteLabelForLastUserMessage(selectedRoute);
|
||||||
const modifiedBody = { ...originalBody };
|
const modifiedBody = { ...originalBody };
|
||||||
if (targetModel) {
|
if (targetModel) {
|
||||||
modifiedBody.model = targetModel;
|
modifiedBody.model = targetModel;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue