Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
math_tutor_dev
public_math_tutor
Commits
e6256e64
Commit
e6256e64
authored
Jan 20, 2026
by
Kantz
Browse files
subsection und section hinzugefügt
parent
be526994
Changes
3
Hide whitespace changes
Inline
Side-by-side
math-tutor/frontend/src/components/Retrieval/DocPanel.tsx
View file @
e6256e64
...
@@ -19,7 +19,10 @@ export type RetrievedDoc = {
...
@@ -19,7 +19,10 @@ export type RetrievedDoc = {
};
};
type
DocPanelProps
=
{
type
DocPanelProps
=
{
docs
:
RetrievedDoc
[];
directChildren
:
RetrievedDoc
[];
indirectChildren
:
RetrievedDoc
[];
subsections
:
RetrievedDoc
[];
sections
:
RetrievedDoc
[];
isLoading
?:
boolean
;
isLoading
?:
boolean
;
error
?:
string
|
null
;
error
?:
string
|
null
;
onCiteDoc
?:
(
uid
:
string
)
=>
void
;
onCiteDoc
?:
(
uid
:
string
)
=>
void
;
...
@@ -63,32 +66,62 @@ const buildSnippet = (markdown: string) => {
...
@@ -63,32 +66,62 @@ const buildSnippet = (markdown: string) => {
return
`
${
trimmed
.
slice
(
0
,
240
)}
...`
;
return
`
${
trimmed
.
slice
(
0
,
240
)}
...`
;
};
};
const
renderGroup
=
(
title
:
string
,
docs
:
RetrievedDoc
[],
onCiteDoc
?:
(
uid
:
string
)
=>
void
,
onInspectDoc
?:
(
doc
:
RetrievedDoc
)
=>
void
)
=>
{
if
(
docs
.
length
===
0
)
{
return
null
;
}
return
(
<
div
className
=
"retrieval-group"
>
<
div
className
=
"retrieval-group-title"
>
{
title
}
</
div
>
{
docs
.
map
((
doc
)
=>
(
<
DocCard
key
=
{
doc
.
uid
}
title
=
{
buildTitle
(
doc
)
}
subtitle
=
{
buildSubtitle
(
doc
)
}
snippetMarkdown
=
{
buildSnippet
(
doc
.
markdown
)
}
score
=
{
doc
.
score
}
onCite
=
{
onCiteDoc
?
()
=>
onCiteDoc
(
doc
.
uid
)
:
undefined
}
onInspect
=
{
onInspectDoc
?
()
=>
onInspectDoc
(
doc
)
:
undefined
}
/>
))
}
</
div
>
);
};
export
default
function
DocPanel
({
export
default
function
DocPanel
({
docs
,
directChildren
,
indirectChildren
,
subsections
,
sections
,
isLoading
,
isLoading
,
error
,
error
,
onCiteDoc
,
onCiteDoc
,
onInspectDoc
,
onInspectDoc
,
}:
DocPanelProps
)
{
}:
DocPanelProps
)
{
const
total
=
directChildren
.
length
+
indirectChildren
.
length
+
subsections
.
length
+
sections
.
length
;
return
(
return
(
<
div
className
=
"retrieval-panel"
>
<
div
className
=
"retrieval-panel"
>
<
div
className
=
"retrieval-title"
>
Retrieved Notes
</
div
>
<
div
className
=
"retrieval-title"
>
Retrieved Notes
</
div
>
{
isLoading
?
<
div
className
=
"retrieval-state"
>
Loading...
</
div
>
:
null
}
{
isLoading
?
<
div
className
=
"retrieval-state"
>
Loading...
</
div
>
:
null
}
{
error
?
<
div
className
=
"retrieval-state error"
>
{
error
}
</
div
>
:
null
}
{
error
?
<
div
className
=
"retrieval-state error"
>
{
error
}
</
div
>
:
null
}
{
!
isLoading
&&
!
error
&&
docs
.
length
===
0
?
(
{
!
isLoading
&&
!
error
&&
total
===
0
?
(
<
div
className
=
"retrieval-state"
>
No results yet.
</
div
>
<
div
className
=
"retrieval-state"
>
No results yet.
</
div
>
)
:
null
}
)
:
null
}
{
docs
.
map
((
doc
)
=>
(
{
renderGroup
(
"
Direct children
"
,
directChildren
,
onCiteDoc
,
onInspectDoc
)
}
<
DocCard
{
renderGroup
(
"
Indirect children
"
,
indirectChildren
,
onCiteDoc
,
onInspectDoc
)
}
key
=
{
doc
.
uid
}
{
renderGroup
(
"
Subsection summary
"
,
subsections
,
onCiteDoc
,
onInspectDoc
)
}
title
=
{
buildTitle
(
doc
)
}
{
renderGroup
(
"
Section summary
"
,
sections
,
onCiteDoc
,
onInspectDoc
)
}
subtitle
=
{
buildSubtitle
(
doc
)
}
snippetMarkdown
=
{
buildSnippet
(
doc
.
markdown
)
}
score
=
{
doc
.
score
}
onCite
=
{
onCiteDoc
?
()
=>
onCiteDoc
(
doc
.
uid
)
:
undefined
}
onInspect
=
{
onInspectDoc
?
()
=>
onInspectDoc
(
doc
)
:
undefined
}
/>
))
}
</
div
>
</
div
>
);
);
}
}
math-tutor/frontend/src/pages/App.tsx
View file @
e6256e64
...
@@ -19,7 +19,10 @@ export default function App() {
...
@@ -19,7 +19,10 @@ export default function App() {
const
[
messages
,
setMessages
]
=
useState
<
ChatMessage
[]
>
(
initialMessages
);
const
[
messages
,
setMessages
]
=
useState
<
ChatMessage
[]
>
(
initialMessages
);
const
[
draft
,
setDraft
]
=
useState
(
""
);
const
[
draft
,
setDraft
]
=
useState
(
""
);
const
[
isCanvasVisible
,
setIsCanvasVisible
]
=
useState
(
false
);
const
[
isCanvasVisible
,
setIsCanvasVisible
]
=
useState
(
false
);
const
[
retrievedDocs
,
setRetrievedDocs
]
=
useState
<
RetrievedDoc
[]
>
([]);
const
[
directChildren
,
setDirectChildren
]
=
useState
<
RetrievedDoc
[]
>
([]);
const
[
indirectChildren
,
setIndirectChildren
]
=
useState
<
RetrievedDoc
[]
>
([]);
const
[
subsections
,
setSubsections
]
=
useState
<
RetrievedDoc
[]
>
([]);
const
[
sections
,
setSections
]
=
useState
<
RetrievedDoc
[]
>
([]);
const
[
retrievalLoading
,
setRetrievalLoading
]
=
useState
(
false
);
const
[
retrievalLoading
,
setRetrievalLoading
]
=
useState
(
false
);
const
[
retrievalError
,
setRetrievalError
]
=
useState
<
string
|
null
>
(
null
);
const
[
retrievalError
,
setRetrievalError
]
=
useState
<
string
|
null
>
(
null
);
...
@@ -55,8 +58,10 @@ export default function App() {
...
@@ -55,8 +58,10 @@ export default function App() {
throw
new
Error
(
`Retrieval failed:
${
res
.
status
}
`
);
throw
new
Error
(
`Retrieval failed:
${
res
.
status
}
`
);
}
}
const
payload
=
await
res
.
json
();
const
payload
=
await
res
.
json
();
const
docs
:
RetrievedDoc
[]
=
payload
.
children
||
[];
setDirectChildren
(
payload
.
children_direct
||
[]);
setRetrievedDocs
(
docs
);
setIndirectChildren
(
payload
.
children_expanded
||
[]);
setSubsections
(
payload
.
subsections
||
[]);
setSections
(
payload
.
sections
||
[]);
});
});
const
response
=
await
fetch
(
"
http://localhost:8000/api/chat
"
,
{
const
response
=
await
fetch
(
"
http://localhost:8000/api/chat
"
,
{
...
@@ -250,7 +255,10 @@ export default function App() {
...
@@ -250,7 +255,10 @@ export default function App() {
<
aside
className
=
"retrieval-column"
>
<
aside
className
=
"retrieval-column"
>
<
DocPanel
<
DocPanel
docs
=
{
retrievedDocs
}
directChildren
=
{
directChildren
}
indirectChildren
=
{
indirectChildren
}
subsections
=
{
subsections
}
sections
=
{
sections
}
isLoading
=
{
retrievalLoading
}
isLoading
=
{
retrievalLoading
}
error
=
{
retrievalError
}
error
=
{
retrievalError
}
onCiteDoc
=
{
handleCiteDoc
}
onCiteDoc
=
{
handleCiteDoc
}
...
...
math-tutor/frontend/src/styles/theme.css
View file @
e6256e64
...
@@ -298,6 +298,21 @@ body {
...
@@ -298,6 +298,21 @@ body {
font-size
:
12px
;
font-size
:
12px
;
}
}
.retrieval-group
{
display
:
flex
;
flex-direction
:
column
;
gap
:
10px
;
}
.retrieval-group-title
{
font-size
:
12px
;
font-weight
:
600
;
text-transform
:
uppercase
;
letter-spacing
:
0.08em
;
color
:
#6f675d
;
margin-top
:
6px
;
}
.retrieval-state.error
{
.retrieval-state.error
{
background
:
#f3d9d6
;
background
:
#f3d9d6
;
color
:
#8a3b2f
;
color
:
#8a3b2f
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment