Skip to content

Commit 9e7d9a7

Browse files
committed
lint
1 parent f95704c commit 9e7d9a7

File tree

15 files changed

+90
-59
lines changed

15 files changed

+90
-59
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"dev": "NODE_ENV=development concurrently \"nodemon --exec node --no-warnings --experimental-specifier-resolution=node --loader ts-node/esm src/server/index.ts\" \"vite\"",
1111
"tsc": "tsc",
1212
"lint": "eslint 'src/**/*.{ts,tsx}'",
13-
"format": "prettier --write '*.{ts,json,css,md}'",
13+
"lint:fix": "eslint 'src/**/*.{ts,tsx}' --fix",
14+
"format": "prettier --write '**/*.{ts,json,css,md}'",
1415
"build": "vite build",
1516
"prepare": "husky install"
1617
},

src/client/components/Chat/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,8 @@ const Chat = () => {
452452
maxWidth: '500px',
453453
}}
454454
>
455-
<Typography>
456-
{`File of type "${disallowedFileType}" not supported currently`}
457-
</Typography>
458-
<Typography>
459-
{`Currenlty there is support for formats ".pdf" and plain text such as ".txt", ".csv", and ".md"`}
460-
</Typography>
455+
<Typography>{`File of type "${disallowedFileType}" not supported currently`}</Typography>
456+
<Typography>{`Currenlty there is support for formats ".pdf" and plain text such as ".txt", ".csv", and ".md"`}</Typography>
461457
</Alert>
462458
)}
463459
<TokenUsageWarning

src/client/components/ChatV2/ChatV2.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,21 @@ export const ChatV2 = () => {
136136
}
137137
}
138138

