Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions src/components/FastNav.astro
Original file line number Diff line number Diff line change
Expand Up @@ -118,29 +118,6 @@
oldToc.innerHTML = newToc.innerHTML;
}

// Swap API right panel (for API pages with two-column layout)
var newRight = doc.getElementById('api-right-panel');
var oldRight = document.getElementById('api-right-panel');
if (newRight && oldRight) {
oldRight.innerHTML = newRight.innerHTML;
}
// Also move any new .apg-right-panel into the aside
var newApgRight = document.querySelector('article .apg-right-panel');
if (newApgRight && oldRight) {
oldRight.innerHTML = '';
oldRight.appendChild(newApgRight);
newApgRight.style.display = 'block';
}

// Re-run inline scripts from the new content (ApiPlayground JS)
var newScripts = doc.querySelectorAll('article script, .apg-right-panel script');
newScripts.forEach(function(oldScript) {
var newScript = document.createElement('script');
newScript.textContent = oldScript.textContent;
document.body.appendChild(newScript);
document.body.removeChild(newScript);
});

// Update document title
var newTitle = doc.querySelector('title');
if (newTitle) document.title = newTitle.textContent;
Expand All @@ -152,6 +129,31 @@
oldSidebar.innerHTML = newSidebar.innerHTML;
}

// Re-execute inline scripts in swapped article
// (innerHTML doesn't execute <script> tags — clone them so the browser runs them)
// This populates ApiPlayground code displays, sets up event listeners, etc.
if (oldArticle) {
oldArticle.querySelectorAll('script').forEach(function(dead) {
var live = document.createElement('script');
Array.from(dead.attributes).forEach(function(a) {
live.setAttribute(a.name, a.value);
});
live.textContent = dead.textContent;
dead.parentNode.replaceChild(live, dead);
});
}

// Move ApiPlayground's .apg-right-panel into the aside (AFTER scripts have populated it)
var rightPanel = document.getElementById('api-right-panel');
if (rightPanel) {
rightPanel.innerHTML = '';
var newPanel = document.querySelector('.apg-right-panel');
if (newPanel) {
rightPanel.appendChild(newPanel);
newPanel.style.display = 'block';
}
}

// Scroll content to top
var main = document.querySelector('main');
if (main) main.scrollTop = 0;
Expand Down Expand Up @@ -195,8 +197,11 @@
}
});

// Cache current page
pageCache[window.location.pathname] = document.documentElement.outerHTML;
// Cache current page from server (not live DOM which has JS mutations)
fetch(window.location.pathname)
.then(function(r) { return r.text(); })
.then(function(html) { pageCache[window.location.pathname] = html; })
.catch(function() {});

// Prefetch visible sidebar links into cache
function prefetchVisible() {
Expand All @@ -221,7 +226,6 @@

// Re-init on Astro view transitions (fallback)
document.addEventListener('astro:page-load', function() {
pageCache[window.location.pathname] = document.documentElement.outerHTML;
initFastNav();
setTimeout(prefetchVisible, 500);
});
Expand Down
30 changes: 15 additions & 15 deletions src/components/Sidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -402,38 +402,38 @@ function inferApiMethod(title: string): { method: string; css: string } | null {
}
}

var SCROLL_KEY = 'sidebar-scroll';

