Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

feat: link workflow editor from slash help

Emre Sokulluc7d9c9d0054d
diff --git a/src/chrome/src/ui/sidepanel.js b/src/chrome/src/ui/sidepanel.js
index de7f11802..3b61385f6 100644
--- a/src/chrome/src/ui/sidepanel.js
+++ b/src/chrome/src/ui/sidepanel.js
@@ -896,6 +896,14 @@ function slashOptionIsDiscoverable(option) {
return option?.unsupported !== true;
}
+function slashOptionDescriptionHtml(command, option) {
+ const description = escapeHtml(t(option.descriptionKey));
+ if (command.value !== '/workflow' || !['--save', '--export', '--import'].includes(option.value)) {
+ return description;
+ }
+ return `${description} <a href="https://webbrain.one/workflow-editor/" target="_blank" rel="noopener noreferrer">Workflow editor</a>`;
+}
+
function slashOptionIsAvailable(option, selectedValues, selectedGroups) {
return slashOptionIsDiscoverable(option)
&& !selectedValues.has(option.value)
@@ -1015,7 +1023,7 @@ function buildSlashCommandHelpHtml() {
lines.push(`<code>${escapeHtml(command.usage)}</code> β€” ${escapeHtml(t(command.descriptionKey))}`);
for (const option of (command.options || []).filter(slashOptionIsDiscoverable)) {
const value = `${option.value}${option.valueLabel ? ` ${option.valueLabel}` : ''}`;
- lines.push(`&nbsp;&nbsp;<code>${escapeHtml(value)}</code> β€” ${escapeHtml(t(option.descriptionKey))}`);
+ lines.push(`&nbsp;&nbsp;<code>${escapeHtml(value)}</code> β€” ${slashOptionDescriptionHtml(command, option)}`);
}
}
const shortcuts = t('sp.help.shortcuts_html');
@@ -1033,7 +1041,7 @@ function buildSlashCommandDetailHtml(command) {
];
for (const option of (command.options || []).filter(slashOptionIsDiscoverable)) {
const value = `${option.value}${option.valueLabel ? ` ${option.valueLabel}` : ''}`;
- lines.push(`&nbsp;&nbsp;<code>${escapeHtml(value)}</code> β€” ${escapeHtml(t(option.descriptionKey))}`);
+ lines.push(`&nbsp;&nbsp;<code>${escapeHtml(value)}</code> β€” ${slashOptionDescriptionHtml(command, option)}`);
}
return lines.join('<br>');
}
diff --git a/src/firefox/src/ui/sidepanel.js b/src/firefox/src/ui/sidepanel.js
index 5e61977d7..65fe17492 100644
--- a/src/firefox/src/ui/sidepanel.js
+++ b/src/firefox/src/ui/sidepanel.js
@@ -771,6 +771,14 @@ function slashOptionIsDiscoverable(option) {
return option?.unsupported !== true;
}
+function slashOptionDescriptionHtml(command, option) {
+ const description = escapeHtml(t(option.descriptionKey));
+ if (command.value !== '/workflow' || !['--save', '--export', '--import'].includes(option.value)) {
+ return description;
+ }
+ return `${description} <a href="https://webbrain.one/workflow-editor/" target="_blank" rel="noopener noreferrer">Workflow editor</a>`;
+}
+
function slashOptionIsAvailable(option, selectedValues, selectedGroups) {
return slashOptionIsDiscoverable(option)
&& !selectedValues.has(option.value)
@@ -890,7 +898,7 @@ function buildSlashCommandHelpHtml() {
lines.push(`<code>${escapeHtml(command.usage)}</code> β€” ${escapeHtml(t(command.descriptionKey))}`);
for (const option of (command.options || []).filter(slashOptionIsDiscoverable)) {
const value = `${option.value}${option.valueLabel ? ` ${option.valueLabel}` : ''}`;
- lines.push(`&nbsp;&nbsp;<code>${escapeHtml(value)}</code> β€” ${escapeHtml(t(option.descriptionKey))}`);
+ lines.push(`&nbsp;&nbsp;<code>${escapeHtml(value)}</code> β€” ${slashOptionDescriptionHtml(command, option)}`);
}
}
const shortcuts = t('sp.help.shortcuts_html');
@@ -908,7 +916,7 @@ function buildSlashCommandDetailHtml(command) {
];
for (const option of (command.options || []).filter(slashOptionIsDiscoverable)) {
const value = `${option.value}${option.valueLabel ? ` ${option.valueLabel}` : ''}`;
- lines.push(`&nbsp;&nbsp;<code>${escapeHtml(value)}</code> β€” ${escapeHtml(t(option.descriptionKey))}`);
+ lines.push(`&nbsp;&nbsp;<code>${escapeHtml(value)}</code> β€” ${slashOptionDescriptionHtml(command, option)}`);
}
return lines.join('<br>');
}
diff --git a/test/run.js b/test/run.js
index 3a1686bb5..070251559 100644
--- a/test/run.js
+++ b/test/run.js
@@ -43601,6 +43601,17 @@ test('canonical slash parser handles flags, values, casing, termination, and har
assert.ok(!chromeHelp.includes(text.split(' ')[0]), `Chrome help must omit retired syntax ${text}`);
}
+ for (const [label, runtime] of [['chrome', chrome], ['firefox', firefox]]) {
+ const workflow = runtime.SLASH_COMMANDS.find((command) => command.value === '/workflow');
+ const link = '<a href="https://webbrain.one/workflow-editor/" target="_blank" rel="noopener noreferrer">Workflow editor</a>';
+ const detail = runtime.buildSlashCommandDetailHtml(workflow);
+ assert.equal((detail.match(/<a href="https:\/\/webbrain\.one\/workflow-editor\/"/g) || []).length, 3, `${label}: workflow save, export, and import help should link to the editor`);
+ assert.ok(detail.includes(`sp.slash.save_workflow ${link}`), `${label}: --save help should end with the workflow editor link`);
+ assert.ok(detail.includes(`sp.slash.workflows ${link}`), `${label}: --export and --import help should end with the workflow editor link`);
+ assert.equal((runtime.buildSlashCommandHelpHtml().match(/<a href="https:\/\/webbrain\.one\/workflow-editor\/"/g) || []).length, 3, `${label}: global slash help should include the editor link for workflow file actions`);
+ assert.ok(!runtime.buildSlashCommandDetailHtml(runtime.SLASH_COMMANDS.find((command) => command.value === '/export')).includes(link), `${label}: unrelated --export command should not link to the workflow editor`);
+ }
+
assert.equal(firefox.parseSlashInvocation('/record --full-screen --transcribe').unsupported, true, 'Firefox should reject canonical recording locally');
assert.equal(firefox.parseSlashInvocation('/screenshot --full-page').unsupported, true, 'Firefox should reject the unsupported canonical screenshot flag locally');
assert.equal(firefox.SLASH_COMMANDS.find((command) => command.value === '/record').unsupported, true, 'Firefox recording should be hidden from discovery');