Skip to content

Commit 7a08066

Browse files
nexxelnmrsimpson
authored andcommitted
fix(app): hide default session timestamps (anomalyco#20892)
1 parent 5641b15 commit 7a08066

File tree

3 files changed

+57
-42
lines changed

3 files changed

+57
-42
lines changed

packages/app/src/pages/layout/sidebar-items.tsx

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { getAvatarColors, type LocalProject, useLayout } from "@/context/layout"
1616
import { useNotification } from "@/context/notification"
1717
import { usePermission } from "@/context/permission"
1818
import { messageAgentColor } from "@/utils/agent"
19+
import { sessionTitle } from "@/utils/session-title"
1920
import { sessionPermissionRequest } from "../session/composer/session-request-tree"
2021
import { hasProjectPermissions } from "./helpers"
2122

@@ -101,42 +102,46 @@ const SessionRow = (props: {
101102
warmPress: () => void
102103
warmFocus: () => void
103104
cancelHoverPrefetch: () => void
104-
}): JSX.Element => (
105-
<A
106-
href={`/${props.slug}/session/${props.session.id}`}
107-
class={`flex items-center gap-1 min-w-0 w-full text-left focus:outline-none ${props.dense ? "py-0.5" : "py-1"}`}
108-
onPointerDown={props.warmPress}
109-
onPointerEnter={props.warmHover}
110-
onPointerLeave={props.cancelHoverPrefetch}
111-
onFocus={props.warmFocus}
112-
onClick={() => {
113-
props.setHoverSession(undefined)
114-
if (props.sidebarOpened()) return
115-
props.clearHoverProjectSoon()
116-
}}
117-
>
118-
<div
119-
class="shrink-0 size-6 flex items-center justify-center"
120-
style={{ color: props.tint() ?? "var(--icon-interactive-base)" }}
105+
}) => {
106+
const title = () => sessionTitle(props.session.title)
107+
108+
return (
109+
<A
110+
href={`/${props.slug}/session/${props.session.id}`}
111+
class={`flex items-center gap-1 min-w-0 w-full text-left focus:outline-none ${props.dense ? "py-0.5" : "py-1"}`}
112+
onPointerDown={props.warmPress}
113+
onPointerEnter={props.warmHover}
114+
onPointerLeave={props.cancelHoverPrefetch}
115+
onFocus={props.warmFocus}
116+
onClick={() => {
117+
props.setHoverSession(undefined)
118+
if (props.sidebarOpened()) return
119+
props.clearHoverProjectSoon()
120+
}}
121121
>
122-
<Switch fallback={<Icon name="dash" size="small" class="text-icon-weak" />}>
123-
<Match when={props.isWorking()}>
124-
<Spinner class="size-[15px]" />
125-
</Match>
126-
<Match when={props.hasPermissions()}>
127-
<div class="size-1.5 rounded-full bg-surface-warning-strong" />
128-
</Match>
129-
<Match when={props.hasError()}>
130-
<div class="size-1.5 rounded-full bg-text-diff-delete-base" />
131-
</Match>
132-
<Match when={props.unseenCount() > 0}>
133-
<div class="size-1.5 rounded-full bg-text-interactive-base" />
134-
</Match>
135-
</Switch>
136-
</div>
137-
<span class="text-14-regular text-text-strong min-w-0 flex-1 truncate">{props.session.title}</span>
138-
</A>
139-
)
122+
<div
123+
class="shrink-0 size-6 flex items-center justify-center"
124+
style={{ color: props.tint() ?? "var(--icon-interactive-base)" }}
125+
>
126+
<Switch fallback={<Icon name="dash" size="small" class="text-icon-weak" />}>
127+
<Match when={props.isWorking()}>
128+
<Spinner class="size-[15px]" />
129+
</Match>
130+
<Match when={props.hasPermissions()}>
131+
<div class="size-1.5 rounded-full bg-surface-warning-strong" />
132+
</Match>
133+
<Match when={props.hasError()}>
134+
<div class="size-1.5 rounded-full bg-text-diff-delete-base" />
135+
</Match>
136+
<Match when={props.unseenCount() > 0}>
137+
<div class="size-1.5 rounded-full bg-text-interactive-base" />
138+
</Match>
139+
</Switch>
140+
</div>
141+
<span class="text-14-regular text-text-strong min-w-0 flex-1 truncate">{title()}</span>
142+
</A>
143+
)
144+
}
140145

