Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make chat-history and doc-selection scrollable #568

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 42 additions & 50 deletions django_app/frontend/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion django_app/frontend/style.css.map

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions django_app/frontend/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,33 @@ body {


/* Chat page */
.iai-panel {
background-color: govuk-colour("light-grey");
border-radius: 0.25rem;
display: block;
margin-bottom: 2rem;
padding: 1rem;
padding-top: 1.5rem;
}
.iai-panel__scrollable {
overflow-y: auto;
padding-right: 0.5rem;
max-height: 16.75rem;
}
.iai-panel__scrollable::-webkit-scrollbar {
background-color: govuk-colour("mid-grey");
width: 5px;
}
.iai-panel__scrollable::-webkit-scrollbar-thumb {
background-color: govuk-colour("dark-grey");
}
.iai-panel__scrollable .govuk-checkboxes__item {
margin-left: 0.625rem;
}
.iai-panel__scrollable .govuk-checkboxes__label {
word-break: break-word;
}

.iai-chat-message__container {
margin-top: -1rem;
}
Expand Down Expand Up @@ -144,6 +171,9 @@ body {
display: block;
overflow-x: auto;
}
.iai-chat-message__text li {
padding: 0.125rem 0;
}
.iai-chat-message__text table {
border-collapse: collapse;
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion django_app/redbox_app/redbox_core/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_session(session_id: str, user: User, user_message_text: str) -> ChatHist
if session_id:
session = ChatHistory.objects.get(id=session_id)
else:
session_name = user_message_text[0:20]
session_name = user_message_text[0 : settings.CHAT_TITLE_LENGTH]
session = ChatHistory(name=session_name, users=user)
session.save()
return session
Expand Down
2 changes: 1 addition & 1 deletion django_app/redbox_app/redbox_core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def post_message(request: HttpRequest) -> HttpResponse:
if session_id := request.POST.get("session-id", None):
session = ChatHistory.objects.get(id=session_id)
else:
session_name = message_text[0:20]
session_name = message_text[0 : settings.CHAT_TITLE_LENGTH]
session = ChatHistory(name=session_name, users=request.user)
session.save()

Expand Down
1 change: 1 addition & 0 deletions django_app/redbox_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
}

USE_STREAMING = env.bool("USE_STREAMING")
CHAT_TITLE_LENGTH = 30
FILE_EXPIRY_IN_SECONDS = env.int("FILE_EXPIRY_IN_DAYS") * 24 * 60 * 60
SUPERUSER_EMAIL = env.str("SUPERUSER_EMAIL", None)
MAX_SECURITY_CLASSIFICATION = Classification[env.str("MAX_SECURITY_CLASSIFICATION")]
26 changes: 14 additions & 12 deletions django_app/redbox_app/templates/chats.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,23 @@ <h1 class="govuk-heading-l">Chats</h1>
classes="govuk-button--secondary"
) }}

<h2 class="govuk-heading-s">Recent chats</h2>
<ul class="govuk-list govuk-list--spaced">
{% for chat in chat_history %}
<li>
<a class="govuk-link" href="{{url('chats', chat.id)}}">{{ chat.name }}</a>
</li>
{% endfor %}
</ul>

<document-selector>
<fieldset class="govuk-fieldset govuk-!-margin-top-7">
<div class="iai-panel">
<h2 class="govuk-heading-s">Recent chats</h2>
<ul class="govuk-list govuk-list--spaced iai-panel__scrollable">
{% for chat in chat_history %}
<li class="govuk-!-margin-bottom-2">
<a class="govuk-link govuk-body-s" href="{{url('chats', chat.id)}}">{{ chat.name }}</a>
</li>
{% endfor %}
</ul>
</div>

<document-selector class="iai-panel">
<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--s">
<h3 class="govuk-fieldset__heading">Documents to use</h3>
</legend>
<div class="govuk-checkboxes govuk-checkboxes--small" data-module="govuk-checkboxes">
<div class="govuk-checkboxes govuk-checkboxes--small iai-panel__scrollable" data-module="govuk-checkboxes">
{% for file in files %}
<div class="govuk-checkboxes__item">
<input class="govuk-checkboxes__input" id="file-{{ file.id }}" name="file-{{ file.id }}" type="checkbox" value="{{ file.id }}" {% if file.selected %}checked{% endif %}>
Expand Down
Loading