Skip to content

refactor: add util for id shortening#3403

Merged
chronark merged 5 commits intomainfrom
util-for-key-shortening
Jul 3, 2025
Merged

refactor: add util for id shortening#3403
chronark merged 5 commits intomainfrom
util-for-key-shortening

Conversation

@ogzhanolguncu
Copy link
Contributor

@ogzhanolguncu ogzhanolguncu commented Jun 25, 2025

What does this PR do?

This PR adds a util for shortening long keys e.g. keyId, apiId etc...
Fixes # (issue)

If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Test A
  • Test B

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

Summary by CodeRabbit

  • New Features

    • Introduced a utility to consistently shorten long IDs across the dashboard for improved readability.
  • Refactor

    • Updated various components to use the new ID shortening utility, replacing previous manual string truncation methods.
    • Improved visual alignment and styling for tag displays in logs tables.

@changeset-bot
Copy link

changeset-bot bot commented Jun 25, 2025

⚠️ No Changeset found

Latest commit: 55ef758

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Jun 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2025 9:09am
engineering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2025 9:09am

@github-actions
Copy link
Contributor

github-actions bot commented Jun 25, 2025

Thank you for following the naming conventions for pull request titles! 🙏

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 25, 2025

📝 Walkthrough
## Walkthrough

A new utility function, `shortenId`, is introduced to standardize the truncation and display of string IDs across the dashboard application. Multiple components are refactored to replace manual substring and truncation logic with calls to this utility, ensuring consistent ID shortening behavior throughout the UI.

## Changes

| File(s)                                                                                                  | Change Summary                                                                                  |
|----------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
| apps/dashboard/lib/shorten-id.ts                                                                         | Added new `shortenId` utility function for configurable string ID truncation.                   |
| .../apis/[apiId]/_overview/components/table/components/override-indicator.tsx                            | Replaced manual key ID truncation with `shortenId` utility.                                     |
| .../apis/[apiId]/api-id-navbar.tsx                                                                       | Refactored breadcrumb ID shortening to use `shortenId`.                                         |
| .../apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/logs-table.tsx                                | Updated tag badge display to use `shortenId`; adjusted badge tooltip classes and alignment.     |
| .../apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx                             | Replaced manual key ID truncation with `shortenId` utility.                                     |
| .../audit/components/controls/components/logs-filters/components/root-keys-filter.tsx                    | Refactored root key label truncation to use `shortenId`.                                        |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant UI_Component
    participant shortenId_Util

    UI_Component->>shortenId_Util: shortenId(id, options?)
    shortenId_Util-->>UI_Component: Shortened ID string
    UI_Component->>UI_Component: Render shortened ID in UI

Possibly related PRs

Suggested labels

Bug

Suggested reviewers

  • perkinsjr
  • mcstepp
  • chronark

</details>