function saveScroll() {
function scrollToActiveItem() {
var nav = document.querySelector('#sidebar nav');
if (nav) sessionStorage.setItem(SCROLL_KEY, nav.scrollTop);
}

function restoreScroll() {
var saved = sessionStorage.getItem(SCROLL_KEY);
if (saved !== null) {
var nav = document.querySelector('#sidebar nav');
if (nav) nav.scrollTop = parseInt(saved, 10);
if (!nav) return;
// Find the active link — it has font-medium + bg-hover styling applied server-side
var active = nav.querySelector('a.font-medium');
if (!active) return;
// Calculate position relative to the nav scroll container
var navRect = nav.getBoundingClientRect();
var activeRect = active.getBoundingClientRect();
// Only scroll if the active item is outside the visible area
if (activeRect.top < navRect.top || activeRect.bottom > navRect.bottom) {
var offset = active.offsetTop - nav.offsetTop - navRect.height / 3;
nav.scrollTop = Math.max(0, offset);
}
}

setupSidebar();
restoreScroll();
scrollToActiveItem();

// Register global listeners only once (script re-executes on view transitions)
if (!window.__sidebarListenersReady) {
window.__sidebarListenersReady = true;

document.addEventListener('astro:before-swap', saveScroll);

document.addEventListener('astro:page-load', function() {
setupSidebar();
restoreScroll();
scrollToActiveItem();
});

// Re-init after FastNav swaps sidebar innerHTML
window.addEventListener('fastnav', function() {
setupSidebar();
scrollToActiveItem();
});
}

Expand Down
44 changes: 23 additions & 21 deletions src/components/docs/ApiCollapsible.astro
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,31 @@ const cid = `apic-${Math.random().toString(36).slice(2, 8)}`;
</div>
</div>

<script is:inline define:vars={{ cid, title }}>
(function(){
var el = document.getElementById(cid);
if (!el || el._apicBound) return;
el._apicBound = true;
<script is:inline>
function initApiCollapsibles() {
document.querySelectorAll('.api-collapsible').forEach(function(el) {
if (el._apicBound) return;
el._apicBound = true;

var trigger = el.querySelector('[data-apic-trigger]');
var content = el.querySelector('[data-apic-content]');
var icon = el.querySelector('[data-apic-icon]');
var label = el.querySelector('[data-apic-label]');
var isOpen = false;
var trigger = el.querySelector('[data-apic-trigger]');
var icon = el.querySelector('[data-apic-icon]');
var label = el.querySelector('[data-apic-label]');
var isOpen = false;
var showTitle = label ? label.textContent : 'Show properties';
var hideTitle = showTitle.replace(/^Show\b/, 'Hide');

var openTitle = title.replace(/^Show\b/, 'Hide');

if (trigger) {
trigger.addEventListener('click', function() {
isOpen = !isOpen;
el.classList.toggle('api-collapsible-open', isOpen);
if (icon) icon.textContent = isOpen ? '\u00d7' : '+';
if (label) label.textContent = isOpen ? openTitle : title;
});
}
})();
if (trigger) {
trigger.addEventListener('click', function() {
isOpen = !isOpen;
el.classList.toggle('api-collapsible-open', isOpen);
if (icon) icon.textContent = isOpen ? '\u00d7' : '+';
if (label) label.textContent = isOpen ? hideTitle : showTitle;
});
}
});
}
initApiCollapsibles();
document.addEventListener('astro:page-load', initApiCollapsibles);
</script>

<style is:global>
Expand Down
180 changes: 180 additions & 0 deletions src/lib/api-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,36 @@ export const apiNavigation: ApiNavGroup[] = [
}
]
},
{
"title": "Personas",
"items": [
{
"title": "List personas",
"href": "/docs/api/personas/listpersonas",
"method": "GET"
},
{
"title": "Create persona",
"href": "/docs/api/personas/createpersona",
"method": "POST"
},
{
"title": "Update persona",
"href": "/docs/api/personas/updatepersona",
"method": "PATCH"
},
{
"title": "Delete persona",
"href": "/docs/api/personas/deletepersona",
"method": "DELETE"
},
{
"title": "Duplicate persona",
"href": "/docs/api/personas/duplicatepersona",
"method": "POST"
}
]
},
{
"title": "Agent Definitions",
"items": [
Expand Down Expand Up @@ -132,15 +162,165 @@ export const apiNavigation: ApiNavGroup[] = [
{
"title": "Run Tests",
"items": [
{
"title": "List test runs",
"href": "/docs/api/run-tests/listruntests",
"method": "GET"
},
{
"title": "Create a New Test Run",
"href": "/docs/api/run-tests/createruntest",
"method": "POST"
},
{
"title": "Get test run details",
"href": "/docs/api/run-tests/getruntestdetails",
"method": "GET"
},
{
"title": "Delete a test run",
"href": "/docs/api/run-tests/deleteruntest",
"method": "DELETE"
},
{
"title": "Execute a test run",
"href": "/docs/api/run-tests/executeruntest",
"method": "POST"
},
{
"title": "Update test run components",
"href": "/docs/api/run-tests/updatetestcomponents",
"method": "PATCH"
},
{
"title": "Get test executions",
"href": "/docs/api/run-tests/gettestexecutions",
"method": "GET"
},
{
"title": "Get scenarios for a test run",
"href": "/docs/api/run-tests/gettestscenarios",
"method": "GET"
},
{
"title": "Get call executions for a test run",
"href": "/docs/api/run-tests/getcallexecutions",
"method": "GET"
},
{
"title": "Get evaluation summary",
"href": "/docs/api/run-tests/getevalsummary",
"method": "GET"
},
{
"title": "Compare evaluation summaries",
"href": "/docs/api/run-tests/compareevalsummaries",
"method": "GET"
},
{
"title": "Add evaluation configurations",
"href": "/docs/api/run-tests/addevalconfigs",
"method": "POST"
},
{
"title": "Update evaluation configuration",
"href": "/docs/api/run-tests/updateevalconfig",
"method": "PATCH"
},
{
"title": "Delete evaluation configuration",
"href": "/docs/api/run-tests/deleteevalconfig",
"method": "DELETE"
},
{
"title": "Run new evaluations on test executions",
"href": "/docs/api/run-tests/runnewevalsontestexecution",
"method": "POST"
},
{
"title": "Rerun test executions",
"href": "/docs/api/run-tests/reruntestexecutions",
"method": "POST"
},
{
"title": "Delete test executions",
"href": "/docs/api/run-tests/deletetestexecutions",
"method": "POST"
}
]
},
{
"title": "Test Executions",
"items": [
{
"title": "Get test execution details",
"href": "/docs/api/test-executions/gettestexecutiondetails",
"method": "GET"
},
{
"title": "Get execution KPIs",
"href": "/docs/api/test-executions/getkpis",
"method": "GET"
},
{
"title": "Get performance summary",
"href": "/docs/api/test-executions/getperformancesummary",
"method": "GET"
},
{
"title": "Get eval explanation summary",
"href": "/docs/api/test-executions/getevalexplanationsummary",
"method": "GET"
},
{
"title": "Cancel test execution",
"href": "/docs/api/test-executions/cancelexecution",
"method": "POST"
},
{
"title": "Rerun call executions",
"href": "/docs/api/test-executions/reruncalls",
"method": "POST"
}
]
},
{
"title": "Call Executions",
"items": [
{
"title": "Get call execution details",
"href": "/docs/api/call-executions/getcallexecutiondetails",
"method": "GET"
},
{
"title": "Compare execution sessions",
"href": "/docs/api/call-executions/getsessioncomparison",
"method": "GET"
}
]
},
{
"title": "Prompt Simulations",
"items": [
{
"title": "List prompt simulation scenarios",
"href": "/docs/api/prompt-simulations/listscenarios",
"method": "GET"
},
{
"title": "List simulations for prompt template",
"href": "/docs/api/prompt-simulations/listsimulations",
"method": "GET"
},
{
"title": "Get prompt simulation details",
"href": "/docs/api/prompt-simulations/getsimulationdetails",
"method": "GET"
},
{
"title": "Execute prompt simulation",
"href": "/docs/api/prompt-simulations/executesimulation",
"method": "POST"
}
]
},
Expand Down
Loading