139+
const handleReset = () => {
140+
setMessages([])
141+
setMessage({ content: '' })
142+
setCompletion('')
143+
setStreamController(undefined)
144+
setTokenUsageWarning('')
145+
setTokenWarningVisible(false)
146+
setRetryTimeout(() => {
147+
if (streamController) {
148+
streamController.abort()
149+
}
150+
}, 5000)
151+
clearRetryTimeout()
152+
}
153+
139154
return (
140155
<Box
141156
sx={{
@@ -155,24 +170,7 @@ export const ChatV2 = () => {
155170
content={system.content}
156171
setContent={(content) => setSystem({ content })}
157172
/>
158-
<Button
159-
onClick={() => {
160-
setMessages([])
161-
setMessage({ content: '' })
162-
setCompletion('')
163-
setStreamController(undefined)
164-
setTokenUsageWarning('')
165-
setTokenWarningVisible(false)
166-
setRetryTimeout(() => {
167-
if (streamController) {
168-
streamController.abort()
169-
}
170-
}, 5000)
171-
clearRetryTimeout()
172-
}}
173-
>
174-
Reset
175-
</Button>
173+
<Button onClick={handleReset}>Reset</Button>
176174
</Box>
177175
<Conversation messages={messages} completion={completion} />
178176
<ChatBox

src/client/components/ChatV2/Conversation.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Box, Paper } from '@mui/material'
22
import { Message } from '../../types'
33
import ReactMarkdown from 'react-markdown'
44
import remarkGfm from 'remark-gfm'
5+
import { Assistant } from '@mui/icons-material'
56

67
const MessageItem = ({ message }: { message: Message }) => (
78
<Paper
@@ -20,19 +21,41 @@ const MessageItem = ({ message }: { message: Message }) => (
2021
</Paper>
2122
)
2223

24+
const PöhinäLogo = () => (
25+
<Box
26+
sx={{
27+
display: 'flex',
28+
justifyContent: 'center',
29+
alignItems: 'center',
30+
height: '40rem',
31+
transition: 'opacity 0.6s, transform 0.6s',
32+
opacity: 1,
33+
transform: 'scale(1)',
34+
animation: 'fadeInScale 0.6s ease',
35+
'@keyframes fadeInScale': {
36+
from: { opacity: 0, transform: 'scale(0.8)' },
37+
to: { opacity: 1, transform: 'scale(1)' },
38+
},
39+
}}
40+
>
41+
<Assistant sx={{ fontSize: 160, color: 'toskaPrimary.main' }} />
42+
</Box>
43+
)
44+
2345
export const Conversation = ({
2446
messages,
2547
completion,
2648
}: {
2749
messages: Message[]
2850
completion: string
2951
}) => (
30-
<Box>
52+
<Box sx={{ flex: 1, overflowY: 'auto' }}>
3153
{messages.map((message, idx) => (
3254
<MessageItem key={idx} message={message} />
3355
))}
3456
{completion && (
3557
<MessageItem message={{ role: 'assistant', content: completion }} />
3658
)}
59+
{messages.length === 0 && <PöhinäLogo />}
3760
</Box>
3861
)

src/client/components/Courses/Course/Discussion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const Message = ({ message }: { message: MessageType }) => {
6464
const Discussion = () => {
6565
const { i18n } = useTranslation()
6666
const { language } = i18n
67-
// eslint-disable-next-line @typescript-eslint/naming-convention
67+
6868
const { id, user_id } = useParams()
6969
const { user, isLoading: isUserLoading } = useCurrentUser()
7070
const { course, isLoading: courseLoading } = useCourse(id)

src/client/hooks/useRetryTimeout.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const useRetryTimeout = (): [
44
(cb: () => Promise<void> | void, time: number) => void,
55
() => void,
66
] => {
7-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
87
const [_, setDummyState] = useState(false) // Dummy state to force re-render
98
const timeoutRef = useRef<NodeJS.Timeout | null>(null)
109

src/client/styles.css

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,37 @@
55
.loader {
66
width: 45px;
77
aspect-ratio: 2;
8-
--_g: no-repeat radial-gradient(circle closest-side,#000 90%,#0000);
9-
background:
10-
var(--_g) 0% 50%,
11-
var(--_g) 50% 50%,
8+
--_g: no-repeat radial-gradient(circle closest-side, #000 90%, #0000);
9+
background:
10+
var(--_g) 0% 50%,
11+
var(--_g) 50% 50%,
1212
var(--_g) 100% 50%;
13-
background-size: calc(100%/3) 50%;
13+
background-size: calc(100% / 3) 50%;
1414
animation: l3 1s infinite linear;
1515
}
1616
@keyframes l3 {
17-
20%{background-position:0% 0%, 50% 50%,100% 50%}
18-
40%{background-position:0% 100%, 50% 0%,100% 50%}
19-
60%{background-position:0% 50%, 50% 100%,100% 0%}
20-
80%{background-position:0% 50%, 50% 50%,100% 100%}
21-
}
17+
20% {
18+
background-position:
19+
0% 0%,
20+
50% 50%,
21+
100% 50%;
22+
}
23+
40% {
24+
background-position:
25+
0% 100%,
26+
50% 0%,
27+
100% 50%;
28+
}
29+
60% {
30+
background-position:
31+
0% 50%,
32+
50% 100%,
33+
100% 0%;
34+
}
35+
80% {
36+
background-position:
37+
0% 50%,
38+
50% 50%,
39+
100% 100%;
40+
}
41+
}

src/server/routes/course.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Responsibility,
1212
Discussion,
1313
} from '../db/models'
14-
import { getOwnCourses } from '../chatInstances/access'
14+
import { getOwnCourses } from '../services/chatInstances/access'
1515
import { encrypt, decrypt } from '../util/util'
1616

1717
const courseRouter = express.Router()
@@ -237,7 +237,6 @@ courseRouter.get('/:id/discussers', checkDiscussionAccess, async (req, res) => {
237237

238238
res.send(
239239
discussionCounts.map((disc) => {
240-
// eslint-disable-next-line @typescript-eslint/naming-convention
241240
const { user_id, discussion_count } = disc.dataValues
242241
return {
243242
user_id: encrypt(user_id).encryptedData,

src/server/routes/openai.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
checkUsage,
1010
checkCourseUsage,
1111
incrementCourseUsage,
12-
} from '../chatInstances/usage'
12+
} from '../services/chatInstances/usage'
1313
import { getCompletionEvents, streamCompletion } from '../util/azure'
1414
import {
1515
getMessageContext,

src/server/routes/user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import {
66
getEnrolledCourseIds,
77
getOwnCourses,
88
getEnrolledCourses,
9-
} from '../chatInstances/access'
9+
} from '../services/chatInstances/access'
1010
import { User } from '../db/models'
11-
import { getUserStatus, getUsage } from '../chatInstances/usage'
11+
import { getUserStatus, getUsage } from '../services/chatInstances/usage'
1212
import { DEFAULT_TOKEN_LIMIT } from '../../config'
1313
import { getLastRestart } from '../util/lastRestart'
1414
import { accessIams } from '../util/config'

0 commit comments

Comments
 (0)