<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: ASSERTIVE**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between f43775c36529e24861165b34aba9aa32e495b178 and 55ef75892a897cd9e3f27b2b5e18d53d1c84ab4f.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `apps/dashboard/app/(app)/apis/[apiId]/api-id-navbar.tsx` (2 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧠 Learnings (2)</summary>

<details>
<summary>📓 Common learnings</summary>

Learnt from: ogzhanolguncu
PR: #2825
File: apps/dashboard/app/(app)/logs-v2/hooks/use-bookmarked-filters.ts:0-0
Timestamp: 2025-01-30T20:51:44.359Z
Learning: The user (ogzhanolguncu) prefers to handle refactoring suggestions in separate PRs to maintain focus in the current PR.


Learnt from: Flo4604
PR: #3421
File: go/apps/api/openapi/openapi.yaml:196-200
Timestamp: 2025-07-03T05:58:10.669Z
Learning: In the Unkey codebase, OpenAPI 3.1 is used, which allows sibling keys (such as description) alongside $ref in schema objects. Do not flag this as an error in future reviews.


Learnt from: chronark
PR: #2693
File: apps/api/src/routes/v1_keys_updateKey.ts:350-368
Timestamp: 2024-11-29T15:15:47.308Z
Learning: In apps/api/src/routes/v1_keys_updateKey.ts, the code intentionally handles externalId and ownerId separately for clarity. The ownerId field will be removed in the future, simplifying the code.


Learnt from: ogzhanolguncu
PR: #2825
File: apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/utils/process-time.ts:8-18
Timestamp: 2025-01-30T20:41:25.648Z
Learning: Extensive input validation is not required for internal UI utility functions in the dashboard, as they are used with controlled UI components that already handle validation.


Learnt from: ogzhanolguncu
PR: #3297
File: apps/dashboard/lib/trpc/routers/authorization/roles/query.ts:210-323
Timestamp: 2025-06-04T20:13:12.060Z
Learning: The user ogzhanolguncu prefers explicit, duplicated code over abstracted helper functions when it improves readability, even if it means some duplication in filter building functions in the authorization roles query module.


Learnt from: ogzhanolguncu
PR: #3375
File: apps/dashboard/app/(app)/settings/root-keys/components/table/hooks/use-root-keys-list-query.ts:0-0
Timestamp: 2025-06-25T20:32:10.471Z
Learning: In the Unkey codebase, ogzhanolguncu prefers strict validation with fail-fast error handling. When validation errors occur that shouldn't happen in normal operation (like invalid operators), throwing errors to crash the page is preferred over graceful error handling or console logging.


</details>
<details>
<summary>apps/dashboard/app/(app)/apis/[apiId]/api-id-navbar.tsx (9)</summary>

Learnt from: chronark
PR: #2693
File: apps/api/src/routes/v1_keys_updateKey.ts:350-368
Timestamp: 2024-11-29T15:15:47.308Z
Learning: In apps/api/src/routes/v1_keys_updateKey.ts, the code intentionally handles externalId and ownerId separately for clarity. The ownerId field will be removed in the future, simplifying the code.


Learnt from: ogzhanolguncu
PR: #3324
File: apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/keys-table-action.popover.constants.tsx:17-18
Timestamp: 2025-06-19T11:48:05.070Z
Learning: In the authorization roles refactor, the RoleBasic type uses roleId as the property name for the role identifier, not id. This is consistent throughout the codebase in apps/dashboard/lib/trpc/routers/authorization/roles/query.ts.


Learnt from: p6l-richard
PR: #2085
File: apps/www/components/glossary/terms-stepper-mobile.tsx:16-20
Timestamp: 2024-10-23T16:25:33.113Z
Learning: In the apps/www/components/glossary/terms-stepper-mobile.tsx file, avoid suggesting to extract the term navigation logic into a custom hook, as the user prefers to keep the component straightforward.


Learnt from: ogzhanolguncu
PR: #2876
File: apps/dashboard/components/logs/datetime/constants.ts:96-96
Timestamp: 2025-02-06T17:41:47.228Z
Learning: In the Unkey codebase, avoid hardcoding IDs or indices that depend on array positions, as the arrays may be modified in the future. Instead, use methods like find with unique identifiers or properties to locate specific items.


Learnt from: chronark
PR: #2294
File: apps/api/src/pkg/keys/service.ts:268-271
Timestamp: 2024-10-20T07:05:55.471Z
Learning: In apps/api/src/pkg/keys/service.ts, ratelimitAsync is a table relation, not a column selection. When querying, ensure that table relations are included appropriately, not as columns.


Learnt from: ogzhanolguncu
PR: #2872
File: apps/dashboard/lib/trpc/routers/ratelimit/createNamespace.ts:36-39
Timestamp: 2025-04-08T09:34:24.576Z
Learning: In the Unkey dashboard, when making database queries involving workspaces, use ctx.workspace.id directly instead of fetching the workspace separately for better performance and security.


Learnt from: ogzhanolguncu
PR: #3242
File: apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/override-indicator.tsx:50-65
Timestamp: 2025-05-15T16:26:08.666Z
Learning: In the Unkey dashboard, Next.js router (router.push) should be used for client-side navigation instead of window.location.href to preserve client state and enable smoother transitions between pages.


Learnt from: ogzhanolguncu
PR: #3311
File: apps/dashboard/components/logs/llm-search/components/search-input.tsx:14-14
Timestamp: 2025-06-10T14:21:42.413Z
Learning: In Next.js applications, importing backend modules into frontend components causes bundling issues and can expose server-side code to the client bundle. For simple constants like limits, it's acceptable to duplicate the value rather than compromise the frontend/backend architectural separation.


Learnt from: ogzhanolguncu
PR: #3115
File: apps/dashboard/components/logs/checkbox/filters-popover.tsx:33-55
Timestamp: 2025-04-24T14:34:30.621Z
Learning: In the ShortcutActivator component within filters-popover.tsx, the purpose is to track keys separately for each filter item, providing a registration mechanism for shortcuts passed to it rather than enforcing specific key combinations like option+shift+key.


</details>

</details><details>
<summary>🧬 Code Graph Analysis (1)</summary>

<details>
<summary>apps/dashboard/app/(app)/apis/[apiId]/api-id-navbar.tsx (1)</summary><blockquote>

<details>
<summary>apps/dashboard/lib/shorten-id.ts (1)</summary>

* `shortenId` (5-48)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (1)</summary>

* GitHub Check: Test Packages / Test ./internal/clickhouse

</details>

<details>
<summary>🔇 Additional comments (2)</summary><blockquote>

<details>
<summary>apps/dashboard/app/(app)/apis/[apiId]/api-id-navbar.tsx (2)</summary>

`8-8`: **LGTM: Import statement is correctly added.**

The import for `shortenId` utility function is properly placed and follows the established import pattern in the codebase.

---

`194-194`: **LGTM: Correct usage of the shortenId utility function.**

The refactoring from manual string concatenation to using the `shortenId` utility function is well-implemented. The code correctly uses `specificKey.id` and will apply the default shortening options (8 start characters, 4 end characters, "..." separator), which is consistent with the refactoring pattern across other components in this PR.

</details>

</blockquote></details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcABpIcVwvOkgAIn8AMzQxfAouNFp6PHhfBNSUekRYVJoMeAwiUNjIAHc0ZAcBZnUaejkI2BJIbERKfiIAL1hMfC8ibAwGbHRkW0gMRwE+gGYAFgAGZf4sXE7IAFUMAGsSeX9ufER1VNkNGD3mbSxPCgve/gSO1DnUAhQMXAURTYBhdNDdcRedTyBITMTwfBYJRXIjkeh/IolMiQLyIoiQE6yBog2AzSAAA0JAElaOT0Bh6OS0Nx4DTyXd3MgyMNJiQ2AD0PBmMg/kLePgpJAebQoRUPjiyERdvJ4EoAfAEvBKMgauoEDs9kwlAJ6iQNG49j9kAxqCQiKl4AMYvV6ZBuZhQfywv9aPAbeI5eoeECJKrpOh7I8fChmOKpF6/NROnxdpgIwJsPjNQAPfh8cg1SAJEjUbD+Dl7ZEMCjwbjiRHzfA0EXDXAdShdVAYfAzRD4BjwW30JAOLoLZhLCjhTD0JgAmsZggUZDOLpkJhltCkdE96slmjbLp5FNUBhHcr4l5vcMaxvkN3ZpC4RDmgzQEIX/6IQEg+sYFf+JAAg1iQCRePIXoImiQF4I2bZKLg2jRLQ4S6rsPBeMkJDFF4SjLnE77fpAACC1QzgRISQAAQtU5S+v6n41MmXTNm234kNwDTFN4bRdFWC50BWXRzoC8CLvkc6ahQwroLQzG8hEPa7F04oiGIADk1qIqJi5QZA4xhrK0jhOUDBeNgvpyr0XgJGA/ihiQNThEawksJBFThMejy4AGlQwTkll+eRZAODWcrdrUzhlBUyASYifbRDi+BEMg/iPOUQlAVQkyknUK5eH23TcLQQ61Hq7Y4raREMDypDIAkQLMBV6VYMBHqkn8aASPgqqQGwFCkAoGBgX6z6vgAcj2+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DO8YdJaWaRCd8XSH4qCHQLFHwNmbdJho8kWbAAgQ6CIr0r4HKVwYqRQGiHcAAPJRkxnwGEqI5YAKlKkrhDR4pyL6F9F94CB/ZDFzFYlTggkGJP4Xi2G1oWpFYVZOF9Z2oVZuFVaR5db1ax6+FQAABiM5skSgtAXA4J15muL5IuqoXAG5mxaSAA/FwAAN4vqQxCkgVtETiUAADcApUFXAFx8F9gW51AqQ0Ff2CFTJLJsA0FKFFACFAAvjbP+TOnSGjEyCEdNpnlgmJJETrjEc+OSEnjjAYDzAKfKELKTHdqVBLF6NLGgLLP3grDinhCrBzOrNzHjFTM0LgMPLQIgF7Aio5HQF7KuexZxSQKsNvLQAAOzLAkArq0AACcJAyw6wplSwAgaGAAbNvOsFZdZdpiugwNpqZesAwCVNvMsMsEunZRrIYJxQkKsMsPpfpW5csHZSuh5SQNprpXZUugFSugIGsCoGgKZWgGgMsNpjpaZalUuvpbvDJRAJACuiuqBJFdvKZdpmgDVfpd5eZcsAkNpvpQINpgIJVUunpSussLQEugwNvKsCoKsJ8FpbJQJeoIpcpapWfLQF7KCfoEAA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=unkeyed/unkey&utm_content=3403):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59a3e6e and e48d73e.

