fix: Misc UX fixes#2157
Open
charlesvien wants to merge 5 commits into
Open
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/code/src/renderer/features/auth/utils/userInitials.ts:13-22
When only `last_name` is set and `first_name` is absent, the function skips the last name entirely and falls through to email-based initials (or `"U"`). A user whose profile has `{first_name: null, last_name: "Smith"}` would get letters from their email address rather than `"S"` from their name.
```suggestion
export function getUserInitials(user: UserLike | null | undefined): string {
const first = firstLetter(user?.first_name);
const last = firstLetter(user?.last_name);
if (first && last) {
return `${first}${last}`.toUpperCase();
}
if (first) {
return first.toUpperCase();
}
if (last) {
return last.toUpperCase();
}
const emailLetters = user?.email?.match(/\p{L}/gu)?.slice(0, 2).join("");
```
Reviews (1): Last reviewed commit: "always render markdown files" | Re-trigger Greptile |
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/code/src/renderer/features/auth/utils/userInitials.test.ts:4-89
The team prefers parameterised tests (`it.each`). The 14 individual `it()` calls here all drive the same function with different inputs and expected outputs — a textbook case for a table-driven test. The only case that warrants its own `it` is the astral-plane one, whose inline comment adds meaningful context. Collapsing the rest into `it.each` reduces repetition and makes it easier to add new edge cases.
```suggestion
describe("getUserInitials", () => {
it.each([
// first + last name
[{ first_name: "Charles", last_name: "Vien" }, "CV"],
[{ first_name: "alice", last_name: "smith" }, "AS"],
// single name field
[{ first_name: "Charles" }, "C"],
[{ last_name: "Vien" }, "V"],
// email fallback
[{ email: "charles.v@posthog.com" }, "CH"],
[{ email: "1234@example.com" }, "U"],
[{ email: "1.2_charles@posthog.com" }, "CH"],
// non-letter prefix in names
[{ first_name: " 123Alice" }, "A"],
// accented characters
[{ first_name: "Émile", last_name: "Über" }, "ÉÜ"],
// null / undefined / empty fallback to "U"
[null, "U"],
[undefined, "U"],
[{ first_name: "", last_name: "", email: "" }, "U"],
[{ first_name: "123" }, "U"],
[{ first_name: "123", email: "456@example.com" }, "U"],
[{ first_name: null, last_name: null, email: "charles.v@posthog.com" }, "CH"],
])("getUserInitials(%o) === %s", (input, expected) => {
expect(getUserInitials(input as Parameters<typeof getUserInitials>[0])).toBe(expected);
});
it("handles astral-plane characters without producing lone surrogates", () => {
// U+20BB7 ("𠮷") is encoded as a UTF-16 surrogate pair. The old
// implementation used string[0], which returned only the high surrogate
// and rendered as a garbled tofu char.
expect(getUserInitials({ first_name: "𠮷田", last_name: "Smith" })).toBe(
"𠮷S",
);
});
});
```
Reviews (2): Last reviewed commit: "address review feedback on initials and ..." | Re-trigger Greptile |
Generated-By: PostHog Code Task-Id: 5f514df8-a02d-42c8-bb24-e972875c458d
Generated-By: PostHog Code Task-Id: 8b514353-44fc-4561-8075-bca46f95d645
35ab2d8 to
1b824ae
Compare
This was referenced May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
Several small UX papercuts across settings, the file viewer, tool output and toasts.
Closes #2168
Changes
getUserInitialsutilmarkdownViewerStore)ExecuteToolViewWarningCircleicon for error toasts instead of an XHow did you test this?
Manually