Skip to content

Commit c11f278

Browse files
committed
revert(search): restore Emir's Search surface and source row markup
Back to his last version (ecd02bc) of the Search surface, its CSS and the source row, which returns to _components/search with his .row, .rowTitle, .quiet and .snippet rules. Kept logic: useSearchField drafts, scope-built paths, nuqs state, URL-less and unavailable sources (no link, no actions), Summarize, Copy link and the Sim link entry. Withdrawn: the main landmark, Assistant's New chat button, the coarse-pointer touch targets and the Unavailable status label. The search and people e2e scripts drop the checks for the withdrawn New chat and narrow-row summary; the parity ledger holds both as Open for the design owner.
1 parent a69c99d commit c11f278

15 files changed

Lines changed: 63 additions & 142 deletions

File tree

‎apps/sim/app/(product)/_components/chat/message/message-sources.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useRef, useState } from 'react'
44
import { Button } from '@sim/emcn/button'
55
import { AnchoredPopover } from '@sim/emcn/menu/anchored-popover'
66
import styles from '@/app/(product)/_components/chat/message/message.module.css'
7-
import { SourceRow } from '@/app/(product)/_components/source-row/source-row'
7+
import { SourceRow } from '@/app/(product)/_components/search/source-row'
88
import type { ChatSource } from '@/platform/lib/data/models/chat'
99
import { plural } from '@/platform/shared/plural'
1010

‎apps/sim/app/(product)/_components/chat/panel/cited-sources.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { EmptyState } from '@sim/emcn/empty-state'
44
import styles from '@/app/(product)/_components/chat/panel/panels.module.css'
5-
import { SourceRow } from '@/app/(product)/_components/source-row/source-row'
5+
import { SourceRow } from '@/app/(product)/_components/search/source-row'
66
import type { ChatSource } from '@/platform/lib/data/models/chat'
77

88
/** Every document one answer cited, in the same row a search result and the reply's list use. */

‎apps/sim/app/(product)/_components/live-shell/live-shell.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { resolveLiveDestinations } from '@/app/(product)/_components/destination
66
import { LiveComposerHost } from '@/app/(product)/_components/live-shell/live-composer-host'
77
import { StaleSession } from '@/app/(product)/_components/live-shell/stale-session'
88
import { ProductSession } from '@/app/(product)/_components/product-session'
9+
import { LiveSourceLinks } from '@/app/(product)/_components/search/live-source-links'
910
import { SessionState } from '@/app/(product)/_components/session-state/session-state'
1011
import { AccessDenied, SurfaceUnavailable } from '@/app/(product)/_components/shell-gate/shell-gate'
11-
import { LiveSourceLinks } from '@/app/(product)/_components/source-row/live-source-links'
1212
import { prefetchShell } from '@/platform/lib/data/prefetch-shell'
1313
import { LiveProviders } from '@/platform/lib/data/providers'
1414
import {

apps/sim/app/(product)/_components/source-row/live-source-links.tsx renamed to apps/sim/app/(product)/_components/search/live-source-links.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
SourceActionsMenu,
77
type SourceActionsProps,
88
SourceActionsProvider,
9-
} from '@/app/(product)/_components/source-row/source-row'
9+
} from '@/app/(product)/_components/search/source-row'
1010
import { type LinkDraft, useSourceLinkAction } from '@/platform/lib/data/links'
1111
import { useOrganization } from '@/platform/lib/data/organization'
1212

‎apps/sim/app/(product)/_components/search/search-results.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { DateRangePicker } from '@sim/emcn/picker/date-picker'
88
import { FailureNotice, InlineNotice } from '@sim/emcn/status'
99
import Link from 'next/link'
1010
import styles from '@/app/(product)/_components/search/search.module.css'
11-
import { SourceRow } from '@/app/(product)/_components/source-row/source-row'
11+
import { SourceRow } from '@/app/(product)/_components/search/source-row'
1212
import type { SearchResultsData } from '@/platform/lib/data/models/search'
1313

1414
function moveFocus(event: KeyboardEvent<HTMLElement>) {

‎apps/sim/app/(product)/_components/search/search.module.css‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,23 @@
1111
justify-content: flex-end;
1212
gap: var(--ui-action-gap);
1313
}
14+
.row {
15+
display: flex;
16+
align-items: center;
17+
justify-content: space-between;
18+
gap: var(--ui-row-gap);
19+
min-inline-size: 0;
20+
}
21+
.rowTitle {
22+
min-inline-size: 0;
23+
}
24+
.rowTitle:hover {
25+
text-decoration: underline;
26+
}
27+
.quiet,
28+
.snippet {
29+
color: var(--ui-secondary);
30+
}
31+
.snippet {
32+
overflow-wrap: anywhere;
33+
}