📒 Files selected for processing (6)
  • apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/override-indicator.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/api-id-navbar.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/logs-table.tsx (4 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx (2 hunks)
  • apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/root-keys-filter.tsx (2 hunks)
  • apps/dashboard/lib/shorten-id.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: autofix
  • GitHub Check: Test Packages / Test ./packages/cache
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (13)
apps/dashboard/lib/shorten-id.ts (1)

1-48: Excellent utility function implementation with comprehensive validation.

The shortenId function is well-designed with proper input validation, edge case handling, and sensible defaults. The logic correctly handles scenarios where shortening isn't beneficial or possible.

apps/dashboard/app/(app)/apis/[apiId]/api-id-navbar.tsx (2)

8-8: Clean import addition.

The import is correctly placed and follows the existing import organization pattern.


138-138: Proper usage of the shortenId utility.

The replacement of manual truncation logic with the centralized utility function improves maintainability and consistency across the codebase.

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx (2)

4-4: Import correctly positioned.

The import follows the established pattern and is placed appropriately with other utility imports.


186-186: Consistent ID shortening implementation.

The replacement standardizes ID display formatting across the dashboard, which improves user experience and code maintainability.

apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/override-indicator.tsx (2)

2-2: Import properly added.

The import is correctly placed at the top of the file with other utility imports.


90-90: Centralized ID shortening logic applied.

The change standardizes the key ID display format while maintaining all existing functionality for navigation and error handling.

apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/root-keys-filter.tsx (2)

3-3: Import appropriately positioned.

The import is correctly placed with other utility imports at the top of the file.


41-41: Consistent label formatting with centralized utility.

The replacement ensures consistent ID formatting across filter labels, maintaining the same user experience while improving code maintainability.

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/logs-table.tsx (4)

4-4: LGTM: Import statement correctly added.

The import for the new shortenId utility function follows the established import conventions and path structure.


315-315: Minor styling improvement added.

The addition of px-2 py-1 padding classes to the InfoTooltip improves the visual spacing around tag tooltips.


334-334: Improved vertical alignment.

Changing from items-start to items-center provides better visual alignment between the tag text and copy button elements.


358-362: Good refactoring to use standardized utility function.

The replacement of manual string truncation with the shortenId utility improves consistency across the application. The parameters are well-chosen for this use case:

  • startChars: 10 provides sufficient context
  • endChars: 0 focuses on the beginning of tags
  • minLength: 14 prevents unnecessary truncation of short tags

This aligns perfectly with the PR objective to standardize ID/string shortening throughout the codebase.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e48d73e and f43775c.

📒 Files selected for processing (2)
  • apps/dashboard/app/(app)/apis/[apiId]/api-id-navbar.tsx (2 hunks)
  • apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/logs-table.tsx (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/dashboard/app/(app)/apis/[apiId]/api-id-navbar.tsx (1)
apps/dashboard/lib/shorten-id.ts (1)
  • shortenId (5-48)
apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/logs-table.tsx (1)
apps/dashboard/lib/shorten-id.ts (1)
  • shortenId (5-48)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test Packages / Test ./internal/clickhouse
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
apps/dashboard/app/(app)/apis/[apiId]/api-id-navbar.tsx (1)

8-8: LGTM!

The import of the shortenId utility function is correct and follows the established pattern.

apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/logs-table.tsx (4)

4-4: LGTM!

The import of the shortenId utility function is correct and consistent with the refactoring across multiple components.


315-315: LGTM!

The addition of padding classes improves the tooltip styling and user experience.


334-334: LGTM!

The alignment change from items-start to items-center provides better visual alignment between the tag text and copy button.


358-362: LGTM!

The replacement of manual truncation with shortenId provides consistent behavior. The custom options are well-configured:

  • startChars: 10 shows meaningful tag content
  • endChars: 0 focuses on the beginning of tags
  • minLength: 14 ensures only longer tags are shortened

This maintains readability while standardizing the truncation logic across the application.

@chronark chronark enabled auto-merge June 30, 2025 08:15
@chronark chronark self-requested a review June 30, 2025 08:16
Copy link
Collaborator

@chronark chronark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the data access comment from rabbit

@chronark chronark self-assigned this Jun 30, 2025
@ogzhanolguncu
Copy link
Contributor Author

@chronark this is good to go

@chronark chronark added this pull request to the merge queue Jul 3, 2025
Merged via the queue into main with commit fb28466 Jul 3, 2025
30 checks passed
@chronark chronark deleted the util-for-key-shortening branch July 3, 2025 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants