Skip to content

Conversation

pablonyx
Copy link
Contributor

@pablonyx pablonyx commented Apr 13, 2025

Description

Fixes https://linear.app/danswer/issue/DAN-1907/get-my-docs-cleanup-in

How Has This Been Tested?

[Describe the tests you ran to verify your changes]

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

Copy link

vercel bot commented Apr 13, 2025

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

Name Status Preview Comments Updated (UTC)
internal-search ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 25, 2025 4:30am

@Weves Weves force-pushed the my_docs_cleanup branch from 48b278b to c43d86d Compare April 25, 2025 04:13
@Weves Weves marked this pull request as ready for review April 25, 2025 04:20
@Weves Weves requested a review from a team as a code owner April 25, 2025 04:20
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Based on the provided changes, here is a concise summary of the key modifications in this pull request:

The PR primarily focuses on cleanup and UI improvements across the codebase, with some functional changes to persona management and tenant provisioning.

Key changes:

  • Improved tenant provisioning by renaming Redis lock to CLOUD_PRE_PROVISION_TENANT_LOCK and adding proper cloud task scheduling
  • Enhanced persona privacy management by adding creator_user_id parameter to prevent unnecessary notifications
  • Streamlined file/folder management in MyDocuments components by removing unused move/rename functionality and improving mobile responsiveness
  • Added dark mode support and mobile-friendly styling across multiple components
  • Fixed potential redirect loops in authentication flow by adding source tracking

The changes appear focused on improving code organization and user experience while maintaining core functionality. However, some areas need attention:

  • The removal of forgot password functionality in cloud mode needs documentation explaining the rationale
  • The LaTeX content processing changes should be tested thoroughly
  • The Modal overflow change from 'auto' to 'visible' could cause layout issues

56 file(s) reviewed, 29 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +33 to +41
if user_id != creator_user_id:
create_notification(
user_id=user_id,
notif_type=NotificationType.PERSONA_SHARED,
db_session=db_session,
additional_data=PersonaSharedNotificationData(
persona_id=persona_id,
).model_dump(),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Notification check correctly prevents sending to creator, but should also check if creator_user_id is None to avoid potential false negatives

Suggested change
if user_id != creator_user_id:
create_notification(
user_id=user_id,
notif_type=NotificationType.PERSONA_SHARED,
db_session=db_session,
additional_data=PersonaSharedNotificationData(
persona_id=persona_id,
).model_dump(),
)
if creator_user_id is not None and user_id != creator_user_id:
create_notification(
user_id=user_id,
notif_type=NotificationType.PERSONA_SHARED,
db_session=db_session,
additional_data=PersonaSharedNotificationData(
persona_id=persona_id,
).model_dump(),
)

MONITOR_BACKGROUND_PROCESSES_LOCK = "da_lock:monitor_background_processes"
CHECK_AVAILABLE_TENANTS_LOCK = "da_lock:check_available_tenants"
PRE_PROVISION_TENANT_LOCK = "da_lock:pre_provision_tenant"
CLOUD_PRE_PROVISION_TENANT_LOCK = "da_lock:pre_provision_tenant"
Copy link
Contributor

Choose a reason for hiding this comment

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

style: The lock name string value remains unchanged despite the constant being renamed to include 'CLOUD_'. Consider updating the string value to also include 'cloud_' for consistency.

folders = (
db_session.query(UserFolder)
.filter(
(UserFolder.user_id == user_id) | (UserFolder.id == RECENT_DOCS_FOLDER_ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Potential security issue: RECENT_DOCS_FOLDER_ID is used before being defined (line 144). Move constant definition to top of file.

Comment on lines +106 to +108
folder_snapshot.files = [
file for file in folder_snapshot.files if file.user_id == user_id
]
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Performance concern: filtering files in memory instead of in the database query. Consider adding user_id filter to the initial query.

def get_current_tenant_id() -> str:
tenant_id = CURRENT_TENANT_ID_CONTEXTVAR.get()
if tenant_id is None:
import traceback
Copy link
Contributor

Choose a reason for hiding this comment

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

style: importing traceback inside function scope - consider moving to top-level imports for better performance and readability

<div className="hidden sm:block relative w-24 h-2 bg-neutral-200 dark:bg-neutral-700 rounded-full overflow-hidden">
<div
className={`absolute top-0 left-0 h-full rounded-full ${
className={` absolute top-0 left-0 h-full rounded-full ${
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Extra space at start of className template literal is unnecessary

Comment on lines +31 to +35
// Log render count on each render
useEffect(() => {
setRenderCount((prevCount) => prevCount + 1);
console.log(`TextView component rendered ${renderCount + 1} times`);
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This effect creates unnecessary re-renders and console spam. Remove the render count tracking as it serves no production purpose and impacts performance.

Suggested change
// Log render count on each render
useEffect(() => {
setRenderCount((prevCount) => prevCount + 1);
console.log(`TextView component rendered ${renderCount + 1} times`);
}, []);

Comment on lines 122 to +124
useEffect(() => {
fetchFile();
}, [fetchFile]);
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Empty dependency array but using fetchFile callback - this will use stale closure. Should include [fetchFile] in dependencies.

Suggested change
useEffect(() => {
fetchFile();
}, [fetchFile]);
}, []);
useEffect(() => {
fetchFile();
}, [fetchFile]);

};

const fetchFile = useCallback(async () => {
console.log("fetching file");
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Remove debug console.log statements before merging to production


return (
<div>
<div className="b">
Copy link
Contributor

Choose a reason for hiding this comment

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

style: The 'b' class name appears to be a typo or undefined class. Consider using a more descriptive class name or removing if unnecessary.

Suggested change
<div className="b">
<div>

@Weves Weves enabled auto-merge April 25, 2025 04:41
@Weves Weves added this pull request to the merge queue Apr 25, 2025
Merged via the queue into main with commit df67ca1 Apr 25, 2025
11 of 12 checks passed
@Weves Weves deleted the my_docs_cleanup branch April 25, 2025 06:13
aronszanto pushed a commit to aronszanto/onyx that referenced this pull request Apr 26, 2025
* update

* improved my docs

* nit

* nit

* k

* push changes

* update

* looking good

* k

* fix preprocessing

* try a fix

* k

* update

* nit

* k

* quick nits

* Cleanup / fixes

* Fixes

* Fix build

* fix

* fix quality checks

---------

Co-authored-by: Weves <chrisweaver101@gmail.com>
AnkitTukatek pushed a commit to TukaTek/onyx that referenced this pull request Sep 23, 2025
* update

* improved my docs

* nit

* nit

* k

* push changes

* update

* looking good

* k

* fix preprocessing

* try a fix

* k

* update

* nit

* k

* quick nits

* Cleanup / fixes

* Fixes

* Fix build

* fix

* fix quality checks

---------

Co-authored-by: Weves <chrisweaver101@gmail.com>
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.

2 participants