Skip to content
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

DEV2-4200: Fix inconsistent behavior (also DEV2-3330) #692

Merged
merged 31 commits into from
Nov 28, 2023

Conversation

ofekby
Copy link
Contributor

@ofekby ofekby commented Nov 21, 2023

No description provided.

@ofekby ofekby requested a review from a team as a code owner November 21, 2023 09:16
@ofekby ofekby force-pushed the fix-inconsistent-behavior branch from 302859b to e57eaa3 Compare November 21, 2023 11:18
import com.tabnineCommon.general.TopicBasedState
import java.util.function.Consumer

class BinaryStateSingleton private constructor() :
Copy link
Contributor

Choose a reason for hiding this comment

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

should we consider this singleton to be persisted, til first poling?
will that make the experience more consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think persisting it can only cause more flakiness and unstable states. Data in the state is considered to be very moment related. Also few IDE can edit it simultaneously.

Comment on lines 46 to 48
val alphaEnabled = CapabilitiesService.getInstance().isCapabilityEnabled(Capability.ALPHA)
val chatCapabilityEnabled =
CapabilitiesService.getInstance().isCapabilityEnabled(Capability.TABNINE_CHAT)
Copy link
Contributor

Choose a reason for hiding this comment

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

how does this behave in SH? empty responses?

Copy link
Contributor Author

@ofekby ofekby Nov 27, 2023

Choose a reason for hiding this comment

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

It doesn't execute this code in SH, this code is only for the SAAS plugin. Anyhow the Capabilities service returns true for any capability asked in SH (It always was that way, didn't change it).

val chatCapabilityEnabled =
CapabilitiesService.getInstance().isCapabilityEnabled(Capability.TABNINE_CHAT)

if (isLoggedIn && (alphaEnabled || chatCapabilityEnabled)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

does this apply to SH too? how does this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this code is the enable logic of the SAAS, SH has separate class for its logic.

when {
!CapabilitiesService.getInstance().isCapabilityEnabled(Capability.FORCE_REGISTRATION) -> return
!forceRegistration -> return
Copy link
Contributor

Choose a reason for hiding this comment

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

is this still relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the force registration flag is still alive

@@ -44,17 +45,23 @@ fun openSigninPage() {
fun presentGreeting(state: StateResponse?) {
if (state?.userName != null) {
TABNINE_NOTIFICATION_GROUP
.createNotification("You are signed in as ${state.userName}", NotificationType.INFORMATION)
.createNotification(
"You are signed in as ${state.userName}",
Copy link
Contributor

Choose a reason for hiding this comment

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

question. do we have the team name too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the state doesn't contain the team name or any information about the team.

capabilities -> {
if (capabilities.isReady()) {
boolean newForceRegistration = capabilities.isEnabled(Capability.FORCE_REGISTRATION);
CapabilitiesStateSingleton.getInstance()
Copy link
Contributor

Choose a reason for hiding this comment

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

do all IJ windows share this singleton? or do they run in different processes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, its per IJ process. Every IJ window is a separate process.

Copy link
Contributor

Choose a reason for hiding this comment

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

so will these changes solve also the multiple windows issues?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ofekby incorrect, all JB windows are under the same process. in vscode its as you say, each window is a process, but not in JB.

import com.tabnineSelfHosted.binary.requests.userInfo.UserInfoResponse
import java.util.function.Consumer

class UserInfoStateSingleton private constructor() :
Copy link
Contributor

Choose a reason for hiding this comment

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

same question regarding this singleton, should it be persisted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general for live data like that I think we shouldn't persist the data, and just have a loading state. Other IDEs can signout while IJ was closed, which will cause a weird startup.

Copy link
Contributor

Choose a reason for hiding this comment

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

what will happen when we encounter network issues?

ENABLED_TOPIC, ChatState.loading()
) {

companion object {
Copy link
Contributor

Choose a reason for hiding this comment

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

why companion object? will the result be different from a static singleton?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Companion object is basically a static instance. For the implementation of the class I always prefer not implementing statically. In general I don't really like singletons but the initialisation process is a little bit complex so it will do for now.

notifyListeners()
}

fun useState(parent: Disposable, subscription: S) {
Copy link
Contributor

Choose a reason for hiding this comment

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

change to onChange

}

CapabilitiesStateSingleton.instance.useState {
updateEnabled()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check for using the current value

import com.tabnineCommon.chat.actions.AbstractTabnineQuickFixAction

class TabnineQuickFixAction : AbstractTabnineQuickFixAction() {
override fun isChatEnabled() = ChatEnabledState.instance.get().enabled
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add to the other one prefix

Copy link
Contributor

@yonip23 yonip23 left a comment

Choose a reason for hiding this comment

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

aside from what we discussed in the friend review, lgtm 🚀

Copy link
Contributor

@yanir-codota yanir-codota left a comment

Choose a reason for hiding this comment

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

LGTM

@ofekby ofekby merged commit f363f88 into master Nov 28, 2023
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