Richer disconnect log: user, product/feature, machine, match reason

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Michael-A-SloanandCursor committed 2026-05-05 15:25:08 -04:00
1 parent 4ef1f6849c
commit 09e29f6975
6 files changed
+87 -11

No files matched your search

+41 -3
View File
@@ -26,6 +26,44 @@
return { product: product, feature: feature };
}
/** Same column mapping as __ptw_getSessions — used for disconnect log lines. */
function rowSessionFields(row) {
var cells = row.querySelectorAll('td');
if (cells.length < 9) return { user: '', product: '', feature: '', machine: '' };
var product = (cells[3] && cells[3].innerText) ? cells[3].innerText.replace(/\s+/g, ' ').trim() : '';
var feature = (cells[4] && cells[4].innerText) ? cells[4].innerText.replace(/\s+/g, ' ').trim() : '';
var user = (cells[6] && cells[6].innerText) ? cells[6].innerText.trim() : '';
var machine = (cells[7] && cells[7].innerText) ? cells[7].innerText.trim() : '';
return { user: user, product: product, feature: feature, machine: machine };
}
function firstMatchingKeyword(feature) {
for (var i = 0; i < TARGET_KEYWORDS.length; i++) {
var k = TARGET_KEYWORDS[i];
if (feature.indexOf(k) !== -1) return k;
}
return null;
}
function disconnectReason(pf, keywordMatch, idMatch) {
var parts = [];
if (idMatch) parts.push('PTW70 feature module ' + pf.feature);
if (keywordMatch) {
var kw = firstMatchingKeyword(pf.feature);
if (kw) parts.push('feature contains ' + kw);
}
return parts.length ? parts.join('; ') : 'matched';
}
function formatDisconnectLog(sess, reason) {
var who = sess.user ? sess.user.trim() : '(unknown user)';
var where = [sess.product, sess.feature].filter(function (x) { return x && String(x).trim(); }).join(' · ');
if (!where) where = '(no product/feature)';
var machine = sess.machine ? sess.machine.trim() : '';
var hostPart = machine ? ' @ ' + machine : '';
return 'OUT: ' + who + hostPart + ' — ' + where + ' — ' + reason;
}
function isPtw70Product(product) {
return product.indexOf('PTW70') !== -1;
}
@@ -43,15 +81,15 @@
if (!window.__ptw_running) return;
const rows = document.querySelectorAll('#mydata table.list tr');
rows.forEach(function (row) {
const rowText = row.innerText;
var pf = productFeatureCells(row);
const keywordMatch = matchesKeywordInFeature(pf.feature);
const idMatch = matchesFeatureId(pf.product, pf.feature);
if (keywordMatch || idMatch) {
const disconnectLink = row.querySelector('a.sbutton');
if (disconnectLink && disconnectLink.textContent.indexOf('Disconnect') !== -1) {
const itemName = (rowText.split('\t')[0] || '').trim() || 'Item';
addLog('OUT: ' + itemName);
var sess = rowSessionFields(row);
var reason = disconnectReason(pf, keywordMatch, idMatch);
addLog(formatDisconnectLog(sess, reason));
disconnectLink.click();
}
}