diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a088b089..99f6a655 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,5 +1,9 @@
module ApplicationHelper
+ def truncate_long_name(name)
+ truncate(name, length: 20)
+ end
+
def at_most_two_initials(initials)
return initials if initials.nil? || initials.length <= 2
initials[0] + initials[-1]
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 6f67f5e7..949d9707 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -36,7 +36,7 @@
<%= render partial: "layouts/user_avatar", locals: { user: Current.user, size: 7, classes: "ml-2 mr-2" } %>
- <%= Current.user.name.full || "Profile" %>
+ <%= truncate_long_name(Current.user.name.full) || "Profile" %>
<%= icon "chevron-up", variant: :mini, class: 'text-gray-500 ml-[2px]' %>
diff --git a/db/schema.rb b/db/schema.rb
index 44ceb9d6..bbd39ec2 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.1].define(version: 2024_11_11_131751) do
+ActiveRecord::Schema[7.2].define(version: 2024_11_11_131751) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -172,8 +172,8 @@
t.boolean "supports_tools", default: false
t.decimal "input_token_cost_cents", precision: 30, scale: 15
t.decimal "output_token_cost_cents", precision: 30, scale: 15
- t.boolean "supports_system_message", default: false
t.boolean "best", default: false
+ t.boolean "supports_system_message", default: false
t.index ["api_service_id"], name: "index_language_models_on_api_service_id"
t.index ["user_id", "deleted_at"], name: "index_language_models_on_user_id_and_deleted_at"
t.index ["user_id"], name: "index_language_models_on_user_id"
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index 8d702b20..680fed59 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -29,4 +29,17 @@ class ApplicationHelperTest < ActionView::TestCase
test "can have spaces" do
assert_equal "pQ", at_most_two_initials("p v Q")
end
+
+ test "truncates long names" do
+ assert_equal "John D. Z. Smith ...", truncate_long_name("John D. Z. Smith Jane Doe")
+ end
+
+ test "short names are not truncated" do
+ assert_equal "John D. Doe", truncate_long_name("John D. Doe")
+ end
+
+ test "handles nil" do
+ assert_nil truncate_long_name(nil)
+ end
+
end