Skip to content

Commit 01fe8c3

Browse files
committed
v2.301 - Fix Slide Selector 2
1 parent 7d58f28 commit 01fe8c3

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

frontend/src/components/app/AppContentRouter.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,16 @@ export function AppContentRouter() {
233233
}
234234
}
235235
const newParams = new URLSearchParams(searchParams.toString())
236-
newParams.delete("q")
237236
newParams.delete("view")
237+
if (!q) newParams.delete("q")
238238
const qs = newParams.toString()
239239
router.replace(qs ? `/app?${qs}` : "/app", { scroll: false })
240240
}, [searchParams, router, setActiveView])
241241

242-
const clearInitialPrompt = useCallback(() => setInitialPrompt(null), [])
242+
const clearInitialPrompt = useCallback(() => {
243+
setInitialPrompt(null)
244+
router.replace("/app", { scroll: false })
245+
}, [router])
243246
const [resetKey, setResetKey] = useState(0)
244247
const [demoSessions, setDemoSessions] = useState<Record<string, Session>>({})
245248

@@ -266,10 +269,10 @@ export function AppContentRouter() {
266269
}, [searchParams, router, upsertConversation, setActiveView])
267270

268271
useEffect(() => {
269-
if (activeView === "new") {
272+
if (activeView === "new" && !initialPrompt) {
270273
queueMicrotask(() => setResetKey((k) => k + 1))
271274
}
272-
}, [activeView])
275+
}, [activeView, initialPrompt])
273276

274277
const handleSessionComplete = useCallback((session: Session) => {
275278
setDemoSessions((prev) => ({ ...prev, [session.id]: session }))

frontend/src/components/blocks/TextbookRenderer.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ export const SessionFloatingTOC = React.memo(function SessionFloatingTOC(props:
290290
}
291291
}
292292

293-
/* Active = last entry whose heading is at or above the viewport reference point.
294-
Each entry "owns" the range from its heading down to the next entry's heading.
295-
Reference = viewport top + small offset so once a heading scrolls past the
296-
top area the indicator switches to it. */
297-
const refPoint = container.scrollTop + 100
293+
/* ChatGPT-style: active = last heading that scrolled past the top area.
294+
Each entry owns the range from its heading to the next heading.
295+
Offset 30 ≈ scroll-to margin (24px) + 6px buffer — keeps click-to-scroll
296+
and manual scroll tracking perfectly in sync, even for short sections. */
297+
const refPoint = container.scrollTop + 30
298298
let activeIdx = 0
299299
for (let i = positions.length - 1; i >= 0; i--) {
300300
if (refPoint >= positions[i]) {

0 commit comments

Comments
 (0)