apps/sim/app/(product)/_components/source-row/source-row.tsx renamed to apps/sim/app/(product)/_components/search/source-row.tsx

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import { ActivityBody } from '@sim/emcn/activity-row/activity-body'
55
import { useClipboard } from '@sim/emcn/feedback/use-clipboard'
66
import { ActionMenu, type MenuAction } from '@sim/emcn/menu/action-menu'
77
import { OverflowText } from '@sim/emcn/overflow-text'
8-
import { StatusText } from '@sim/emcn/status'
98
import { toast } from '@/lib/toast/sink'
10-
import styles from '@/app/(product)/_components/source-row/source-row.module.css'
9+
import styles from '@/app/(product)/_components/search/search.module.css'
1110
import { onExternalLinkClick } from '@/platform/lib/data/external-link'
1211
import type { LinkedSourceRow, SourceRowData } from '@/platform/lib/data/models/source-row'
1312

@@ -56,37 +55,11 @@ export function SourceRow({ row, onOpen, onSummarize, onLeave }: SourceRowProps)
5655
const { copy } = useClipboard()
5756
const LinkActions = useContext(ActionsHost) ?? BaseSourceActions
5857
const { url } = row
59-
const title = <OverflowText text={row.title}>{row.title}</OverflowText>
58+
// An unavailable document, or one with no page to open, keeps the title without its link.
59+
const href = row.unavailable ? undefined : url
6060
const summarize: MenuAction[] = onSummarize
6161
? [{ id: 'summarize', label: 'Summarize', onSelect: () => onSummarize(row) }]
6262
: []
63-
const heading = row.unavailable ? (
64-
<>
65-
<span className={styles.unavailable} data-type='T048'>
66-
{title}
67-
</span>
68-
<StatusText label='Unavailable' />
69-
</>
70-
) : url ? (
71-
<a
72-
className={styles.title}
73-
data-type='T048'
74-
data-source-link=''
75-
href={url}
76-
target='_blank'
77-
rel='noopener noreferrer'
78-
onClick={(event) => {
79-
onOpen?.({ ...row, url })
80-
onExternalLinkClick(event, url)
81-
}}
82-
>
83-
{title}
84-
</a>
85-
) : (
86-
<span className={styles.title} data-type='T048'>
87-
{title}
88-
</span>
89-
)
9063
const actions = row.unavailable ? null : url ? (
9164
<LinkActions
9265
row={{ ...row, url }}
@@ -109,7 +82,21 @@ export function SourceRow({ row, onOpen, onSummarize, onLeave }: SourceRowProps)
10982
return (
11083
<article className={styles.row}>
11184
<ActivityBody>
112-
{heading}
85+
<a
86+
className={styles.rowTitle}
87+
data-type='T048'
88+
data-source-link=''
89+
href={href}
90+
target='_blank'
91+
rel='noopener noreferrer'
92+
onClick={(event) => {
93+
if (!href) return
94+
onOpen?.({ ...row, url: href })
95+
onExternalLinkClick(event, href)
96+
}}
97+
>
98+
<OverflowText text={row.title}>{row.title}</OverflowText>
99+
</a>
113100
{row.meta && (
114101
<span className={styles.quiet} data-type='T052'>
115102
{row.meta}

‎apps/sim/app/(product)/_components/source-row/source-row.module.css‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎apps/sim/app/(product)/o/[organizationId]/search/_components/search-surface/search-surface.module.css‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
}
2929
.switch {
3030
display: flex;
31-
align-items: center;
32-
gap: var(--ui-action-gap);
3331
min-inline-size: 0;
3432
}
3533
.column {
@@ -44,18 +42,6 @@
4442
gap: var(--ui-action-gap);
4543
min-inline-size: 0;
4644
}
47-
/* On touch, the field's buttons keep their drawn size while their targets grow to the touch target. */
48-
@media (pointer: coarse) {
49-
.field > button {
50-
position: relative;
51-
}
52-
.field > button::after {
53-
content: "";
54-
position: absolute;
55-
inset-block: calc((var(--spacing-28) - var(--spacing-app-touch-target)) / 2);
56-
inset-inline: 0;
57-
}
58-
}
5945
.field > :first-child {
6046
flex: 1;
6147
min-inline-size: 0;

‎apps/sim/app/(product)/o/[organizationId]/search/_components/search-surface/search-surface.tsx‎

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ import { surfaceHref } from '@/platform/lib/data/organization-model'
1616
import { useSearchField, useSearchSurface } from '@/platform/lib/data/search'
1717
import { useSurfaceScope } from '@/platform/lib/surface-scope'
1818

19-
interface SearchFieldProps {
19+
interface SearchFormProps {
2020
query: string
2121
searching: boolean
2222
onSubmit: (value: string) => void
2323
onStop: () => void
24-
newSearch?: { label: string; disabled: boolean; onStart: () => void }
24+
newSearch?: { disabled: boolean; onStart: () => void }
2525
}
2626

27-
function SearchField({ query, searching, onSubmit, onStop, newSearch }: SearchFieldProps) {
27+
/** Keyed by the committed query, so each query opens on its own saved draft. */
28+
function SearchForm({ query, searching, onSubmit, onStop, newSearch }: SearchFormProps) {
2829
const field = useSearchField({ query, searching, onSubmit, onStop })
2930
function submit(event: FormEvent) {
3031
event.preventDefault()
@@ -60,7 +61,7 @@ function SearchField({ query, searching, onSubmit, onStop, newSearch }: SearchFi
6061
disabled={newSearch.disabled}
6162
onClick={newSearch.onStart}
6263
>
63-
{newSearch.label}
64+
New search
6465
</Button>
6566
)}
6667
</form>
@@ -76,9 +77,6 @@ export function SearchSurface({ chat }: SearchSurfaceProps) {
7677
const surface = useSearchSurface(chat?.id)
7778
const scope = useSurfaceScope()
7879
const { mode, query, assistantAvailable, history } = surface
79-
const newAction = surface.canStartNew
80-
? { label: surface.newLabel, disabled: surface.startingNew, onStart: surface.startNew }
81-
: undefined
8280
const modeSwitch = assistantAvailable && (
8381
<SegmentedControl
8482
label='Search mode'
@@ -91,7 +89,7 @@ export function SearchSurface({ chat }: SearchSurfaceProps) {
9189
/>
9290
)
9391
return (
94-
<main className={styles.surface}>
92+
<div className={styles.surface}>
9593
{/* The conversation stays mounted under Search so a running turn keeps streaming. */}
9694
{assistantAvailable && (mode === 'assistant' || surface.assistantStarted) && (
9795
<div className={styles.assistant} hidden={mode !== 'assistant'}>
@@ -103,22 +101,7 @@ export function SearchSurface({ chat }: SearchSurfaceProps) {
103101
searchView={mode}
104102
summaryRequest={surface.pendingSummary}
105103
onSummaryConsumed={surface.consumeSummary}
106-
header={
107-
<div className={styles.switch}>
108-
{modeSwitch}
109-
{mode === 'assistant' && newAction && (
110-
<Button
111-
variant='quiet'
112-
size='compact'
113-
icon='I074'
114-
disabled={newAction.disabled}
115-
onClick={newAction.onStart}
116-
>
117-
{newAction.label}
118-
</Button>
119-
)}
120-
</div>
121-
}
104+
header={<div className={styles.switch}>{modeSwitch}</div>}
122105
/>
123106
</div>
124107
)}
@@ -130,13 +113,17 @@ export function SearchSurface({ chat }: SearchSurfaceProps) {
130113
</header>
131114
<PageColumn>
132115
<div className={styles.column}>
133-
<SearchField
116+
<SearchForm
134117
key={query}
135118
query={query}
136119
searching={surface.searching}
137120
onSubmit={surface.submit}
138121
onStop={surface.stop}
139-
newSearch={newAction}
122+
newSearch={
123+
surface.canStartNew
124+
? { disabled: surface.startingNew, onStart: surface.startNew }
125+
: undefined
126+
}
140127
/>
141128
{query || surface.filtered ? (
142129
<SearchResults results={surface.results} />
@@ -170,6 +157,6 @@ export function SearchSurface({ chat }: SearchSurfaceProps) {
170157
</PageColumn>
171158
</div>
172159
)}
173-
</main>
160+
</div>
174161
)
175162
}

0 commit comments

Comments
 (0)