141146
const SessionHoverPreview = (props: {
142147
mobile?: boolean
@@ -319,7 +324,7 @@ export const SessionItem = (props: SessionItemProps): JSX.Element => {
319324
fallback={
320325
<Tooltip
321326
placement={props.mobile ? "bottom" : "right"}
322-
value={props.session.title}
327+
value={sessionTitle(props.session.title)}
323328
gutter={10}
324329
class="min-w-0 w-full"
325330
>

packages/app/src/pages/session/message-timeline.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { useSettings } from "@/context/settings"
2929
import { useSDK } from "@/context/sdk"
3030
import { useSync } from "@/context/sync"
3131
import { messageAgentColor } from "@/utils/agent"
32+
import { sessionTitle } from "@/utils/session-title"
3233
import { parseCommentNote, readCommentMetadata } from "@/utils/comment-note"
3334
import { makeTimer } from "@solid-primitives/timer"
3435

@@ -43,7 +44,6 @@ type MessageComment = {
4344

4445
const emptyMessages: MessageType[] = []
4546
const idle = { type: "idle" as const }
46-
4747
type UserActions = {
4848
fork?: (input: { sessionID: string; messageID: string }) => Promise<void> | void
4949
revert?: (input: { sessionID: string; messageID: string }) => Promise<void> | void
@@ -291,6 +291,7 @@ export function MessageTimeline(props: {
291291
return sync.session.get(id)
292292
})
293293
const titleValue = createMemo(() => info()?.title)
294+
const titleLabel = createMemo(() => sessionTitle(titleValue()))
294295
const shareUrl = createMemo(() => info()?.share?.url)
295296
const shareEnabled = createMemo(() => sync.data.config.share !== "disabled")
296297
const parentID = createMemo(() => info()?.parentID)
@@ -399,7 +400,7 @@ export function MessageTimeline(props: {
399400

400401
const openTitleEditor = () => {
401402
if (!sessionID()) return
402-
setTitle({ editing: true, draft: titleValue() ?? "" })
403+
setTitle({ editing: true, draft: titleLabel() ?? "" })
403404
requestAnimationFrame(() => {
404405
titleRef?.focus()
405406
titleRef?.select()
@@ -417,7 +418,7 @@ export function MessageTimeline(props: {
417418
if (titleMutation.isPending) return
418419

419420
const next = title.draft.trim()
420-
if (!next || next === (titleValue() ?? "")) {
421+
if (!next || next === (titleLabel() ?? "")) {
421422
setTitle("editing", false)
422423
return
423424
}
@@ -532,7 +533,9 @@ export function MessageTimeline(props: {
532533
}
533534

534535
function DialogDeleteSession(props: { sessionID: string }) {
535-
const name = createMemo(() => sync.session.get(props.sessionID)?.title ?? language.t("command.session.new"))
536+
const name = createMemo(
537+
() => sessionTitle(sync.session.get(props.sessionID)?.title) ?? language.t("command.session.new"),
538+
)
536539
const handleDelete = async () => {
537540
await deleteSession(props.sessionID)
538541
dialog.close()
@@ -673,15 +676,15 @@ export function MessageTimeline(props: {
673676
</div>
674677
</Show>
675678
</div>
676-
<Show when={titleValue() || title.editing}>
679+
<Show when={titleLabel() || title.editing}>
677680
<Show
678681
when={title.editing}
679682
fallback={
680683
<h1
681684
class="text-14-medium text-text-strong truncate grow-1 min-w-0"
682685
onDblClick={openTitleEditor}
683686
>
684-
{titleValue()}
687+
{titleLabel()}
685688
</h1>
686689
}
687690
>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const pattern = /^(New session|Child session) - \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/
2+
3+
export function sessionTitle(title?: string) {
4+
if (!title) return title
5+
const match = title.match(pattern)
6+
return match?.[1] ?? title
7+
}

0 commit comments

Comments
 (0)