-
Notifications
You must be signed in to change notification settings - Fork 49
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
hs cost #2443
hs cost #2443
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the WalkthroughThe changes in the pull request involve modifications to the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
You are out of MentatBot reviews. Your usage will refresh December 16 at 08:00 AM. |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
client/src/dojo/setup.ts (1)
Line range hint
19-94
: Consider splitting setup responsibilitiesThe
setup
function handles multiple concerns (network, components, system calls, sync). Consider:
- Breaking it down into smaller, focused functions
- Adding explicit error handling for sync operations
- Implementing retry logic for failed sync attempts
This would improve maintainability and reliability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
client/src/dojo/setup.ts
(2 hunks)
🔇 Additional comments (2)
client/src/dojo/setup.ts (2)
1-5
: LGTM! Import formatting improves readability
The grouped imports from @bibliothecadao/eternum enhance code organization.
52-58
: Verify the impact of broader key matching
The new clause for HYPERSTRUCTURE_CONFIG_ID uses "VariableLen" pattern matching with an undefined second key. This differs from the WORLD_CONFIG_ID approach which uses two separate clauses. Please verify:
- Is this broader matching intentional?
- Could this affect which entities are synced?
Let's check for any existing patterns in the codebase:
✅ Verification successful
Let me analyze the usage patterns further to understand the consistency of key matching.
Let me try one more search to see the complete setup context:
The broader key matching is intentional and consistent with the codebase patterns
Based on the evidence from the codebase:
- The
VariableLen
pattern matching withundefined
second key is consistent with howWORLD_CONFIG_ID
is handled, which also usesVariableLen
. - The usage of
getEntityIdFromKeys
shows thatHYPERSTRUCTURE_CONFIG_ID
is queried both with and without a second parameter across the codebase, justifying the need for variable length matching. - This pattern allows the sync to capture both single-key and two-key entity configurations, which aligns with the actual usage in the ConfigManager implementations.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Search for similar key pattern usage to understand the convention
# Look for similar pattern matching configurations
rg -A 5 "pattern_matching.*VariableLen" --type ts
# Look for HYPERSTRUCTURE_CONFIG_ID usage
rg "HYPERSTRUCTURE_CONFIG_ID" --type ts
Length of output: 4418
Script:
#!/bin/bash
# Look for getEntityIdFromKeys usage with HYPERSTRUCTURE_CONFIG_ID to understand the key patterns
rg -B 2 -A 2 "getEntityIdFromKeys.*HYPERSTRUCTURE_CONFIG_ID" --type ts
# Look for other config patterns in setup.ts
rg -A 10 "Keys: {" client/src/dojo/setup.ts
Length of output: 4577
Script:
#!/bin/bash
# Look at the complete setup.ts file to understand the key patterns
cat client/src/dojo/setup.ts
Length of output: 2395
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
client/src/ui/components/entities/Entity.tsx (2)
88-90
: Consider enhancing the syncing feedbackWhile the current implementation is functional, consider providing more detailed feedback about the synchronization process to improve user experience.
Here's a suggested enhancement:
if (isSyncing) { - return <div className="text-gold/50 italic">Syncing resources...</div>; + return ( + <div className="text-gold/50 italic flex items-center gap-2"> + <div className="animate-spin">⚙️</div> + <span>Syncing resources for {entityName[entity.entityType]}...</span> + </div> + ); }
Line range hint
51-104
: Consider extracting synchronization logicThe component currently handles both UI rendering and data synchronization. Consider extracting the synchronization logic into a custom hook (e.g.,
useEntitySync
) to:
- Improve code reusability
- Separate concerns
- Make the component more maintainable
- Simplify testing
Example structure:
// hooks/useEntitySync.ts export function useEntitySync(entityId: string) { const [isSyncing, setIsSyncing] = useState(false); const dojo = useDojo(); useEffect(() => { // Current synchronization logic }, [entityId]); return { isSyncing }; } // EntityArrival component const { isSyncing } = useEntitySync(arrival.entityId);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
client/src/ui/components/entities/Entity.tsx
(6 hunks)
🔇 Additional comments (3)
client/src/ui/components/entities/Entity.tsx (3)
14-14
: LGTM: Import addition is appropriate
The useState import is correctly added to support the new synchronization state management.
36-36
: LGTM: State management implementation is clean
The isSyncing state is well-placed and appropriately initialized.
51-69
: 🛠️ Refactor suggestion
Consider improving error handling and type safety
A few suggestions to enhance this implementation:
- Consider showing error feedback to users when synchronization fails
- The
as any
type assertion should be avoided if possible - Consider memoizing the network objects to prevent unnecessary effect triggers
Here's a suggested improvement:
+ const { toriiClient, contractComponents } = dojo.network;
+ const memoizedNetwork = useMemo(() => ({
+ toriiClient,
+ contractComponents
+ }), [toriiClient, contractComponents]);
useEffect(() => {
if (entityResources.length === 0) {
setIsSyncing(true);
const fetch = async () => {
try {
await addToSubscription(
- dojo.network.toriiClient,
- dojo.network.contractComponents as any,
+ memoizedNetwork.toriiClient,
+ memoizedNetwork.contractComponents,
arrival.entityId.toString(),
);
} catch (error) {
console.error("Fetch failed", error);
+ // Show error to user
+ toast.error("Failed to sync resources. Please try again.");
} finally {
setIsSyncing(false);
}
};
fetch();
}
- }, [arrival.entityId, dojo.network.toriiClient, dojo.network.contractComponents, entityResources.length]);
+ }, [arrival.entityId, memoizedNetwork, entityResources.length]);
Let's verify the type definition of contractComponents:
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
client/src/dojo/setup.ts (1)
52-58
: Consider sync performance implicationsThe addition of a new clause with variable length pattern matching could impact sync performance, especially with the existing 40,000 batch size. Consider:
- Monitoring sync performance after this change
- Implementing pagination or chunking if performance degrades
- Adding telemetry to track sync times specifically for hyperstructure entities
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
client/src/dojo/setup.ts
(2 hunks)
🔇 Additional comments (2)
client/src/dojo/setup.ts (2)
3-4
: LGTM: Import addition is consistent and used
The new import follows the existing pattern and is properly utilized in the code.
52-58
: Verify the use of "VariableLen" pattern matching
The new clause uses "VariableLen" pattern matching while other clauses use "FixedLen". This difference in matching strategy could have implications for entity synchronization.
Please verify:
- Is this difference intentional?
- Are there any security considerations for variable length matching?
Let's check for similar patterns in the codebase:
✅ Verification successful
Use of "VariableLen" pattern matching is consistent with similar config entities
Based on the codebase analysis, the use of "VariableLen" for HYPERSTRUCTURE_CONFIG_ID is intentional and follows an established pattern:
- In
WorldStructuresMenu.tsx
, "VariableLen" is used for all config-related queries including other hyperstructure entries - In
landing/src/dojo/setup.ts
, similar config entities (WORLD_CONFIG_ID) also use "VariableLen" - "FixedLen" is primarily used for position-based queries and entity-specific lookups as seen in
queries.ts
This pattern suggests that variable length matching is the intended strategy for config-related entities, allowing for flexible key structures while maintaining strict fixed-length matching for position and entity-specific queries.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other instances of VariableLen pattern matching
rg -B 5 -A 5 '"VariableLen"' --type ts
# Search for any documentation or comments about pattern matching
rg -B 5 -A 5 'pattern_matching' --type ts --type md
Length of output: 10791
* Add confirmation step to destroy building * raise limits and remove chat (#2435) * loading page loading itmes (#2436) * loaf-opti * buildings * load * push config * loading * fix for 0 donkey bridge, base manifest on chain env * tiles * merge * do sync * bank * market * bump * queries * reintroduce syncing and fetching * sync and get happening again * working multi bridge out step 2, fix transaction success states * tiles * remove logging * memo * world * set loading state * chunk * coords * as * bunk * bridge styling * update * update dojo version * update dojo sync * Fix hyperstructures * fix * add back chat * a * llint * ✨ Add sub to all player structures * fix(social): get name from address directly * chore: add has not settled realm yet * undefined if no realm found * pretty * fix: trade history crash * 🐛 Fix * config * add realm select border animation * hovered frag mine * hs cost (#2443) * hs cost * fix deposit arrival * update lock * load * Fix/army stamina (#2448) * Fix current tick values in nextBlockTimestamp * lint * Remove quest UI while syncing (#2449) * Remove quest UI while syncing * Add quest load animation * Raschel-dev (#2447) * hs cost * fix deposit arrival * update lock * fix hs crash * building cost config * fix namespace * remove resource cost syncing * added production * fix costs * add upgrade * trigger * remove events * fix tile * fixes * remove loading * fix: transfer view styling bug (#2451) * Fix social tribe crash (#2450) * fix build * fix market --------- Co-authored-by: Bob <[email protected]> Co-authored-by: tedison <[email protected]> Co-authored-by: ponderingdemocritus <[email protected]> Co-authored-by: tedison <[email protected]> Co-authored-by: RedBeardEth <[email protected]> Co-authored-by: Loaf <[email protected]> Co-authored-by: bal7hazar <[email protected]> Co-authored-by: Nasr <[email protected]> Co-authored-by: Larko <[email protected]> Co-authored-by: 0x1337 <[email protected]> Co-authored-by: Bob <[email protected]> Co-authored-by: zabanyat.eth <[email protected]>
* Add confirmation step to destroy building * raise limits and remove chat (#2435) * loading page loading itmes (#2436) * loaf-opti * buildings * load * push config * loading * fix for 0 donkey bridge, base manifest on chain env * tiles * merge * do sync * bank * market * bump * queries * reintroduce syncing and fetching * sync and get happening again * working multi bridge out step 2, fix transaction success states * tiles * remove logging * memo * world * set loading state * chunk * coords * as * bunk * bridge styling * update * update dojo version * update dojo sync * Fix hyperstructures * fix * add back chat * a * llint * ✨ Add sub to all player structures * fix(social): get name from address directly * chore: add has not settled realm yet * undefined if no realm found * pretty * fix: trade history crash * 🐛 Fix * config * add realm select border animation * hovered frag mine * hs cost (#2443) * hs cost * fix deposit arrival * update lock * load * Fix/army stamina (#2448) * Fix current tick values in nextBlockTimestamp * lint * Remove quest UI while syncing (#2449) * Remove quest UI while syncing * Add quest load animation * Raschel-dev (#2447) * hs cost * fix deposit arrival * update lock * fix hs crash * building cost config * fix namespace * remove resource cost syncing * added production * fix costs * add upgrade * trigger * remove events * fix tile * fixes * remove loading * fix: transfer view styling bug (#2451) * Fix social tribe crash (#2450) * fix build * fix market * feat: optimise event messages (#2455) * optimize events * fix getSyncEvents composite * small fixes --------- Co-authored-by: Bob <[email protected]> Co-authored-by: ponderingdemocritus <[email protected]> Co-authored-by: RedBeardEth <[email protected]> Co-authored-by: Loaf <[email protected]> Co-authored-by: aymericdelab <[email protected]> Co-authored-by: bal7hazar <[email protected]> Co-authored-by: Nasr <[email protected]> Co-authored-by: Larko <[email protected]> Co-authored-by: 0x1337 <[email protected]> Co-authored-by: raschel <[email protected]> Co-authored-by: Bob <[email protected]> Co-authored-by: zabanyat.eth <[email protected]>
* Add confirmation step to destroy building * raise limits and remove chat (#2435) * loading page loading itmes (#2436) * loaf-opti * buildings * load * push config * loading * fix for 0 donkey bridge, base manifest on chain env * tiles * merge * do sync * bank * market * bump * queries * reintroduce syncing and fetching * sync and get happening again * working multi bridge out step 2, fix transaction success states * tiles * remove logging * memo * world * set loading state * chunk * coords * as * bunk * bridge styling * update * update dojo version * update dojo sync * Fix hyperstructures * fix * add back chat * a * llint * ✨ Add sub to all player structures * fix(social): get name from address directly * chore: add has not settled realm yet * undefined if no realm found * pretty * fix: trade history crash * 🐛 Fix * config * add realm select border animation * hovered frag mine * hs cost (#2443) * hs cost * fix deposit arrival * update lock * load * Fix/army stamina (#2448) * Fix current tick values in nextBlockTimestamp * lint * Remove quest UI while syncing (#2449) * Remove quest UI while syncing * Add quest load animation * Raschel-dev (#2447) * hs cost * fix deposit arrival * update lock * fix hs crash * building cost config * fix namespace * remove resource cost syncing * added production * fix costs * add upgrade * trigger * remove events * fix tile * fixes * remove loading * fix: transfer view styling bug (#2451) * Fix social tribe crash (#2450) * fix build * fix market * add lords to controller on landing * feat: optimise event messages (#2455) * optimize events * fix getSyncEvents composite * small fixes * 🐛 Fix mainnet torii cfg * Fix laggy social search * landing page + quest + inventory (#2461) * update inventory * more discrete quest loading * fix landing page sync --------- Co-authored-by: Bob <[email protected]> Co-authored-by: tedison <[email protected]> Co-authored-by: ponderingdemocritus <[email protected]> Co-authored-by: tedison <[email protected]> Co-authored-by: RedBeardEth <[email protected]> Co-authored-by: Loaf <[email protected]> Co-authored-by: bal7hazar <[email protected]> Co-authored-by: Nasr <[email protected]> Co-authored-by: Larko <[email protected]> Co-authored-by: 0x1337 <[email protected]> Co-authored-by: Bob <[email protected]> Co-authored-by: zabanyat.eth <[email protected]>
Summary by CodeRabbit
New Features
Bug Fixes
Style