-
Notifications
You must be signed in to change notification settings - Fork 2
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
workspace handles #554
base: master
Are you sure you want to change the base?
workspace handles #554
Conversation
@devxpy do you want to review and merge this part first? - adding workspace->handle to DB and allowing workspace admins to edit it. Or, to wait and review it along with the UI changes for rendering the workspace page on |
return new_handle | ||
|
||
|
||
def update_handle(handle: Handle | None, name: str | None) -> Handle | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be a method on Handle?
I do think the better path would be to move handles from app user to workspace entirely, but I guess this is easier |
I was thinking the same, but not entirely. On the users' profile page, we do include contributions to other workspaces and I think that's the way we want it. I also think it's likely that we might want to allow adding saved runs from another workspace to a user's profile a la github |
I meant more like how we transferred billing info from user to workspace so its consistent and we can always refer to current_workspace.handle |
that makes sense to me 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR adds handle functionality to workspaces, allowing teams to have unique identifiers similar to user handles, with automatic handle generation and management through the admin interface.
- Added
handle
OneToOneField toWorkspace
model with proper validation and uniqueness constraints in/workspaces/models.py
- Implemented automatic handle generation for workspaces based on display name in
/handles/models.py
with fallback options - Added handle input field and update logic to workspace edit form in
/workspaces/views.py
with transaction handling - Added new index on
PublishedRun
model for optimizing visibility/workspace queries inbots/migrations/0091_publishedrun_bots_publis_visibil_cf3dd8_idx.py
- Updated
PublishedRunVisibility
to support public visibility for team workspace handles in/bots/models.py
💡 (3/5) Reply to the bot's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!
10 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile
if workspace.is_personal: | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: returning None from a generator is incorrect - should use 'return' with no value or just 'return []'
@@ -84,7 +85,7 @@ class WorkspaceAdmin(SafeDeleteAdmin): | |||
] | |||
inlines = [WorkspaceMembershipInline, WorkspaceInviteInline] | |||
ordering = ["-created_at"] | |||
autocomplete_fields = ["created_by", "subscription"] | |||
autocomplete_fields = ["created_by", "handle", "subscription"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: handle added to autocomplete_fields but Handle model needs search_fields defined in its admin for autocomplete to work
workspace.handle = Handle.create_default_for_workspace(workspace) | ||
if workspace.handle: | ||
workspace.save() | ||
session[SESSION_SELECTED_WORKSPACE] = workspace.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Handle creation and save should be wrapped in a transaction to ensure atomicity. If save fails after handle creation, the handle could be orphaned.
Q/A checklist
You can visualize this using tuna:
To measure import time for a specific library:
To reduce import times, import libraries that take a long time inside the functions that use them instead of at the top of the file:
Legal Boilerplate
Look, I get it. The entity doing business as “Gooey.AI” and/or “Dara.network” was incorporated in the State of Delaware in 2020 as Dara Network Inc. and is gonna need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Dara Network Inc can use, modify, copy, and redistribute my contributions, under its choice of terms.