Skip to content

The only tool you need to know what is happening and how to fix it.

fix: minor UI bugs (#221)

narrow-adventure9bfd80795f04
diff --git a/backend/app/controllers/log.controller.go b/backend/app/controllers/log.controller.go
index bf17cf17..31297c04 100644
--- a/backend/app/controllers/log.controller.go
+++ b/backend/app/controllers/log.controller.go
@@ -115,7 +115,7 @@ func (l logController) List(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid distributedTraceId"})
return
}
- traceIds, err := l.resolveDistributedTraceIds(c, dtid, projectId, request.ExcludeTraceId)
+ traceIds, err := l.resolveDistributedTraceIds(c, dtid, projectId, request.ExcludeTraceId, request.FromDate)
if err != nil {
c.AbortWithError(500, traceway.NewStackTraceErrorf("error resolving distributed trace: %w", err))
return
@@ -155,18 +155,23 @@ func (l logController) List(c *gin.Context) {
})
}
-func (l logController) resolveDistributedTraceIds(ctx context.Context, dtid uuid.UUID, projectId uuid.UUID, excludeTraceHex string) ([]string, error) {
+func (l logController) resolveDistributedTraceIds(ctx context.Context, dtid uuid.UUID, projectId uuid.UUID, excludeTraceHex string, recordedAt time.Time) ([]string, error) {
projectIds := []uuid.UUID{projectId}
- endpoints, err := repositories.EndpointRepository.FindByDistributedTraceId(ctx, dtid, projectIds, nil)
+ var recordedAtHint *time.Time
+ if !recordedAt.IsZero() {
+ recordedAtHint = &recordedAt
+ }
+
+ endpoints, err := repositories.EndpointRepository.FindByDistributedTraceId(ctx, dtid, projectIds, recordedAtHint)
if err != nil {
return nil, err
}
- tasks, err := repositories.TaskRepository.FindByDistributedTraceId(ctx, dtid, projectIds, nil)
+ tasks, err := repositories.TaskRepository.FindByDistributedTraceId(ctx, dtid, projectIds, recordedAtHint)
if err != nil {
return nil, err
}
- aiTraces, err := repositories.AiTraceRepository.FindByDistributedTraceId(ctx, dtid, projectIds, nil)
+ aiTraces, err := repositories.AiTraceRepository.FindByDistributedTraceId(ctx, dtid, projectIds, recordedAtHint)
if err != nil {
return nil, err
}
diff --git a/frontend/src/lib/components/distributed-trace/distributed-trace-card.svelte b/frontend/src/lib/components/distributed-trace/distributed-trace-card.svelte
index 8079f681..fd1bc2ca 100644
--- a/frontend/src/lib/components/distributed-trace/distributed-trace-card.svelte
+++ b/frontend/src/lib/components/distributed-trace/distributed-trace-card.svelte
@@ -8,17 +8,31 @@
import { LoadingCircle } from '$lib/components/ui/loading-circle';
import { formatDuration, getStatusColor, formatDateTime } from '$lib/utils/formatters';
import { getTimezone } from '$lib/state/timezone.svelte';
- import { projectsState } from '$lib/state/projects.svelte';
import { ArrowRight, GitBranch } from 'lucide-svelte';
import type { DistributedTraceResponse, DistributedTraceNode } from '$lib/types/distributed-trace';
interface Props {
distributedTraceId: string;
currentExceptionHash?: string;
+ currentNodeId?: string;
recordedAt?: string;
}
- let { distributedTraceId, currentExceptionHash, recordedAt }: Props = $props();
+ let { distributedTraceId, currentExceptionHash, currentNodeId, recordedAt }: Props = $props();
+
+ function isCurrentNode(node: DistributedTraceNode): boolean {
+ if (currentExceptionHash && node.traceType === 'exception') {
+ return node.exception?.exceptionHash === currentExceptionHash;
+ }
+ if (currentNodeId) {
+ return (
+ node.endpoint?.id === currentNodeId ||
+ node.task?.id === currentNodeId ||
+ node.aiTrace?.id === currentNodeId
+ );
+ }
+ return false;
+ }
const timezone = $derived(getTimezone());
@@ -42,15 +56,21 @@
}
function navigateToNode(node: DistributedTraceNode) {
- projectsState.selectProject(node.projectId);
+ const project = `&projectId=${encodeURIComponent(node.projectId)}`;
if (node.traceType === 'task' && node.task) {
- goto(`/tasks/${encodeURIComponent(node.task.taskName)}/${node.task.id}?preset=24h`);
+ goto(
+ `/tasks/${encodeURIComponent(node.task.taskName)}/${node.task.id}?preset=24h&t=${encodeURIComponent(node.task.recordedAt)}${project}`
+ );
} else if (node.traceType === 'ai_trace' && node.aiTrace) {
- goto(`/ai-traces/${encodeURIComponent(node.aiTrace.traceName)}/${node.aiTrace.id}?preset=24h`);
+ goto(
+ `/ai-traces/${encodeURIComponent(node.aiTrace.traceName)}/${node.aiTrace.id}?preset=24h&t=${encodeURIComponent(node.aiTrace.recordedAt)}${project}`
+ );
} else if (node.traceType === 'exception' && node.exception) {
- goto(`/issues/${node.exception.exceptionHash}?preset=24h`);
+ goto(`/issues/${node.exception.exceptionHash}?preset=24h${project}`);
} else if (node.endpoint) {
- goto(`/endpoints/${encodeURIComponent(node.endpoint.endpoint)}/${node.endpoint.id}?preset=24h`);
+ goto(
+ `/endpoints/${encodeURIComponent(node.endpoint.endpoint)}/${node.endpoint.id}?preset=24h&t=${encodeURIComponent(node.endpoint.recordedAt)}${project}`
+ );
}
}
@@ -125,7 +145,7 @@
<Badge variant="destructive" class="shrink-0">Exception</Badge>
{/if}
</div>
- {#if currentExceptionHash && node.traceType === 'exception' && node.exception?.exceptionHash === currentExceptionHash}
+ {#if isCurrentNode(node)}
<Badge class="bg-blue-500 hover:bg-blue-500 text-white">You're here</Badge>
{:else}
<Button variant="ghost" size="sm" onclick={() => navigateToNode(node)}>
diff --git a/frontend/src/lib/utils/navigation.ts b/frontend/src/lib/utils/navigation.ts
index 6e9c2a23..29a944e8 100644
--- a/frontend/src/lib/utils/navigation.ts
+++ b/frontend/src/lib/utils/navigation.ts
@@ -1,22 +1,28 @@
import { goto } from '$app/navigation';
export function addStickyParamsToHref(href: string, ...stickyParams: string[]) {
- let finalHref = href;
-
- if (stickyParams.length > 0) {
- const currentParams = new URLSearchParams(window.location.search);
- const url = new URL(href, window.location.origin);
+ const currentParams = new URLSearchParams(window.location.search);
+ const url = new URL(href, window.location.origin);
+
+ // projectId is the source of truth for the selected project, so it is always
+ // sticky. An explicit projectId already in href (e.g. a cross-project link)
+ // wins over the current one.
+ if (!url.searchParams.has('projectId')) {
+ const currentProjectId = currentParams.get('projectId');
+ if (currentProjectId !== null) {
+ url.searchParams.set('projectId', currentProjectId);
+ }
+ }
- stickyParams.forEach(stickyParam => {
- const currentValue = currentParams.get(stickyParam);
- if (currentValue !== null) {
- url.searchParams.set(stickyParam, currentValue);
- }
- });
+ stickyParams.forEach(stickyParam => {
+ if (stickyParam === 'projectId') return;
+ const currentValue = currentParams.get(stickyParam);
+ if (currentValue !== null) {
+ url.searchParams.set(stickyParam, currentValue);
+ }
+ });
- finalHref = url.pathname + url.search;
- }
- return finalHref;
+ return url.pathname + url.search;
}
// in the future it would be really cool if we could bind the type here to get type safety and force the use of resolve :/
diff --git a/frontend/src/lib/utils/url-params.ts b/frontend/src/lib/utils/url-params.ts
index 64e942aa..6fffc04f 100644
--- a/frontend/src/lib/utils/url-params.ts
+++ b/frontend/src/lib/utils/url-params.ts
@@ -90,9 +90,16 @@ export function updateUrl(
const { pushToHistory = false } = options;
const urlParams = new URLSearchParams();
+ const currentProjectId = new URLSearchParams(window.location.search).get('projectId');
+ if (currentProjectId) {
+ urlParams.set('projectId', currentProjectId);
+ }
+
for (const [key, value] of Object.entries(params)) {
if (value != null && value !== '') {
urlParams.set(key, value);
+ } else {
+ urlParams.delete(key);
}
}
diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte
index e5db3bed..3baff413 100644
--- a/frontend/src/routes/+layout.svelte
+++ b/frontend/src/routes/+layout.svelte
@@ -35,11 +35,27 @@
const bannerOrganizationId = $derived(projectsState.currentProject?.organizationId ?? null);
+ const PUBLIC_PATHS = new Set([
+ '/login',
+ '/register',
+ '/auth/callback',
+ '/finish-setup',
+ '/forgot-password',
+ '/reset-password'
+ ]);
+
+ function isProjectScopedPath(pathname: string): boolean {
+ if (PUBLIC_PATHS.has(pathname)) return false;
+ if (pathname.startsWith('/accept-invitation')) return false;
+ return true;
+ }
+
// Track navigation depth for smart back buttons
let lastPathname = '';
afterNavigate((navigation) => {
if (!navigation.to?.url) return;
- const newPathname = navigation.to.url.pathname;
+ const newUrl = navigation.to.url;
+ const newPathname = newUrl.pathname;
if (navigation.type === 'popstate') {
// Browser back/forward button
@@ -51,6 +67,24 @@
// Param-only changes (same pathname) don't affect depth
lastPathname = newPathname;
+
+ // Make the URL the source of truth for the selected project: stamp the
+ // current project onto any project-scoped URL that lacks one, so the back
+ // button, reloads, and shared links all resolve to the right project.
+ if (
+ authState.isAuthenticated &&
+ isProjectScopedPath(newPathname) &&
+ projectsState.currentProjectId &&
+ !newUrl.searchParams.get('projectId')
+ ) {
+ const canonical = new URL(newUrl);
+ canonical.searchParams.set('projectId', projectsState.currentProjectId);
+ goto(canonical.pathname + canonical.search, {
+ replaceState: true,
+ noScroll: true,
+ keepFocus: true
+ });
+ }
});
onMount(() => {
@@ -76,8 +110,7 @@
}
function handleProjectSelect(projectId: string) {
- projectsState.selectProject(projectId);
- goto('/');
+ goto(`/?projectId=${projectId}`);
}
function handleAddProjectClick() {
diff --git a/frontend/src/routes/+layout.ts b/frontend/src/routes/+layout.ts
index 09a24d33..b066737c 100644
--- a/frontend/src/routes/+layout.ts
+++ b/frontend/src/routes/+layout.ts
@@ -1,2 +1,15 @@
+import { browser } from '$app/environment';
+
export const ssr = false;
-export const prerender = true;
\ No newline at end of file
+export const prerender = true;
+
+export const load = async ({ url }) => {
+ if (browser) {
+ const projectId = url.searchParams.get('projectId');
+ if (projectId) {
+ const { projectsState } = await import('$lib/state/projects.svelte');
+ projectsState.selectProject(projectId);
+ }
+ }
+ return {};
+};
diff --git a/frontend/src/routes/endpoints/[endpoint]/[endpointId]/+page.svelte b/frontend/src/routes/endpoints/[endpoint]/[endpointId]/+page.svelte
index b357186b..e076e82d 100644
--- a/frontend/src/routes/endpoints/[endpoint]/[endpointId]/+page.svelte
+++ b/frontend/src/routes/endpoints/[endpoint]/[endpointId]/+page.svelte
@@ -284,6 +284,7 @@
{#if response.endpoint.distributedTraceId}
<DistributedTraceCard
distributedTraceId={response.endpoint.distributedTraceId}
+ currentNodeId={response.endpoint.id}
recordedAt={response.endpoint.recordedAt}
/>
{/if}
diff --git a/frontend/src/routes/tasks/[task]/[taskId]/+page.svelte b/frontend/src/routes/tasks/[task]/[taskId]/+page.svelte
index 04ecdba1..741a3fa1 100644
--- a/frontend/src/routes/tasks/[task]/[taskId]/+page.svelte
+++ b/frontend/src/routes/tasks/[task]/[taskId]/+page.svelte
@@ -283,6 +283,7 @@
{#if response.task.distributedTraceId}
<DistributedTraceCard
distributedTraceId={response.task.distributedTraceId}
+ currentNodeId={response.task.id}
recordedAt={response.task.recordedAt}
/>
{/if}