MCPcopy Index your code
hub / github.com/bytebase/bytebase / changeContextStatus

Function changeContextStatus

frontend/src/react/hooks/useExecuteSQL.ts:111–139  ·  view source on GitHub ↗
(
    database: string,
    ctx: SQLEditorDatabaseQueryContext,
    status: QueryContextStatus
  )

Source from the content-addressed store, hash-verified

109 // state, detects no change, and returns the same state reference —
110 // Zustand then skips firing subscribers, and the UI never re-renders.
111 const changeContextStatus = (
112 database: string,
113 ctx: SQLEditorDatabaseQueryContext,
114 status: QueryContextStatus
115 ) => {
116 const patch: Partial<SQLEditorDatabaseQueryContext> = { status };
117 switch (status) {
118 case "EXECUTING": {
119 patch.abortController = new AbortController();
120 patch.beginTimestampMS = Date.now();
121 break;
122 }
123 case "CANCELLED":
124 ctx.abortController?.abort();
125 break;
126 case "DONE":
127 break;
128 }
129 const next = getSQLEditorTabsState().updateDatabaseQueryContext({
130 database,
131 contextId: ctx.id,
132 context: patch,
133 });
134 if (!next) {
135 // Ad-hoc context (not in the tab's map): mirror the patch onto
136 // the passed-in object so awaiters can still observe the result.
137 Object.assign(ctx, patch);
138 }
139 };
140
141 const preExecute = useCallback(
142 async (params: SQLEditorQueryParams) => {

Callers 2

useExecuteSQLFunction · 0.85
finishFunction · 0.85

Calls 1

getSQLEditorTabsStateFunction · 0.90

Tested by

no test coverage detected